user()->cannot('update', $agent->company)) { abort(403, 'Unauthorized action'); } $admin = CompanyAdmin::where('user_id', auth()->id()) ->where( 'company_id', $agent->company_id ); if (!$admin->count()) { abort(404); return; } $agent->delete(); return to_route('company.agents.table'); } }