/** * Register the service provider. * * @return void */ public function register() { //SupportprogramsApplication SupportprogramsApplication::created(function ($supportprogram) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'SupportprogramsApplication_supportprogram', 'reference_id' => $supportprogram->id]); }); SupportprogramsApplication::updated(function ($supportprogram) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'SupportprogramsApplication_supportprogram', 'reference_id' => $supportprogram->id]); }); SupportprogramsApplication::deleted(function ($supportprogram) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'SupportprogramsApplication_supportprogram', 'reference_id' => $supportprogram->id]); }); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); Permission::where('module', 'supportprograms')->delete(); // $this->call("OthersTableSeeder"); $permissions = [['name' => 'اضافة برنامج', 'slug' => 'create.supportprograms', 'module' => 'supportprograms'], ['name' => 'عرض البرامج', 'slug' => 'index.supportprograms', 'module' => 'supportprograms'], ['name' => 'تعديل برنامج', 'slug' => 'edit.supportprograms', 'module' => 'supportprograms'], ['name' => 'عرض برنامج', 'slug' => 'show.supportprograms', 'module' => 'supportprograms'], ['name' => 'حذف برنامج', 'slug' => 'delete.supportprograms', 'module' => 'supportprograms']]; $programs = [['name' => 'اي شيء', 'comment' => 'رابط اي شيء', 'program_link' => 'http://google.com', 'guide_link' => 'http://google.com'], ['name' => 'اي شيء 2', 'comment' => 'رابط اي شيء 2', 'program_link' => 'http://google.com', 'guide_link' => 'http://google.com']]; $users = User::all(); foreach ($permissions as $permission) { $perm = Permission::create($permission); foreach ($users as $user) { $user->attachPermission($perm); } } foreach ($programs as $program) { Program::create($program); } }
/** * Display a listing of the resource. * @return Response */ public function index() { $softwares = SupportprogramsApplication::all(); return response()->json($softwares, 200, [], JSON_NUMERIC_CHECK); }
/** * delete all selected programs at once * @param SupportprogramsApplication $SubProgModel Supportprograms model * @param Request $req CreateUserRequest $request we validate the data sent from the form in this class before we continue our logic * @return return to the program index view index.blade.php */ public function deletebulk(SupportprogramsApplication $SubProgModel, Request $req) { // if the table_records is empty we redirect to the support programs index if (!$req->has('table_records')) { return redirect()->route('supportprograms.index'); } // we delete all the programs with the ids $ids $SubProgModel->destroy($req->input('table_records')); // we redirect to the support programs index view with a success message return redirect()->route('supportprograms.index')->with('success', trans('supportprograms::programs.delete_bulk_success')); }