Example #1
0
 public function deleteBulk(Request $request, LibraryBook $BookModle)
 {
     //$id = $BookModle->where('category_id',$cat_id)->get();
     // if the table_records is empty we redirect to the subject index
     if (!$request->has('table_records')) {
         return redirect()->route('library.category.index');
     }
     $message = "تم حذف الكتب بنجاح";
     // we get all the ids and put them in a variable
     $ids = $request->input('table_records');
     // we delete all the subject with the ids $ids
     $BookModle->destroy($ids);
     // we redirect to the user index view with a success message
     return redirect()->route('library.category.index')->with('success', $message);
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //LibraryBook
     LibraryBook::created(function ($book) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Library_book', 'reference_id' => $book->id]);
     });
     LibraryBook::updated(function ($book) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Library_book', 'reference_id' => $book->id]);
     });
     LibraryBook::deleted(function ($book) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Library_book', 'reference_id' => $book->id]);
     });
     //LibraryCategory
     LibraryCategory::created(function ($category) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Library_category', 'reference_id' => $category->id]);
     });
     LibraryCategory::updated(function ($category) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Library_category', 'reference_id' => $category->id]);
     });
     LibraryCategory::deleted(function ($category) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Library_category', 'reference_id' => $category->id]);
     });
 }