我要访问的观点Laravel模型属性鉴于
我的模型类的静态属性我已经试过
{{ \App\task::$accounts_currency }}
{{ \App\task::accounts_currency }}
但似乎没有任何工作。请指导 感谢
我的模型类
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class task extends Model
{
protected $fillable = [
'title',
'description'
];
public static $company_name = 'SolutionsLtd.';
public static $company_address_l1 = "Adress";
public static $company_address_l2 = "Cell# 11111111111";
public static $company_address_l3 = "Pabx# 1111111111111";
public static $reports_prefix = "LS_";
public static $invoices_prefix = "LS-";
public static $accounts_currency = "USD";
public static $currency_symbol = "USD.";
public static $financial_year = "07-01"; // MM-DD
}
错误:
FatalErrorException在87347301c85619fc6de3f6b6738745f2行105: 访问未申报的静态属性:应用程序\任务:: $ accounts_currency
为什么不能让一个方法,其中,将返回所有?比如'public function getStatics(){return ['company_name'=> $ this-> company_name,'etc'=> $ this-> etc]; }' – Demonyowh
你有什么错误吗? –
@AndreyLutskevich它说错误:FatalErrorException 87347301c85619fc6de3f6b6738745f2第105行:访问未声明的静态属性:App \ task :: $ accounts_currency – Peter