Company::with(['region.group'])->paginate(), 'regions' => Region::with(['group'])->get(), ]); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $request->validate([ 'name' => 'required|string|max:255', 'short' => 'required|string|max:255', 'region_id' => 'required|exists:regions,id' ]); Company::create([ 'region_id' => $request->region_id, 'name' => $request->name, 'short' => $request->short ]); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Company $company * @return \Illuminate\Http\Response */ public function update(Request $request, Company $company) { $request->validate([ 'name' => 'required|string|max:255', 'short' => 'required|string|max:255', 'region_id' => 'required|exists:regions,id' ]); $company->update([ 'region_id' => $request->region_id, 'name' => $request->name, 'short' => $request->short ]); } /** * Remove the specified resource from storage. * * @param \App\Models\Company $company * @return \Illuminate\Http\Response */ public function destroy(Company $company) { $company->delete(); } }