Created
March 23, 2018 21:46
-
-
Save marufmax/5fdf8e9ae074f22c4b91ee1ed02c4c65 to your computer and use it in GitHub Desktop.
Laravel CRUD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function destroy(Company $company) | |
{ | |
$findCompany = Company::find( $company->i); | |
if ($findCompany->delete()) { | |
return redirect()->route('companies.index')->with('success','Company Deleted Successfully'); | |
} | |
return back()->withInput()->with('error','Delectation Error'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function edit(Company $company) | |
{ | |
$company = Company::find($company->id); | |
return view('companies.edit',['company'=>$company]); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function update(Request $request, Company $company) | |
{ | |
$companyUpdate = Company::where('id', $company->id) | |
->update([ | |
'name' => $request->input('name'), | |
'description' => $request->input('description') | |
]); | |
if ($companyUpdate) { | |
return redirect()->route('companies.show',['company'=>$company->id])->with('success','Company Updated Successfully'); | |
} | |
return back()->withInput(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment