3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-06 00:45:40 +00:00

Attempt to generalize companyable in company scope

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe
2025-07-02 17:12:55 +01:00
parent 699e9f75c9
commit e5e586dc43
6 changed files with 42 additions and 5 deletions

View File

@ -83,6 +83,8 @@ final class CompaniesController extends Controller
public function edit(Company $company) : View | RedirectResponse
{
$this->authorize('update', $company);
Company::isCurrentUserHasAccess($company);
// $company = Company::scopeCompanyables($company, 'id', 'companies');
return view('companies/edit')->with('item', $company);
}
@ -98,6 +100,7 @@ final class CompaniesController extends Controller
{
$this->authorize('update', $company);
$company = Company::scopeCompanyables($company, 'id', 'companies');
$company->name = $request->input('name');
$company->phone = $request->input('phone');
$company->fax = $request->input('fax');
@ -123,11 +126,14 @@ final class CompaniesController extends Controller
*/
public function destroy($companyId) : RedirectResponse
{
if (is_null($company = Company::find($companyId))) {
return redirect()->route('companies.index')
->with('error', trans('admin/companies/message.not_found'));
}
$company = Company::scopeCompanyables($company, 'id', 'companies');
$this->authorize('delete', $company);
if (! $company->isDeletable()) {
return redirect()->route('companies.index')