skip to Main Content

Laravel – Attempt to read property "episodes" on null

I wrote a code that sums the number of minutes of several videos together. But it shows the following error: Attempt to read property "episodes" on null public function setCourseTime($episode) { $course = $episode->course; $course->time = $this->getCourseTime($course->episodes->pluck('time')); $course->save(); } Model…

VIEW QUESTION

How to load a relationship in Laravel without foreign key?

I have this model: AppControllersImageController.php ..... $image = new Image; $image->id = "pre_" . (string) Str::ulid()->toBase58(); $image->filename = $filename $image->post_id= $post_id; $image->save(); return $image->load("post:id,status,subject,body"); it is working fine, it returns the following: { "id": "pre_1BzVrTK8dviqA9FGxSoSnU", "type": "document", "filename": "v1BzVc3jJPp64e7bQo1drmL.jpeg", "post_id":…

VIEW QUESTION

Laravel where condition from string

I just want to make a where clause from string as my where clause depends upon the other variable. I did like this $where_condition = "post_flight_informations.schedule_year,=,2022"; and then applied to query like this ->where($where_condition) but it is taking $where_condition as…

VIEW QUESTION
Back To Top
Search