fix: 🐛 admin/store sorting
This commit is contained in:
parent
a0268f1c47
commit
d905171fcb
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Models\ShopProduct;
|
use App\Models\ShopProduct;
|
||||||
|
use App\Traits\DatatablesSortable;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
|
@ -14,6 +15,8 @@ use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class ShopProductController extends Controller
|
class ShopProductController extends Controller
|
||||||
{
|
{
|
||||||
|
use DatatablesSortable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
|
@ -72,17 +75,6 @@ class ShopProductController extends Controller
|
||||||
return redirect()->route('admin.store.index')->with('success', __('Store item has been created!'));
|
return redirect()->route('admin.store.index')->with('success', __('Store item has been created!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the specified resource.
|
|
||||||
*
|
|
||||||
* @param ShopProduct $shopProduct
|
|
||||||
* @return Response
|
|
||||||
*/
|
|
||||||
public function show(ShopProduct $shopProduct)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
|
@ -147,10 +139,14 @@ class ShopProductController extends Controller
|
||||||
return redirect()->back()->with('success', __('Store item has been removed!'));
|
return redirect()->back()->with('success', __('Store item has been removed!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataTable()
|
public function dataTable(Request $request)
|
||||||
{
|
{
|
||||||
$query = ShopProduct::query();
|
$query = ShopProduct::query();
|
||||||
|
|
||||||
|
if ($request->has('order')) {
|
||||||
|
$query = $this->sortByColumn($request->input('order'), $request->input('columns'), $query);
|
||||||
|
}
|
||||||
|
|
||||||
return datatables($query)
|
return datatables($query)
|
||||||
->addColumn('actions', function (ShopProduct $shopProduct) {
|
->addColumn('actions', function (ShopProduct $shopProduct) {
|
||||||
return '
|
return '
|
||||||
|
|
|
@ -102,10 +102,12 @@
|
||||||
data: 'price'
|
data: 'price'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: 'display'
|
data: 'display',
|
||||||
|
sortable: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: 'description'
|
data: 'description',
|
||||||
|
sortable: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: 'created_at'
|
data: 'created_at'
|
||||||
|
@ -121,7 +123,4 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
Loading…
Reference in a new issue