2019-03-26 05:46:08 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2019-03-26 05:46:08 +01:00
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2020-02-27 00:32:44 +01:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2019-03-26 05:46:08 +01:00
|
|
|
|
2023-03-08 08:33:42 +01:00
|
|
|
/**
|
|
|
|
* App\Models\CompanyToken
|
|
|
|
*
|
|
|
|
* @property int $id
|
|
|
|
* @property int $company_id
|
|
|
|
* @property int $account_id
|
|
|
|
* @property int $user_id
|
|
|
|
* @property string|null $token
|
|
|
|
* @property string|null $name
|
|
|
|
* @property int|null $created_at
|
|
|
|
* @property int|null $updated_at
|
|
|
|
* @property int|null $deleted_at
|
2023-04-26 15:17:49 +02:00
|
|
|
* @property bool $is_deleted
|
|
|
|
* @property bool $is_system
|
2023-03-08 08:33:42 +01:00
|
|
|
* @property-read \App\Models\Account $account
|
|
|
|
* @property-read \App\Models\Company $company
|
|
|
|
* @property-read \App\Models\CompanyUser|null $company_user
|
|
|
|
* @property-read \App\Models\CompanyUser|null $cu
|
|
|
|
* @property-read mixed $hashed_id
|
|
|
|
* @property-read \App\Models\User $user
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|CompanyToken filter(\App\Filters\QueryFilters $filters)
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|CompanyToken newModelQuery()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|CompanyToken newQuery()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|CompanyToken onlyTrashed()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|CompanyToken query()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|CompanyToken withTrashed()
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|CompanyToken withoutTrashed()
|
|
|
|
* @mixin \Eloquent
|
|
|
|
*/
|
2020-04-09 12:48:04 +02:00
|
|
|
class CompanyToken extends BaseModel
|
2019-03-26 05:46:08 +01:00
|
|
|
{
|
2020-02-27 00:32:44 +01:00
|
|
|
use SoftDeletes;
|
2020-04-09 12:48:04 +02:00
|
|
|
use Filterable;
|
2022-03-15 13:28:16 +01:00
|
|
|
use \Awobaz\Compoships\Compoships;
|
2020-04-09 12:48:04 +02:00
|
|
|
|
|
|
|
protected $fillable = [
|
2020-09-06 11:38:10 +02:00
|
|
|
'name',
|
2019-03-26 22:17:28 +01:00
|
|
|
];
|
2019-03-26 05:46:08 +01:00
|
|
|
|
2019-04-25 12:21:07 +02:00
|
|
|
protected $with = [
|
2021-09-08 01:29:20 +02:00
|
|
|
'company',
|
2022-06-21 11:57:17 +02:00
|
|
|
'user',
|
2019-04-25 12:21:07 +02:00
|
|
|
];
|
|
|
|
|
2020-07-23 05:55:11 +02:00
|
|
|
protected $touches = [];
|
2020-07-16 13:01:39 +02:00
|
|
|
|
2020-05-06 13:49:42 +02:00
|
|
|
public function getEntityType()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
return self::class;
|
2020-05-06 13:49:42 +02:00
|
|
|
}
|
|
|
|
|
2023-08-01 14:36:04 +02:00
|
|
|
public function account(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-03-26 05:46:08 +01:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Account::class);
|
|
|
|
}
|
|
|
|
|
2023-08-01 14:36:04 +02:00
|
|
|
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-03-26 05:46:08 +01:00
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
return $this->belongsTo(User::class);
|
2019-03-26 05:46:08 +01:00
|
|
|
}
|
|
|
|
|
2023-08-01 12:30:47 +02:00
|
|
|
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2019-03-26 05:46:08 +01:00
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
return $this->belongsTo(Company::class);
|
2019-03-26 05:46:08 +01:00
|
|
|
}
|
2020-08-08 01:50:32 +02:00
|
|
|
|
2023-08-01 14:36:04 +02:00
|
|
|
public function company_user(): \Illuminate\Database\Eloquent\Relations\HasOne
|
2020-08-08 01:50:32 +02:00
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
return $this->hasOne(CompanyUser::class, 'user_id', 'user_id')
|
2020-08-08 01:50:32 +02:00
|
|
|
->where('company_id', $this->company_id)
|
|
|
|
->where('user_id', $this->user_id);
|
|
|
|
}
|
2022-03-13 09:48:57 +01:00
|
|
|
|
2023-04-26 15:03:32 +02:00
|
|
|
/**
|
|
|
|
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasOne
|
|
|
|
*/
|
2022-03-13 09:48:57 +01:00
|
|
|
public function cu()
|
|
|
|
{
|
2022-03-23 09:54:30 +01:00
|
|
|
return $this->hasOne(CompanyUser::class, 'user_id', 'user_id')
|
|
|
|
->where('company_id', $this->company_id)
|
|
|
|
->where('user_id', $this->user_id);
|
2022-03-13 09:48:57 +01:00
|
|
|
}
|
2019-03-26 05:46:08 +01:00
|
|
|
}
|