D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
stage
/
app
/
Filename :
Blogs.php
back
Copy
<?php namespace App; use Illuminate\Database\Eloquent\Model; use Laraveldaily\Quickadmin\Observers\UserActionsObserver; use Carbon\Carbon; use Illuminate\Database\Eloquent\SoftDeletes; class Blogs extends Model { use SoftDeletes; /** * The attributes that should be mutated to dates. * * @var array */ protected $dates = ['deleted_at']; protected $table = 'blogs'; protected $fillable = [ 'name', 'small_body', 'body', 'picture', 'putdate', 'showhide', 'url' ]; public static function boot() { parent::boot(); Blogs::observe(new UserActionsObserver); } /** * Set attribute to date format * @param $input */ public function setPutdateAttribute($input) { if($input != '') { $this->attributes['putdate'] = Carbon::createFromFormat(config('quickadmin.date_format'), $input)->format('Y-m-d'); }else{ $this->attributes['putdate'] = ''; } } /** * Get attribute from date format * @param $input * * @return string */ public function getPutdateAttribute($input) { if($input != '0000-00-00') { return Carbon::createFromFormat('Y-m-d', $input)->format(config('quickadmin.date_format')); }else{ return ''; } } }