repository = $activity_log; parent::__construct(); } /** * Display a list of activity_log. * * @return Response */ public function index(ActivityLogRequest $request) { if ($request->wantsJson()) { return $this->getJson($request); } $this ->theme->prependTitle(trans('bgtest::activity_log.names').' :: '); return $this->theme->of('bgtest::admin.activity_log.index')->render(); } /** * Display a list of activity_log. * * @return Response */ public function getJson(ActivityLogRequest $request) { $pageLimit = $request->input('pageLimit'); $activity_logs = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->setPresenter('\\Bgtest\\Bgtest\\Repositories\\Presenter\\ActivityLogListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate($pageLimit); $activity_logs['recordsTotal'] = $activity_logs['meta']['pagination']['total']; $activity_logs['recordsFiltered'] = $activity_logs['meta']['pagination']['total']; $activity_logs['request'] = $request->all(); return response()->json($activity_logs, 200); } /** * Display activity_log. * * @param Request $request * @param Model $activity_log * * @return Response */ public function show(ActivityLogRequest $request, ActivityLog $activity_log) { if (!$activity_log->exists) { return response()->view('bgtest::admin.activity_log.new', compact('activity_log')); } Form::populate($activity_log); return response()->view('bgtest::admin.activity_log.show', compact('activity_log')); } /** * Show the form for creating a new activity_log. * * @param Request $request * * @return Response */ public function create(ActivityLogRequest $request) { $activity_log = $this->repository->newInstance([]); Form::populate($activity_log); return response()->view('bgtest::admin.activity_log.create', compact('activity_log')); } /** * Create new activity_log. * * @param Request $request * * @return Response */ public function store(ActivityLogRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $activity_log = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('bgtest::activity_log.name')]), 'code' => 204, 'redirect' => trans_url('/admin/bgtest/activity_log/'.$activity_log->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show activity_log for editing. * * @param Request $request * @param Model $activity_log * * @return Response */ public function edit(ActivityLogRequest $request, ActivityLog $activity_log) { Form::populate($activity_log); return response()->view('bgtest::admin.activity_log.edit', compact('activity_log')); } /** * Update the activity_log. * * @param Request $request * @param Model $activity_log * * @return Response */ public function update(ActivityLogRequest $request, ActivityLog $activity_log) { try { $attributes = $request->all(); $activity_log->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('bgtest::activity_log.name')]), 'code' => 204, 'redirect' => trans_url('/admin/bgtest/activity_log/'.$activity_log->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/bgtest/activity_log/'.$activity_log->getRouteKey()), ], 400); } } /** * Remove the activity_log. * * @param Model $activity_log * * @return Response */ public function destroy(ActivityLogRequest $request, ActivityLog $activity_log) { try { $t = $activity_log->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('bgtest::activity_log.name')]), 'code' => 202, 'redirect' => trans_url('/admin/bgtest/activity_log/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/bgtest/activity_log/'.$activity_log->getRouteKey()), ], 400); } } }