芝麻web文件管理V1.00
编辑当前文件:/home/digitalh/yeahea.digitalhubbd.com/app/Models/Page.php
'datetime', ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'shop_id', 'author_id', 'title', 'slug', 'content', 'published_at', 'position', 'visibility', ]; /** * Get the author for the refund. */ public function author() { return $this->belongsTo(User::class, 'author_id'); } /** * Set the published_at for the model. */ public function setPublishedAtAttribute($value) { $this->attributes['published_at'] = $value ? date('Y-m-d H:i:s', strtotime($value)) : null; // if ($value) $this->attributes['published_at'] = Carbon::createFromFormat('Y-m-d h:i a', $value); } /** * Scope a query to only include published blogs. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopePublished($query) { return $query->whereNotNull('published_at')->where('published_at', '<', Carbon::now()); } /** * Scope a query to only include records that have the given visibility. * * @return \Illuminate\Database\Eloquent\Builder */ public function scopeVisibilityOf($query, $visibility) { return $query->where('visibility', $visibility); } public function viewPosition() { switch ($this->position) { case 'copyright_area': return trans('app.copyright_area'); case 'footer_1st_column': return trans('app.footer_1st_column'); case 'footer_2nd_column': return trans('app.footer_2nd_column'); case 'footer_3rd_column': return trans('app.footer_3rd_column'); case 'main_nav': return trans('app.main_nav'); } } public function visibilityName() { switch ($this->visibility) { case static::VISIBILITY_PUBLIC: return '
' . trans('app.public') . '
'; case static::VISIBILITY_MERCHANT: return '
' . trans('app.merchants') . '
'; } } }