find($agentId); $admin = CompanyAdmin::where('user_id', auth()->id()) ->where( 'company_id', $agent->company_id ); if (!$admin->count()) { abort(404); return; } if (!Agent::where('user_id', $agent->user->id)->count()) { $agent->restore(); } return to_route('company.agents.table'); } }