Add shop search by title

This commit is contained in:
Amanmyrat 2023-08-11 20:29:02 +05:00
parent 188bbdd82b
commit 0e9fad91cc
6 changed files with 21 additions and 7 deletions

View File

@ -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();
}
}

View File

@ -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"

View File

@ -0,0 +1,11 @@
# ===================================
# Filter Scope Definitions
# ===================================
scopes:
title:
label: Title Search
type: text
modelClass: Tps\Shops\Models\Shop
scope: FilterName

View File

@ -10,3 +10,5 @@ toolbar:
search:
prompt: 'backend::lang.list.search_prompt'
recordUrl: 'tps/shops/shops/update/:id'
filter: config_filter.yaml

View File

@ -1,4 +0,0 @@
title: Shops
modelClass: Tps\Shops\Models\Shop
toolbar:
buttons: reorder_toolbar

View File

@ -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 . '%');
}
}