Advertisement
refda21

CurriculumLectureResource

Apr 6th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Resources;
  4.  
  5. use App\Models\Course;
  6. use App\Models\Lecture;
  7. use App\Models\Quiz;
  8. use Illuminate\Http\Resources\Json\JsonResource;
  9. use Illuminate\Support\Facades\Auth;
  10.  
  11.  
  12. class CurriculumLectureResource extends JsonResource
  13. {
  14.     public function toArray($request)
  15.     {
  16.         $lectureId = $request->lecture_id;
  17.         return [
  18.             'id' => $this->id,
  19.             'title_section' => json_decode($this->title_section),
  20.             'learning_objective'=> json_decode($this->learning_objective),
  21.             'lecture_detail' => LectureDisplayResource::collection(new LectureDisplayResource(
  22.                     Lecture::where('id','=',$lectureId)
  23.                         ->get())
  24.             ),
  25.  
  26.             'parent_id' => $this->id,
  27.             'course_id' => $this->course_id,
  28.         ];
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement