2022-07-05 12:36:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2022-10-03 21:27:17 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
2022-07-05 12:36:10 +00:00
|
|
|
|
|
|
|
|
class Application extends Model
|
|
|
|
|
{
|
|
|
|
|
use CrudTrait;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| GLOBAL VARIABLES
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
protected $table = 'applications';
|
|
|
|
|
// protected $primaryKey = 'id';
|
|
|
|
|
// public $timestamps = false;
|
2022-08-09 10:12:46 +00:00
|
|
|
// protected $guarded = ['id'];
|
2022-07-05 12:36:10 +00:00
|
|
|
protected $fillable = [
|
2022-11-21 09:28:13 +00:00
|
|
|
'account_id', 'status','state','accepted_by','approved_by'
|
2022-07-05 12:36:10 +00:00
|
|
|
];
|
|
|
|
|
// protected $hidden = [];
|
2022-11-21 09:28:13 +00:00
|
|
|
protected $dates = ['accepted_date','approved_date','created_at','updated_at'];
|
2022-07-05 12:36:10 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| FUNCTIONS
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
2022-09-30 08:58:33 +00:00
|
|
|
public function preview(){
|
2022-11-22 06:07:17 +00:00
|
|
|
return '<a class="btn btn-sm btn-link" href="'. backpack_url('preview-application/'.$this->id) .'" data-toggle="tooltip">
|
2022-09-30 08:58:33 +00:00
|
|
|
<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>
|
2022-11-18 20:20:50 +00:00
|
|
|
' . trans('app.last_updates.preview') . '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-05 12:36:10 +00:00
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| RELATIONS
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
public function account(){
|
|
|
|
|
return $this->belongsTo(Account::class, 'account_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function attachments(){
|
2022-09-29 09:02:54 +00:00
|
|
|
return $this->hasMany(Attachment::class)
|
|
|
|
|
->leftJoin('documents','attachments.document_id','=','documents.id')
|
2022-09-29 09:12:23 +00:00
|
|
|
->select('attachments.*','order')
|
2022-09-29 09:02:54 +00:00
|
|
|
->orderBy('documents.order');
|
2022-07-05 12:36:10 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-03 21:27:17 +00:00
|
|
|
public function ticket():HasOne{
|
|
|
|
|
return $this->hasOne(Ticket::class);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-29 09:24:10 +00:00
|
|
|
|
2022-11-29 09:19:45 +00:00
|
|
|
|
2022-07-05 12:36:10 +00:00
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| SCOPES
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| ACCESSORS
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
2022-11-29 09:25:34 +00:00
|
|
|
|
2022-07-05 12:36:10 +00:00
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| MUTATORS
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
}
|