*/ protected $fillable = [ 'vault_id', 'type', 'name', 'description', 'amount_lent', 'currency_id', 'loaned_at', 'settled_at', 'settled', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'settled' => 'boolean', 'loaned_at' => 'datetime', 'settled_at' => 'datetime', ]; /** * When updating a model, this method determines if we should update the search index. * * @return bool */ public function searchIndexShouldBeUpdated() { return ScoutHelper::isActivated(); } /** * Get the vault associated with the loan. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Vault, $this> */ public function vault(): BelongsTo { return $this->belongsTo(Vault::class); } /** * Get the currency associated with the loan. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Currency, $this> */ public function currency(): BelongsTo { return $this->belongsTo(Currency::class); } /** * Get the contact that did the loan. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\App\Models\Contact, $this> */ public function loaners(): BelongsToMany { return $this->belongsToMany(Contact::class, 'contact_loan', 'loan_id', 'loaner_id'); } /** * Get the contact records the loan was made to. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\App\Models\Contact, $this> */ public function loanees(): BelongsToMany { return $this->belongsToMany(Contact::class, 'contact_loan', 'loan_id', 'loanee_id'); } /** * Get the loan's feed item. * * @return \Illuminate\Database\Eloquent\Relations\MorphOne<\App\Models\ContactFeedItem, $this> */ public function feedItem(): MorphOne { return $this->morphOne(ContactFeedItem::class, 'feedable'); } }