我尝试在QuizSubmissionController中创建关系,以获得未回答提交的问题。quiz_submission->quiz->questions()->whereDoesntHave('answers')或whereNotExist('submission_answers')这样的东西吗我在这里的亲戚:public function category() return $this->be
当我使用带有Laravel Eloquent的ModelName::with('somerelation')->get()时,如果模型没有这种关系,我会得到Call to undefined relationship但是对于多态关系,我得到了所有相关模型的集合,如果没有定义关系,我想使用with('somerelation')和null。有没有办法避免错误并从with()返回null,或者有条件地使用呢?
我有这个laravel作用域代码 public function apply(Builder $builder, Model $model) $builder->whereDoesntHave('getPermissionData');
} 到现在为止,一切都很好,我需要的是写下这样的条件 public function apply(Builder $builder, Model $model
我正在建设一个Laravel应用程序,在那里人们阅读书籍,最喜欢的书也。'favorited' => I want o show true or false depending if user favorited }
public function indexapi() return BookResource::collection(