芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Models/Lead.php
$products * @property-read int|null $products_count * @property-read int|null $follow_up_date_next * @property-read int|null $follow_up_date_past * @mixin \Eloquent */ class Lead extends BaseModel { use Notifiable, HasFactory; use CustomFieldsTrait; use HasCompany; protected $table = 'leads'; const CUSTOM_FIELD_MODEL = 'App\Models\Lead'; protected $appends = ['image_url']; protected $casts = [ 'salutation' => Salutation::class, ]; public function getImageUrlAttribute() { $gravatarHash = md5(strtolower(trim($this->client_email))); return 'https://www.gravatar.com/avatar/' . $gravatarHash . '.png?s=200&d=mp'; } /** * Route notifications for the mail channel. * * @param \Illuminate\Notifications\Notification $notification * @return string */ // phpcs:ignore public function routeNotificationForMail($notification) { return $this->client_email; } public function leadAgent(): BelongsTo { return $this->belongsTo(LeadAgent::class, 'agent_id'); } public function note(): BelongsTo { return $this->belongsTo(LeadNote::class, 'lead_id'); } public function leadSource(): BelongsTo { return $this->belongsTo(LeadSource::class, 'source_id'); } public function category(): BelongsTo { return $this->belongsTo(LeadCategory::class, 'category_id'); } public function leadStatus(): BelongsTo { return $this->belongsTo(LeadStatus::class, 'status_id'); } public function client(): BelongsTo { return $this->belongsTo(User::class, 'client_id'); } public function currency(): BelongsTo { return $this->belongsTo(Currency::class, 'currency_id'); } public function products(): BelongsToMany { return $this->belongsToMany(Product::class, 'lead_products')->using(LeadProduct::class); } public function follow() { if (user()) { $viewLeadFollowUpPermission = user()->permission('view_lead_follow_up'); if ($viewLeadFollowUpPermission == 'all') { return $this->hasMany(LeadFollowUp::class); } elseif ($viewLeadFollowUpPermission == 'added') { return $this->hasMany(LeadFollowUp::class)->where('added_by', user()->id); } else { return null; } } return $this->hasMany(LeadFollowUp::class); } public function followup(): HasOne { return $this->hasOne(LeadFollowUp::class, 'lead_id')->orderBy('created_at', 'desc'); } public function files(): HasMany { return $this->hasMany(LeadFiles::class)->orderBy('created_at', 'desc'); } public static function allLeads() { $viewLeadPermission = user()->permission('view_lead'); $leads = Lead::select('*') ->orderBy('client_name', 'asc'); if (!isRunningInConsoleOrSeeding()) { if ($viewLeadPermission == 'added') { $leads->where('added_by', user()->id); } } return $leads->get(); } public function addedBy() { $addedBy = User::findOrFail($this->added_by); return $addedBy ?: null; } }