{{-- Lead form (create / edit). Params: $lead, $offers, $branches, $agents, $action, $method. --}} @php $editing = $lead->exists; $canAssign = auth('admin')->user()->can('crm.leads.assign'); // When the phone belongs to another open lead, link to it. $duplicate = $errors->has('phone') && old('phone') ? \App\Models\Crm\Lead::query()->open()->where('phone_normalized', \App\Models\Crm\Lead::normalizePhone(old('phone')))->when($editing, fn ($q) => $q->whereKeyNot($lead->id))->first() : null; @endphp
@csrf @if ($method !== 'POST') @method($method) @endif
@error('name')
{{ $message }}
@enderror
@error('phone')
{{ $message }} @if ($duplicate) {{ trans('crm.form.open_duplicate') }} @endif
@enderror
@error('email')
{{ $message }}
@enderror
@if ($canAssign)
@endif @unless ($editing)
@endunless