osb/app/Models/Account.php

48 lines
888 B
PHP
Raw Normal View History

2018-07-06 06:57:49 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Account extends Model
{
protected $table = 'ab_account';
2018-07-13 04:53:44 +00:00
public $timestamps = FALSE;
2018-07-17 04:10:40 +00:00
protected $appends = [
'active_display',
];
protected $visible = [
'id',
'company',
'active_display',
];
2018-07-13 04:53:44 +00:00
/**
* Return the country the user belongs to
*/
public function country()
{
return $this->belongsTo(Country::class);
}
public function language()
{
return $this->belongsTo(Language::class);
}
public function user()
{
return $this->belongsTo(\App\User::class);
}
2018-07-17 04:10:40 +00:00
public function getCompanyAttribute($value)
{
return $value ? $value : $this->user->SurFirstName;
}
public function getActiveDisplayAttribute($value)
{
return sprintf('<span class="btn-sm btn-block btn-%s text-center">%s</span>',$this->active ? 'primary' : 'danger',$this->active ? 'Active' : 'Inactive');
}
2018-07-06 06:57:49 +00:00
}