public function delete($id) { $book = new \App\Book(); $book->find($id)->delete(); //$book->delete(); return redirect('books'); }
function getExample6() { $book = new \App\Book(); $book_to_update = $book->find(1); $book_to_update->title = 'Green Eggs adn Ham'; $book_to_update->save(); return 'Example 6'; }
function getExample5() { $book = new \App\Book(); $harry_potter = $book->find(8); $harry_potter->delete(); }
Route::get('login', ['uses' => 'LoginController@index', 'middleware' => 'login']); Route::group(['middleware' => 'admin', 'prefix' => 'admin'], function () { Route::get('/', 'AdminController@index'); Route::resource('users', 'UserController'); Route::get('profile', 'UserController@editProfile'); Route::put('profile/update/{id}', ['as' => 'profile.admin', 'uses' => 'UserController@updateProfile']); Route::resource('books', 'BookController'); Route::get('users/reset/{id}', 'UserController@reset'); }); Route::group(['middleware' => 'operator', 'prefix' => 'operator'], function () { Route::get('/', ['as' => 'op', 'uses' => 'OperatorController@index']); Route::resource('users', 'UserController'); Route::get('profile', 'UserController@editProfile'); Route::put('profile/update/{id}', ['as' => 'profile.operator', 'uses' => 'UserController@updateProfile']); Route::get('users/reset/{id}', 'UserController@reset'); Route::resource('borrow', 'BorrowController'); Route::resource('books', 'BookController'); Route::get('order', 'OrderController@index'); Route::get('order/{id}', 'OrderController@process'); Route::resource('transactions', 'TransactionController'); }); Route::group(['middleware' => 'member'], function () { Route::get('books/order/{id}', ['as' => 'order', 'uses' => 'OrderController@order']); Route::put('/profile/update/{id}', ['as' => 'profile.member', 'uses' => 'UserController@updateName']); Route::put('users/{id}', 'UserController@updateProfile'); }); Route::get('image/{id}', function ($id) { $book = App\Book::find($id); $img = Image::make(asset('images/cover/' . $book->cover))->resize(268, 249); return $img->response('jpg'); });