/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $lead_id = $this->route('leads'); $lead = Lead::findOrFail($lead_id); return $lead->first()->campaign()->with('users')->whereHas('users', function ($q) { $q->where('user_id', Auth::id())->where('role_id', config('roles.admin')); })->exists(); }
/** * Determine if the user is authorized to make this request. * * @param Request $request * @return bool */ public function authorize() { $lead_id = $this->route('leads'); $lead = Lead::findOrFail($lead_id); if (!is_null($lead)) { return $lead->first()->campaign()->users->contains(Auth::id()); } return false; }
/** * Melihat satu record Lead. * * @param $id Lead ID * @return View */ public function show($id) { $lead = Lead::findOrFail($id); if (Gate::denies('access-lead', $lead)) { abort(404); } $gcf = Gcf::find($lead->gcf_id); $lead = Lead::addCustomFields($lead); return view('lead.form', ['playList' => PlayRepository::collection($this->workingAreaId), 'lead' => $lead, 'gcf' => $gcf, 'url' => null, 'method' => 'get']); }
/** * Determine if the user is authorized to make this request. * * @param Request $request * @return bool */ public function authorize() { $lead_id = $this->route('leads'); $lead = Lead::findOrFail($lead_id); // Check if user is admin on campaign $is_admin_for_campaign = $lead->campaign()->with('users')->whereHas('users', function ($q) { $q->where('user_id', Auth::id())->where('role_id', config('roles.admin')); })->exists(); // Check if user is owner of lead $is_owner_of_lead = $lead->users()->wherePivot('type', 'owner')->where('user_id', Auth::id())->exists(); if ($is_admin_for_campaign || $is_owner_of_lead) { return true; } return false; }
/** * Show the form to remove the specific resource from storage * * @param AdminShowRequest $request * @param Integer $id * @return Response */ public function getDestroyLead(AdminShowRequest $request, $id) { $lead = Lead::findOrFail($id); return view('leads.destroy')->with('user', $this->user)->with('lead', $lead); }
public function getDelete($id) { $lead = Lead::findOrFail($id); return view('admin.leads.delete', compact('lead')); }