Files
faveo/app/Model/MailJob/QueueService.php
Shift 43386fd86d Apply Laravel coding style
Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions.

You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root.

For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style).
2023-01-03 08:25:25 +00:00

75 lines
1.8 KiB
PHP

<?php
namespace App\Model\MailJob;
use Illuminate\Database\Eloquent\Model;
use Lang;
class QueueService extends Model
{
protected $table = 'queue_services';
protected $fillable = ['name', 'short_name', 'status'];
public function extraFieldRelation()
{
$related = "App\Model\MailJob\FaveoQueue";
return $this->hasMany($related, 'service_id');
}
public function getExtraField($key)
{
$value = '';
$setting = $this->extraFieldRelation()->where('key', $key)->first();
if ($setting) {
$value = $setting->value;
}
return $value;
}
public function getName()
{
$name = $this->attributes['name'];
$id = $this->attributes['id'];
$html = '<a href='.url('queue/'.$id).'>'.$name.'</a>';
return $html;
}
public function getStatus()
{
$status = $this->attributes['status'];
$html = "<span style='color:red'>".Lang::get('lang.inactive').'</span>';
if ($status == 1) {
$html = "<span style='color:green'>".Lang::get('lang.active').'</span>';
}
return $html;
}
public function getAction()
{
$id = $this->attributes['id'];
$status = $this->attributes['status'];
$html = '<a href='.url('queue/'.$id.'/activate')." class='btn btn-primary'>".Lang::get('lang.activate').'</a>';
if ($status == 1) {
$html = "<a href='#' class='btn btn-primary' disabled>".Lang::get('lang.activate').'</a>';
}
return $html;
}
public function isActivate()
{
$check = true;
$settings = $this->extraFieldRelation()->get();
if ($settings->count() == 0) {
$check = false;
}
return $check;
}
}