/** * Register the service provider. * * @return void */ public function register() { //Papersemesterdoc Papersemesterdoc::created(function ($papersemesterdoc) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_papersemesterdoc', 'reference_id' => $papersemesterdoc->id]); }); Papersemesterdoc::updated(function ($papersemesterdoc) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_papersemesterdoc', 'reference_id' => $papersemesterdoc->id]); }); Papersemesterdoc::deleted(function ($papersemesterdoc) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_papersemesterdoc', 'reference_id' => $papersemesterdoc->id]); }); //PaperDoc PaperDoc::created(function ($paperdoc) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paperdoc', 'reference_id' => $paperdoc->id]); }); PaperDoc::updated(function ($paperdoc) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paperdoc', 'reference_id' => $paperdoc->id]); }); PaperDoc::deleted(function ($paperdoc) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paperdoc', 'reference_id' => $paperdoc->id]); }); //PaperFile PaperFile::created(function ($paperfile) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paperfile', 'reference_id' => $paperfile->id]); }); PaperFile::updated(function ($paperfile) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paperfile', 'reference_id' => $paperfile->id]); }); PaperFile::deleted(function ($paperfile) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paperfile', 'reference_id' => $paperfile->id]); }); //Paper Paper::created(function ($paper) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paper', 'reference_id' => $paper->id]); }); Paper::updated(function ($paper) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paper', 'reference_id' => $paper->id]); }); Paper::deleted(function ($paper) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Papers_paper', 'reference_id' => $paper->id]); }); }
/** * Report. * @return Response */ public function report(Request $request) { $paper = Paper::with('docs', 'student')->groupBy('student_id'); if ($request->has('category')) { $paper = $paper->whereHas('docs', function ($query) use($request) { $query->where('category', $request->input('category')); }); } if ($request->has('type')) { $paper = $paper->whereHas('docs', function ($query) use($request) { $query->where('type', $request->input('type')); }); } if ($request->has('hardcopy')) { $paper = $paper->whereHas('docs', function ($query) use($request) { $query->where('is_exist_hardcopy', $request->input('hardcopy')); }); } if ($request->has('softcopy')) { $paper = $paper->whereHas('docs', function ($query) use($request) { $query->where('is_exist_softcopy', $request->input('softcopy')); }); } $papers = $paper->get(); return view('papers::report', compact('papers')); }