Add shop search by title
This commit is contained in:
parent
188bbdd82b
commit
0e9fad91cc
|
|
@ -7,11 +7,10 @@ use Tps\Shops\Models\Shop;
|
|||
|
||||
class Shops extends Controller
|
||||
{
|
||||
public $implement = [ 'Backend\Behaviors\ListController', 'Backend\Behaviors\FormController', 'Backend\Behaviors\ReorderController' ];
|
||||
public $implement = ['Backend\Behaviors\ListController','Backend\Behaviors\FormController'];
|
||||
|
||||
public $listConfig = 'config_list.yaml';
|
||||
public $formConfig = 'config_form.yaml';
|
||||
public $reorderConfig = 'config_reorder.yaml';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -24,4 +23,5 @@ class Shops extends Controller
|
|||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<div data-control="toolbar">
|
||||
<a href="<?= Backend::url('tps/shops/shops/create') ?>" class="btn btn-primary oc-icon-plus"><?= e(trans('backend::lang.form.create')) ?></a>
|
||||
<a href="<?= Backend::url('tps/shops/shops/reorder') ?>" class="btn btn-default oc-icon-list"><?= e(trans('backend::lang.reorder.default_title')) ?></a>
|
||||
<button
|
||||
class="btn btn-default oc-icon-trash-o"
|
||||
disabled="disabled"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
# ===================================
|
||||
# Filter Scope Definitions
|
||||
# ===================================
|
||||
|
||||
scopes:
|
||||
title:
|
||||
label: Title Search
|
||||
type: text
|
||||
modelClass: Tps\Shops\Models\Shop
|
||||
scope: FilterName
|
||||
|
||||
|
|
@ -10,3 +10,5 @@ toolbar:
|
|||
search:
|
||||
prompt: 'backend::lang.list.search_prompt'
|
||||
recordUrl: 'tps/shops/shops/update/:id'
|
||||
|
||||
filter: config_filter.yaml
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
title: Shops
|
||||
modelClass: Tps\Shops\Models\Shop
|
||||
toolbar:
|
||||
buttons: reorder_toolbar
|
||||
|
|
@ -52,4 +52,10 @@ class Shop extends Model
|
|||
public function getCategoryFieldAttribute() {
|
||||
return $this->category->name;
|
||||
}
|
||||
|
||||
public function scopeFilterName($query, $name)
|
||||
{
|
||||
return $query->where('name', 'LIKE', '%' . $name . '%');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue