Route::get('update', ['as' => 'ORM.update', function () { // 更新資料 $data = \App\Models\Articles::find(1); $data->update(['article_title' => 'update test.', 'feature' => true]); $data = \App\Models\Articles::where('id', '=', 10); $data->update(['article_title' => 'update test=3=.', 'feature' => false]); // save方法 $data = \App\Models\Articles::where('id', '=', 11)->first(); $data->article_title = 'update test -3-.'; $data->feature = true; $data->save(); }]); Route::get('delete', ['as' => 'ORM.delete', function () { $data = \App\Models\Articles::find(2); $data->delete(); \App\Models\Articles::destroy(19, 20); }]); }); Route::get('test', function () { // $data = \App\Models\Article::find(5); $data1 = \App\Models\Article::all(); $data2 = \App\Models\Article::where('id', '>', 8); $data3 = \App\Models\Article::orderBy('id', 'DESC'); dd([$data1, $data2, $data3]); }); /* Route::get('hello', function(){ return "Hello World!"; }); Route::get('post/{id}', function($id) {
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Request $request) { Articles::destroy($request->aID); return "success"; }