私は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;
}
}