62 lines
2.3 KiB
PHP
62 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* App\Models\CMSInfoAvailable
|
|
*
|
|
* @property int $id
|
|
* @property string $type
|
|
* @property bool $active
|
|
* @property string|null $from
|
|
* @property string|null $to
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereActive($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereFrom($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereTo($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereType($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
* @property int $wday
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSInfoAvailable whereWday($value)
|
|
*/
|
|
class CMSInfoAvailable extends Model
|
|
{
|
|
protected $connection = 'mysql_stern';
|
|
protected $table = 'c_m_s_info_availables';
|
|
|
|
protected $fillable = [
|
|
'type', 'wday', 'active', 'from', 'to'
|
|
];
|
|
|
|
protected $casts = [
|
|
'active' => 'bool',
|
|
];
|
|
|
|
|
|
public static function getContentBySlug($type, $wday){
|
|
return CMSInfoAvailable::whereType($type)->whereWday($wday)->first();
|
|
}
|
|
|
|
public static function setContentBySlug($type, $wday, $values){
|
|
|
|
$content = CMSInfoAvailable::whereType($type)->whereWday($wday)->first();
|
|
if(!$content) {
|
|
$content = CMSInfoAvailable::create([
|
|
'type' => $type,
|
|
'wday' => $wday,
|
|
]);
|
|
}
|
|
$content->fill($values);
|
|
$content->save();
|
|
return $content;
|
|
}
|
|
}
|