1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Models/GroupSetting.php

81 lines
1.7 KiB
PHP
Raw Normal View History

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