|
@@ -35,15 +35,19 @@ class CompanyController extends Controller
|
|
|
|
|
|
public function store(CreateOrUpdateRequest $request)
|
|
|
{
|
|
|
- $company=new Company();
|
|
|
+ if(Auth::user()->super_admin){
|
|
|
+ $company=new Company();
|
|
|
|
|
|
- $company->fill([
|
|
|
+ $company->fill([
|
|
|
...$request->all(),
|
|
|
]);
|
|
|
|
|
|
$company->save();
|
|
|
-
|
|
|
return $this->created();
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->forbidden("Operation without permission");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function show(string $id)
|
|
@@ -54,16 +58,26 @@ class CompanyController extends Controller
|
|
|
}
|
|
|
|
|
|
public function update(CreateOrUpdateRequest $request,string $id){
|
|
|
- $company=Company::findOrFail($id);
|
|
|
- $company->fill($request->all());
|
|
|
- $company->save();
|
|
|
- return $this->noContent();
|
|
|
+ if(Auth::user()->super_admin) {
|
|
|
+ $company = Company::findOrFail($id);
|
|
|
+ $company->fill($request->all());
|
|
|
+ $company->save();
|
|
|
+ return $this->noContent();
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->forbidden("Operation without permission");
|
|
|
}
|
|
|
|
|
|
|
|
|
public function destroy(string $id)
|
|
|
{
|
|
|
+ if(Auth::user()->super_admin) {
|
|
|
+ $company = Company::findOrFail($id);
|
|
|
+ $company->delete();
|
|
|
|
|
|
+ return $this->noContent();
|
|
|
+ }
|
|
|
+ return $this->forbidden("Operation without permission");
|
|
|
}
|
|
|
|
|
|
|