middleware('auth'); parent::__construct(); } /** * Returns a view that invokes the ajax tables which actually contains * the content for the assets listing, which is generated in getDatatable. * * @author [A. Gianotto] [] * @see AssetController::getDatatable() method that generates the JSON response * @since [v1.0] * @return View */ public function index(Request $request) { $this->authorize('index', Department::class); if ($request->has('company_id')) { $company = Company::find($request->input('company_id')); } else { $company = null; } return view('departments/index')->with('company',$company); } /** * Store a newly created resource in storage. * * @author [A. Gianotto] [] * @since [v4.0] * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->authorize('create', Department::class); $department = new Department; $department->fill($request->all()); if ($department->save()) { return response()->json(Helper::formatStandardApiResponse('success', $department, trans('admin/department/message.create.success'))); } return response()->json(Helper::formatStandardApiResponse('error', null, $department->getErrors())); } }