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
|
|
|
|
|
*
|
2020-01-07 11:13:47 +11:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-09-10 12:30:43 +10:00
|
|
|
*
|
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
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
|
|
|
|
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
|
|
|
}
|