search fix
This commit is contained in:
parent
6a6422c130
commit
6f8aee3a55
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use Backpack\CRUD\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Cviebrock\EloquentSluggable\SluggableScopeHelpers;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Page extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use Sluggable;
|
||||
use SluggableScopeHelpers;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'pages';
|
||||
protected $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
// protected $guarded = ['id'];
|
||||
protected $fillable = ['template', 'name', 'title', 'slug', 'content', 'extras'];
|
||||
// protected $hidden = [];
|
||||
// protected $dates = [];
|
||||
protected $fakeColumns = ['extras'];
|
||||
|
||||
/**
|
||||
* Return the sluggable configuration array for this model.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'slug_or_title',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public function getTemplateName()
|
||||
{
|
||||
return str_replace('_', ' ', title_case($this->template));
|
||||
}
|
||||
|
||||
public function getPageLink()
|
||||
{
|
||||
return url($this->slug);
|
||||
}
|
||||
|
||||
public function getOpenButton()
|
||||
{
|
||||
return '<a class="btn btn-default btn-xs" href="'.$this->getPageLink().'" target="_blank">'.
|
||||
'<i class="fa fa-eye"></i> '.trans('backpack::pagemanager.open').'</a>';
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// The slug is created automatically from the "name" field if no slug exists.
|
||||
public function getSlugOrTitleAttribute()
|
||||
{
|
||||
if ($this->slug != '') {
|
||||
return Str::substr($this->slug,0,Str::length($this->slug)-3);
|
||||
// return $this->slug;
|
||||
}
|
||||
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
||||
Loading…
Reference in New Issue