84 lines
2.7 KiB
PHP
84 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* App\Models\CMSInfoHoliday
|
|
*
|
|
* @property int $id
|
|
* @property bool $local
|
|
* @property bool $phone
|
|
* @property string $from
|
|
* @property string $to
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday whereFrom($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday whereLocal($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday wherePhone($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday whereTo($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoHoliday whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class CMSInfoHoliday extends Model
|
|
{
|
|
protected $connection = 'mysql_stern';
|
|
protected $table = 'c_m_s_info_holidays';
|
|
|
|
protected $fillable = [
|
|
'local', 'phone', 'from', 'to'
|
|
];
|
|
|
|
protected $casts = [
|
|
'local' => 'bool',
|
|
'phone' => 'bool',
|
|
];
|
|
|
|
|
|
public function getFromAttribute()
|
|
{
|
|
return isset($this->attributes['from']) ? Carbon::parse($this->attributes['from'])->format('d.m.Y') : '';
|
|
}
|
|
|
|
public function setFromAttribute($value)
|
|
{
|
|
if (!$value) {
|
|
$this->attributes['from'] = null;
|
|
} else {
|
|
$this->attributes['from'] = Carbon::parse($value)->format('Y-m-d'); //(new Carbon($value))->format('Y-m-d');
|
|
|
|
}
|
|
}
|
|
|
|
public function getToAttribute()
|
|
{
|
|
return isset($this->attributes['to']) ? Carbon::parse($this->attributes['to'])->format('d.m.Y') : '';
|
|
}
|
|
|
|
public function setToAttribute($value)
|
|
{
|
|
if (!$value) {
|
|
$this->attributes['to'] = null;
|
|
} else {
|
|
$this->attributes['to'] = Carbon::parse($value)->format('Y-m-d'); //(new Carbon($value))->format('Y-m-d');
|
|
|
|
}
|
|
}
|
|
|
|
/* //local / phone
|
|
//local / phone
|
|
$table->boolean('local')->default(true);
|
|
$table->boolean('phone')->default(true);
|
|
|
|
$table->date('from');
|
|
$table->date('to');
|
|
*/
|
|
|
|
}
|