$flights = App\Flight::where('active', 1) ->orderBy('name', 'desc') ->take(10) ->get(); $price = DB::table('flights') ->orderBy('name', 'desc') ->take(10) ->get(); 其實只是至關於App\Flight等於了DB::table('flights')
public function create() { $d=Lesson::find(1)->videos()->get(); dd($d->toArray()); return view('admin.lesson.create'); }
require(['vue'],function (Vue) { new Vue({ el:'#app', data:{ videos:JSON.parse('{!! $videos !!}') }, mounted:function(){ this.videos.forEach(function (v) { //掛載以添加點擊事件 upload(v); }) }, methods:{ add:function () { var field={title:'',path:'',id:'fry'+Date.parse(new Date())}; this.videos.push(field); //綁定上傳事件,200ms是由於擔憂add方法以後元素還沒出來,數據改動以後元素出來vue渲染須要時間 setTimeout(function () { upload(field); },100); }, del:function (k) { this.videos.splice(k,1); } } }); });
public function edit($id) { $lesson=Lesson::find($id); $videos=json_encode($lesson->videos()->get()->toArray(),JSON_UNESCAPED_UNICODE); //dd($videos); return view('admin.lesson.edit',compact('lesson','videos')); }
php -mphp