2019-09-10 12:30:43 +10:00
|
|
|
<?php
|
|
|
|
|
/**
|
2020-09-06 19:38:10 +10:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-09-10 12:30:43 +10:00
|
|
|
*
|
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
|
*
|
2022-04-27 13:20:41 +10:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-09-10 12:30:43 +10:00
|
|
|
*
|
2021-06-16 16:58:16 +10:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-09-10 12:30:43 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use App\Utils\Traits\MakesHash;
|
2019-09-11 15:32:47 +10:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2020-09-06 19:38:10 +10:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2019-09-10 12:30:43 +10:00
|
|
|
|
2019-09-12 11:28:41 +10:00
|
|
|
class GroupSetting extends StaticModel
|
2019-09-10 12:30:43 +10:00
|
|
|
{
|
2019-12-31 08:59:12 +11:00
|
|
|
use MakesHash;
|
2020-02-27 10:32:44 +11:00
|
|
|
use SoftDeletes;
|
2020-09-06 19:38:10 +10:00
|
|
|
|
2020-08-04 18:21:14 +10:00
|
|
|
//public $timestamps = false;
|
2019-09-11 15:32:47 +10:00
|
|
|
|
2019-09-10 12:30:43 +10:00
|
|
|
protected $casts = [
|
2019-09-26 08:27:26 +10:00
|
|
|
'settings' => 'object',
|
|
|
|
|
'updated_at' => 'timestamp',
|
|
|
|
|
'created_at' => 'timestamp',
|
|
|
|
|
'deleted_at' => 'timestamp',
|
2019-09-10 12:30:43 +10:00
|
|
|
];
|
|
|
|
|
|
2019-10-05 08:58:51 +10:00
|
|
|
protected $fillable = [
|
2019-12-31 08:59:12 +11:00
|
|
|
'name',
|
2020-09-06 19:38:10 +10:00
|
|
|
'settings',
|
2019-10-05 10:11:04 +10:00
|
|
|
];
|
2019-10-05 08:58:51 +10:00
|
|
|
|
2021-08-30 15:35:37 +10:00
|
|
|
protected $appends = [
|
|
|
|
|
'hashed_id',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function getHashedIdAttribute()
|
|
|
|
|
{
|
|
|
|
|
return $this->encodePrimaryKey($this->id);
|
|
|
|
|
}
|
2022-06-21 09:57:17 +00:00
|
|
|
|
2020-07-23 13:55:11 +10:00
|
|
|
protected $touches = [];
|
2020-07-16 21:01:39 +10:00
|
|
|
|
2019-12-31 08:59:12 +11:00
|
|
|
public function company()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Company::class);
|
|
|
|
|
}
|
2019-09-10 12:30:43 +10:00
|
|
|
|
2019-12-31 08:59:12 +11:00
|
|
|
public function user()
|
|
|
|
|
{
|
2021-09-08 09:29:20 +10:00
|
|
|
return $this->belongsTo(User::class)->withTrashed();
|
2019-12-31 08:59:12 +11:00
|
|
|
}
|
2019-09-10 12:30:43 +10:00
|
|
|
|
2019-12-31 08:59:12 +11:00
|
|
|
public function clients()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Client::class, 'id', 'group_settings_id');
|
|
|
|
|
}
|
2019-09-11 15:32:47 +10:00
|
|
|
|
2021-01-18 22:06:26 +11:00
|
|
|
public function documents()
|
|
|
|
|
{
|
|
|
|
|
return $this->morphMany(Document::class, 'documentable');
|
|
|
|
|
}
|
2022-06-21 09:57:17 +00:00
|
|
|
|
2019-11-07 09:57:09 +11:00
|
|
|
/**
|
|
|
|
|
* Retrieve the model for a bound value.
|
|
|
|
|
*
|
2020-10-28 21:10:49 +11:00
|
|
|
* @param mixed $value
|
|
|
|
|
* @param null $field
|
|
|
|
|
* @return Model|null
|
2019-11-07 09:57:09 +11:00
|
|
|
*/
|
2020-11-25 15:19:52 +01:00
|
|
|
public function resolveRouteBinding($value, $field = null)
|
2019-11-07 09:57:09 +11:00
|
|
|
{
|
|
|
|
|
return $this
|
|
|
|
|
->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
|
|
|
|
}
|
2019-12-31 08:59:12 +11:00
|
|
|
}
|