我正在使用 laravel 5。在一个模型中,我有一个静态函数,我在控制器中调用它。它工作正常,但我希望在这个函数中使用另一个非静态函数进行相同的更改,当我在静态函数中调用它时会产生错误。
Non-static method App\Models\Course::_check_existing_course() should not be called statically
这是我的模型
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Course extends Model {
public $course_list;
protected $primaryKey = "id";
public function questions(){
return $this->belongsToMany('App\Models\Question','course_questions')->where("status",1)->orderBy("id","DESC");
}
public static function courses_list(){
self::_check_existing_course();
}
private function _check_existing_course(){
if(empty($this->course_list)){
$this->course_list = self::where("status",1)->orderBy("course")->get();
}
return $this->course_list;
}
}