워크 벤치 환경에서 패키지를 개발 중입니다. 난 내가 클래스 자체 내에서클래스의 인스턴스를 가져 오는 Laravel 모델
public function getDefaultCatalogs() {
return Catalog::where('is_default_catalog', '=', true)->get();
}}
같은 사용자 정의 인스턴스 게터를 가질 수 있다면
<?php namespace Vendor\Webshop\Models;
use Vendor\Webshop\Models\Country as Country;
use Illuminate\Database\Eloquent\Model as Eloquent;
/**
* A catalog
*/
class Catalog extends Eloquent {
// Define the database
protected $table = 'catalogs';
// Mass assignment restriction
protected $guarded = array('id');
// Return the countries related to this catalog
public function countries() {
return $this->belongsToMany('Vendor\Webshop\Models\Country');
}
/**
* Returns whether to enforce the compability check or not
*/
public function getForceCompabilityTest() {
return $this->force_compability_check;
}
}
?>
같은 모델은 내가 궁금합니다. 이게 가능합니까 아니면 구체적인 인스턴스에서만 사용할 수있는 메서드입니까? 클래스 외부에서 Catalog::getDefaultCatalogs()
과 같은 식으로 호출 할 수 있습니까?
'Vendor \ Webshop \ Models \ Catal와 같은 제품을 사용해 보셨습니까? og :: getDefaultCatalogs()' –
그것은 클래스의 바깥 쪽에서 메서드의 정적 호출에 대한 네임 스페이스에 대해 많은 것이 아니 었습니다. 오해의 소지가 있었고, 슬프다. – pfried