反思laravel-admin的使用总结
生活随笔
收集整理的這篇文章主要介紹了
反思laravel-admin的使用总结
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
關聯模型
展示頁面grid函數的關聯:這個是order控制器的函數? 里面的user是使用的order模型的user函數,user函數是order與user表關聯
$grid->column('user.username', __('用戶名'));展示頁面的函數:carBrand是一個關聯函數? 就可以獲取名稱了
$show->field('carBrand.name', __('汽車品牌'));修改數據表集合的操作
//修改分享鏈接$grid->model()->collection(function (Collection $collection) {foreach ($collection as $item) {$item->link = url("/admin/user/{$item->id}");$item->qrcode = url("/admin/user/{$item->id}");}return $collection;});命令行
新建控制器
php artisan admin:make PlusPriceController --model=App\\Models\\PlusPrice操作功能區?
php artisan admin:action User\\Up --grid-row --name="上架"?使用遷移文件進行生成數據表
php artisan migrate進行使用數據表填充的:全部的與一個的
php artisan db:seedphp artisan db:seed --class=UserSeeder按鈕
首頁的按鈕
$grid->disableCreateButton(); $grid->disableExport(); $grid->disableRowSelector(); $grid->disableColumnSelector();?編輯的按鈕
$form->footer(function ($footer) {// 去掉`重置`按鈕$footer->disableReset();// 去掉`查看`checkbox$footer->disableViewCheck();// 去掉`繼續編輯`checkbox$footer->disableEditingCheck();// 去掉`繼續創建`checkbox$footer->disableCreatingCheck();});?展示的按鈕
$show->panel()->tools(function ($tools) {$tools->disableEdit();$tools->disableList();$tools->disableDelete();});;篩選區:or查詢? 連表查詢
$grid->filter(function ($filter) {$filter->disableIdFilter();$filter->column(1 / 2, function () {});$filter->where(function ($query) {$query->where('order_code', 'like', "%{$this->input}%")->orWhere('VIN', 'like', "%{$this->input}%");}, '訂單編號/VIN');$filter->where(function ($query) {$query->whereHas('user', function ($query) {$query->where('user_id', 'like', "%{$this->input}%")->orWhere('username', 'like', "%{$this->input}%");});}, '用戶ID或者名字');});?
總結
以上是生活随笔為你收集整理的反思laravel-admin的使用总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 租车时购买了尊享服务可以免除那些车损
- 下一篇: 反思赚钱:一定要动脑子 一定找发财点