birzha-legalizasia/app/Models/BrokerApplication.php

81 lines
3.0 KiB
PHP

<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
class BrokerApplication extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'broker_applications';
// protected $primaryKey = 'id';
// public $timestamps = false;
// protected $guarded = ['id'];
protected $fillable = [
'account_id', 'status','state','accepted_by','approved_by', 'ticket_id', 'is_local'
];
// protected $hidden = [];
protected $dates = ['accepted_date','approved_date','created_at','updated_at'];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
public function preview(){
return '<a class="btn btn-sm btn-link" href="'. backpack_url('preview-broker-application/'.$this->id) .'" data-toggle="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
<path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
<path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
</svg>
' . trans('app.last_updates.preview') . '</a>';
}
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function account(){
return $this->belongsTo(Account::class, 'account_id');
}
public function broker_attachments(){
return $this->hasMany(BrokerAttachment::class)
->leftJoin('broker_documents','broker_attachments.broker_document_id','=','broker_documents.id')
->select('broker_attachments.*','order')
->orderBy('broker_documents.order');
}
public function ticket():HasOne{
return $this->hasOne(Ticket::class);
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}