/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // //生成测试数据 // $res = Factory(Lesson::class, 10)->create(); $lessons = Lesson::all(); return $this->response(['status' => 'success', 'data' => $this->lessonTransformer->transformCollection($lessons->toArray())]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // Why this is bad: // 1. All is bad (maybe alright for small queries, bad for thousands of records). // 2. Linking DB structure to the API output. $lessons = Lesson::all(); return $this->respond(['data' => $this->lessonTransformer->transformCollection($lessons->toArray())]); }
public static function lessons() { if (Gate::allows('view_lesson')) { return Lesson::all(); } elseif (Auth::check() && Gate::allows('view_own_lesson')) { return Lesson::where('user_id', Auth::id())->get(); } else { return null; } }
public function index() { //1.All is bad. //2.No way to attach metadata. //3.Linking db structure to API output. //4.No way to signal headers/response codes. $lessons = Lesson::all(); return Response()->json(['data' => $this->lessonTransformer->transformCollection($lessons->all())], 200); //return $lessons = Lesson::all();//really bad practice }
/** * Execute the console command. * * @return mixed */ public function handle() { $lessons = \App\Lesson::all(); foreach ($lessons as $lesson) { $path = base_path(\App\Lesson::$path . DIRECTORY_SEPARATOR . $lesson->name); $lesson->content = \File::get($path); $lesson->save(); $lesson->touch(); $this->info(sprintf('Success updating %d: %s', $lesson->id, $lesson->name)); } return $this->warn('Finished.'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function home() { $all = Category::where('parent', '=', 0); $fullcat = Category::get(); $allarticles = Article::orderBy('id', 'desc')->take(10)->get(); $alllessons = Lesson::groupBy('categories_id')->orderBy('id', 'desc')->take(10)->get(); $newsallarticles = Article::where('stat', '=', 'nouvelles')->orderBy('id', 'desc')->take(3)->get(); $bacallarticles = Article::where('stat', '=', 'apres-bac')->orderBy('id', 'desc')->take(3)->get(); $lessons = Lesson::all(); $partners = Partner::all(); return view(proj . '.home', ['title' => trans('accueil.accueil'), 'asccat' => $all->get(), 'allcat' => $all->orderBy('id', 'desc')->get(), 'fullcat' => $fullcat, 'allarticles' => $allarticles, 'newsallarticles' => $newsallarticles, 'bacallarticles' => $bacallarticles, 'partners' => $partners, 'alllessons' => $alllessons])->with('lessons', $lessons); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { // $lesson = Lesson::where('user_id', $request->user()->id)->get()->medias; if (Auth::user()->group_id != 1) { $lessons = Lesson::where('category_id', Auth::user()->category_id)->get(); $infos = Info::all(); $notes = Note::where('user_id', Auth::user()->id)->get(); } else { $lessons = Lesson::all(); $infos = Info::all(); $notes = Note::where('user_id', Auth::user()->id)->get(); } return view('home.index', compact('lessons', 'infos', 'notes')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $lessons = Lesson::all(); $episodes = Episode::all(); return view('episodes.index', compact('lessons', 'episodes')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $lessons = Lesson::all(); return view('lessons.index', compact('lessons')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $lessons = Lesson::all(); return $this->respond(['data' => $this->lessonTransformer->transformCollection($lessons->toArray())]); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $lessons = Lesson::all(['id']); return view('infos.create', compact('lessons')); }
public function indexGET() { $data = \App\Lesson::all(); return $this->respond(['data' => $this->lessonTransformer->transformCollection($data->toArray())]); }