mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Laracasts\Presenter\PresentableTrait;
|
|
use Hashids\Hashids;
|
|
use App\Utils\Traits\MakesHash;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Client extends BaseModel
|
|
{
|
|
use PresentableTrait;
|
|
use MakesHash;
|
|
use SoftDeletes;
|
|
|
|
protected $presenter = 'App\Models\Presenters\ClientPresenter';
|
|
|
|
protected $appends = ['client_id'];
|
|
|
|
protected $guarded = [
|
|
'id'
|
|
];
|
|
|
|
public function getRouteKeyName()
|
|
{
|
|
return 'client_id';
|
|
}
|
|
|
|
public function getClientIdAttribute()
|
|
{
|
|
return $this->encodePrimaryKey($this->id);
|
|
}
|
|
|
|
public function contacts()
|
|
{
|
|
return $this->hasMany(ClientContact::class);
|
|
}
|
|
|
|
public function locations()
|
|
{
|
|
return $this->hasMany(ClientLocation::class);
|
|
}
|
|
|
|
public function primary_billing_location()
|
|
{
|
|
return $this->hasOne(ClientLocation::class)->whereIsPrimaryBilling(true);
|
|
}
|
|
|
|
public function primary_shipping_location()
|
|
{
|
|
return $this->hasOne(ClientLocation::class)->whereIsPrimaryShipping(true);
|
|
}
|
|
|
|
public function primary_contact()
|
|
{
|
|
return $this->hasMany(ClientContact::class)->whereIsPrimary(true);
|
|
}
|
|
|
|
}
|