示例#1
0
 public function deleteBulk(Request $request, TeacherGuide $GuideModel)
 {
     // if the table_records is empty we redirect to the subject index
     $message = ' لم تقم بتحديد أي عنصر';
     if (!$request->has('table_records')) {
         return redirect()->route('teachers.guides.index')->with('success', $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
     $GuideModel->destroy($ids);
     // we redirect to the user index view with a success message
     $message = 'تم حذف الكل بنجاح';
     return redirect()->route('teachers.guides.index')->with('success', $message);
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //Teacher
     Teacher::created(function ($teacher) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_teacher', 'reference_id' => $teacher->id]);
     });
     Teacher::updated(function ($teacher) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_teacher', 'reference_id' => $teacher->id]);
     });
     Teacher::deleted(function ($teacher) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_teacher', 'reference_id' => $teacher->id]);
     });
     //TeacherFund
     TeacherFund::created(function ($fund) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_fund', 'reference_id' => $fund->id]);
     });
     TeacherFund::updated(function ($fund) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_fund', 'reference_id' => $fund->id]);
     });
     TeacherFund::deleted(function ($fund) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_fund', 'reference_id' => $fund->id]);
     });
     //TeacherGuide
     TeacherGuide::created(function ($guide) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_guide', 'reference_id' => $guide->id]);
     });
     TeacherGuide::updated(function ($guide) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_guide', 'reference_id' => $guide->id]);
     });
     TeacherGuide::deleted(function ($guide) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_guide', 'reference_id' => $guide->id]);
     });
     //TeacherMessage
     TeacherMessage::created(function ($message) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_message', 'reference_id' => $message->id]);
     });
     TeacherMessage::updated(function ($message) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_message', 'reference_id' => $message->id]);
     });
     TeacherMessage::deleted(function ($message) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_message', 'reference_id' => $message->id]);
     });
     //TeacherMessageAttachment
     TeacherMessageAttachment::created(function ($messageattach) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_messageattach', 'reference_id' => $messageattach->id]);
     });
     TeacherMessageAttachment::updated(function ($messageattach) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_messageattach', 'reference_id' => $messageattach->id]);
     });
     TeacherMessageAttachment::deleted(function ($messageattach) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_messageattach', 'reference_id' => $messageattach->id]);
     });
     //TeacherSubject
     TeacherSubject::created(function ($subject) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_subject', 'reference_id' => $subject->id]);
     });
     TeacherSubject::updated(function ($subject) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_subject', 'reference_id' => $subject->id]);
     });
     TeacherSubject::deleted(function ($subject) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Teachers_subject', 'reference_id' => $subject->id]);
     });
 }
 public function guides()
 {
     # code...
     $guides = TeacherGuide::paginate(200);
     return view('teachers::profile.guides.index', compact('guides'));
 }