78 lines
1.8 KiB
PHP
78 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\Traits\Vihar\Attributes;
|
||
|
|
|
||
|
|
use Carbon\Carbon;
|
||
|
|
use App\Constant\Constant;
|
||
|
|
use App\Models\Vihar;
|
||
|
|
use App\Traits\ActionButtons;
|
||
|
|
|
||
|
|
trait ViharAttributes
|
||
|
|
{
|
||
|
|
use ActionButtons;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getStartTimeAttribute($value): string
|
||
|
|
{
|
||
|
|
return defaulTimeFormat24($value) ?? '-';
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getEndTimeAttribute($value): string
|
||
|
|
{
|
||
|
|
return defaulTimeFormat24($value) ?? '-';
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getViharEditActionAttribute(): string
|
||
|
|
{
|
||
|
|
return $this->editButton(route('admin.sant.vihar.edit', [$this->sant->id, $this->id]), 'Edit Vihar');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getViharCheckboxActionAttribute(): string
|
||
|
|
{
|
||
|
|
return $this->checkboxAction($this);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function getViharActionButtonsAttribute(): string
|
||
|
|
{
|
||
|
|
$action = $this->vihar_vihar_list_action;
|
||
|
|
$action .= $this->vihar_edit_action;
|
||
|
|
// $action =$action.$this->vihar_view_action;
|
||
|
|
// if (loggedInUser()->isSuperAdmin() || loggedInUser()->isAdmin()) {
|
||
|
|
// $action =$action.$this->vihar_delete_action;
|
||
|
|
// }
|
||
|
|
return $action;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get vihar live status
|
||
|
|
* @return int
|
||
|
|
*/
|
||
|
|
public function getLiveViharAttribute(): int
|
||
|
|
{
|
||
|
|
$live = Vihar::where('start_date', '=', Carbon::now()->toDateString())
|
||
|
|
->where('start_time', '<=', Carbon::now()->toTimeString())
|
||
|
|
->where('sant_id', $this->sant_id)
|
||
|
|
->find($this->id);
|
||
|
|
|
||
|
|
if ($live) {
|
||
|
|
return Constant::STATUS_ONE;
|
||
|
|
} else {
|
||
|
|
return Constant::STATUS_ZERO;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|