2018-10-15 07:00:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
use Laracasts\Presenter\PresentableTrait;
|
2018-11-10 14:24:36 +01:00
|
|
|
use Hashids\Hashids;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
2018-11-12 08:52:20 +01:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2018-10-15 07:00:48 +02:00
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
class Client extends BaseModel
|
2018-10-15 07:00:48 +02:00
|
|
|
{
|
2018-11-02 11:54:46 +01:00
|
|
|
use PresentableTrait;
|
2018-11-10 14:24:36 +01:00
|
|
|
use MakesHash;
|
2018-11-12 08:52:20 +01:00
|
|
|
use SoftDeletes;
|
2018-11-02 11:54:46 +01:00
|
|
|
|
|
|
|
protected $presenter = 'App\Models\Presenters\ClientPresenter';
|
|
|
|
|
2018-11-20 05:36:56 +01:00
|
|
|
//protected $appends = ['client_id'];
|
2018-11-10 14:24:36 +01:00
|
|
|
|
2018-11-12 08:52:20 +01:00
|
|
|
protected $guarded = [
|
|
|
|
'id'
|
2018-11-10 14:24:36 +01:00
|
|
|
];
|
|
|
|
|
2018-11-12 08:52:20 +01:00
|
|
|
public function getRouteKeyName()
|
|
|
|
{
|
|
|
|
return 'client_id';
|
|
|
|
}
|
|
|
|
|
2018-11-21 09:28:07 +01:00
|
|
|
public function getHashedIdAttribute()
|
2018-11-10 14:24:36 +01:00
|
|
|
{
|
|
|
|
return $this->encodePrimaryKey($this->id);
|
|
|
|
}
|
2018-10-29 04:16:17 +01:00
|
|
|
|
|
|
|
public function contacts()
|
|
|
|
{
|
|
|
|
return $this->hasMany(ClientContact::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function primary_contact()
|
|
|
|
{
|
|
|
|
return $this->hasMany(ClientContact::class)->whereIsPrimary(true);
|
|
|
|
}
|
|
|
|
|
2018-10-15 07:00:48 +02:00
|
|
|
}
|