$documents * @property-read \Illuminate\Database\Eloquent\Collection $tasks * @property-read \Illuminate\Database\Eloquent\Collection $expenses * @property-read \Illuminate\Database\Eloquent\Collection $invoices * @property-read \Illuminate\Database\Eloquent\Collection $quotes * @mixin \Eloquent */ class Project extends BaseModel { use SoftDeletes; use PresentableTrait; use Filterable; use Searchable; /** * Get the index name for the model. * * @return string */ public function searchableAs(): string { return 'projects_v2'; } protected $fillable = [ 'name', 'client_id', 'task_rate', 'private_notes', 'public_notes', 'due_date', 'budgeted_hours', 'custom_value1', 'custom_value2', 'custom_value3', 'custom_value4', 'assigned_user_id', 'color', 'number', ]; protected $with = [ 'documents', ]; protected $touches = []; public function getEntityType() { return self::class; } public function toSearchableArray() { $locale = $this->company->locale(); App::setLocale($locale); return [ 'id' => (string)$this->company->db.":".$this->id, 'name' => ctrans('texts.project') . " " . $this->number . ' | ' . $this->name . " | " . $this->client->present()->name(), 'hashed_id' => $this->hashed_id, 'number' => (string)$this->number, 'is_deleted' => (bool)$this->is_deleted, 'task_rate' => (float) $this->task_rate, 'budgeted_hours' => (float) $this->budgeted_hours, 'due_date' => $this->due_date, 'custom_value1' => (string)$this->custom_value1, 'custom_value2' => (string)$this->custom_value2, 'custom_value3' => (string)$this->custom_value3, 'custom_value4' => (string)$this->custom_value4, 'company_key' => $this->company->company_key, 'private_notes' => (string) $this->private_notes ?: '', 'public_notes' => (string) $this->public_notes ?: '', 'current_hours' => (int) $this->current_hours ?: 0, ]; } public function getScoutKey() { return (string)$this->company->db.":".$this->id; } public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Company::class); } public function client(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Client::class)->withTrashed(); } public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Vendor::class)->withTrashed(); } public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(self::class)->withTrashed(); } public function documents() { return $this->morphMany(Document::class, 'documentable'); } public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class)->withTrashed(); } public function assigned_user(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed(); } public function tasks(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(Task::class); } public function expenses(): HasMany { return $this->hasMany(Expense::class); } public function invoices(): HasMany { return $this->hasMany(Invoice::class)->withTrashed(); } public function quotes(): HasMany { return $this->hasMany(Quote::class); } /** * Service entry points. * * @return ProjectService */ public function service(): ProjectService { return new ProjectService($this); } public function translate_entity() { return ctrans('texts.project'); } }