mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
cf1e65f1c0
* Refactor pivot table accessors * Add select2 for client - country selector * Fixes for client contact update * implement ctrans() function across application * Increase custom fields to 4 across the application * Refactor: remove repos calling other repos, implement 4 custom values across application * include querying the custom values in the client list * Fix null custom value labels * Scaffold for client - show view * Working on Client Show
57 lines
1.1 KiB
PHP
57 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Company;
|
|
use App\Utils\Traits\MakesHash;
|
|
use Hashids\Hashids;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Laracasts\Presenter\PresentableTrait;
|
|
|
|
class Client extends BaseModel
|
|
{
|
|
use PresentableTrait;
|
|
use MakesHash;
|
|
use SoftDeletes;
|
|
|
|
protected $presenter = 'App\Models\Presenters\ClientPresenter';
|
|
|
|
//protected $appends = ['client_id'];
|
|
|
|
protected $guarded = [
|
|
'id',
|
|
'updated_at',
|
|
'created_at',
|
|
'deleted_at',
|
|
'contacts',
|
|
'primary_contact',
|
|
'q',
|
|
'company'
|
|
];
|
|
|
|
protected $with = ['contacts', 'primary_contact'];
|
|
|
|
//protected $dates = ['deleted_at'];
|
|
|
|
public function getHashedIdAttribute()
|
|
{
|
|
return $this->encodePrimaryKey($this->id);
|
|
}
|
|
|
|
public function contacts()
|
|
{
|
|
return $this->hasMany(ClientContact::class)->orderBy('is_primary', 'desc');
|
|
}
|
|
|
|
public function primary_contact()
|
|
{
|
|
return $this->hasMany(ClientContact::class)->whereIsPrimary(true);
|
|
}
|
|
|
|
public function company()
|
|
{
|
|
return $this->belongsTo(Company::class);
|
|
}
|
|
|
|
}
|