2018-10-15 07:00:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2018-11-20 05:36:56 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2018-11-02 11:54:46 +01:00
|
|
|
use Hashids\Hashids;
|
2018-10-15 07:00:48 +02:00
|
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
2018-11-27 07:59:16 +01:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2018-10-15 07:00:48 +02:00
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
2018-11-20 05:36:56 +01:00
|
|
|
use Illuminate\Notifications\Notifiable;
|
2018-11-21 09:28:07 +01:00
|
|
|
use Laracasts\Presenter\PresentableTrait;
|
2018-10-15 07:00:48 +02:00
|
|
|
|
|
|
|
|
2018-10-24 12:24:09 +02:00
|
|
|
class ClientContact extends Authenticatable
|
2018-10-15 07:00:48 +02:00
|
|
|
{
|
|
|
|
use Notifiable;
|
2018-11-20 05:36:56 +01:00
|
|
|
use MakesHash;
|
2018-11-21 09:28:07 +01:00
|
|
|
use PresentableTrait;
|
2018-11-27 07:59:16 +01:00
|
|
|
use SoftDeletes;
|
2018-11-21 09:28:07 +01:00
|
|
|
|
|
|
|
// protected $appends = ['contact_id'];
|
2018-10-15 07:00:48 +02:00
|
|
|
|
|
|
|
protected $guard = 'contact';
|
|
|
|
|
2018-11-21 09:28:07 +01:00
|
|
|
protected $presenter = 'App\Models\Presenters\ClientContactPresenter';
|
|
|
|
|
2018-11-27 07:59:16 +01:00
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
2018-11-20 05:36:56 +01:00
|
|
|
protected $guarded = [
|
|
|
|
'id',
|
2018-10-15 07:00:48 +02:00
|
|
|
];
|
2018-12-07 11:57:20 +01:00
|
|
|
|
2018-10-15 07:00:48 +02:00
|
|
|
protected $hidden = [
|
2018-11-21 09:28:07 +01:00
|
|
|
'password',
|
|
|
|
'remember_token',
|
2018-10-15 07:00:48 +02:00
|
|
|
];
|
|
|
|
|
2018-11-20 05:36:56 +01:00
|
|
|
|
|
|
|
public function getRouteKeyName()
|
|
|
|
{
|
|
|
|
return 'contact_id';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getContactIdAttribute()
|
|
|
|
{
|
|
|
|
return $this->encodePrimaryKey($this->id);
|
|
|
|
}
|
2018-10-29 04:16:17 +01:00
|
|
|
|
|
|
|
public function client()
|
|
|
|
{
|
|
|
|
$this->hasOne(Client::class);
|
|
|
|
}
|
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
public function primary_contact()
|
|
|
|
{
|
|
|
|
$this->where('is_primary', true);
|
|
|
|
}
|
|
|
|
|
2018-10-15 07:00:48 +02:00
|
|
|
}
|