2019-09-08 12:39:13 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-09-08 12:39:13 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-09-08 12:39:13 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2020-03-23 18:10:42 +01:00
|
|
|
use App\Utils\Traits\MakesDates;
|
2020-10-28 11:10:49 +01:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2019-09-08 12:39:13 +02:00
|
|
|
|
|
|
|
class ClientGatewayToken extends BaseModel
|
|
|
|
{
|
2020-03-23 18:10:42 +01:00
|
|
|
use MakesDates;
|
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
protected $casts = [
|
|
|
|
'meta' => 'object',
|
2019-09-26 00:27:26 +02:00
|
|
|
'updated_at' => 'timestamp',
|
|
|
|
'created_at' => 'timestamp',
|
|
|
|
'deleted_at' => 'timestamp',
|
2019-12-30 22:59:12 +01:00
|
|
|
];
|
2019-09-18 04:39:53 +02:00
|
|
|
|
2020-06-16 14:41:56 +02:00
|
|
|
protected $appends = [
|
|
|
|
'hashed_id',
|
|
|
|
];
|
2020-09-06 11:38:10 +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
|
|
|
}
|
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public function client()
|
|
|
|
{
|
|
|
|
return $this->hasOne(Client::class)->withTrashed();
|
|
|
|
}
|
2019-09-08 12:39:13 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public function gateway()
|
|
|
|
{
|
2020-07-08 04:20:44 +02:00
|
|
|
return $this->hasOne(CompanyGateway::class, 'id', 'company_gateway_id');
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-09-08 12:39:13 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public function gateway_type()
|
|
|
|
{
|
|
|
|
return $this->hasOne(GatewayType::class, 'id', 'gateway_type_id');
|
|
|
|
}
|
2019-09-18 04:39:53 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public function company()
|
|
|
|
{
|
|
|
|
return $this->hasOne(Company::class);
|
|
|
|
}
|
2019-09-08 12:39:13 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->hasOne(User::class)->withTrashed();
|
|
|
|
}
|
2020-03-23 18:10:42 +01:00
|
|
|
|
2019-11-28 11:35:13 +01:00
|
|
|
/**
|
|
|
|
* Retrieve the model for a bound value.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param mixed $value
|
|
|
|
* @param null $field
|
|
|
|
* @return Model|null
|
2019-11-28 11:35:13 +01:00
|
|
|
*/
|
2020-11-25 15:19:52 +01:00
|
|
|
public function resolveRouteBinding($value, $field = null)
|
2019-11-28 11:35:13 +01:00
|
|
|
{
|
|
|
|
return $this
|
|
|
|
->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
|
|
|
}
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|