我制作了自己的类
<?php
namespace AppÇonsole;
use AppKernelSetting;
class Setting
{
/**
* @param $setting
* @return
*/
function KS($setting)
{
return KernelSetting::where('setting', $setting)->first()->value;
}
}
现在我这样称呼它Setting::KS('review_time_limit')
如何从获取的数据库条目中返回value
?
我得到这个
Non-static method AppConsoleSetting::KS() should not be called statically
错误消息非常清楚,您需要将方法设置为静态,以便这样调用它。
static function KS($setting)
{
return KernelSetting::where('setting', $setting)->first()->value;
}
你可以在这里阅读更多关于静态的信息:https://www.php.net/manual/en/language.oop5.static.php