Laravel-admin 用法

莫名私下裡發表於2019-12-26

各大映象連結


1. composer-laravel-映象 
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/  

2.  加法 add()、
    減法 subtract()、
    乘法 multiply()、
    除法 divide()

3.  php artisan ide-helper:models
    php artisan ide-helper:generate

4.   //只讀
   $form->text('from_address', '支付地址')->readonly();
    //show的使用 透過 as 可以使用模型關聯呼叫資料
    $show->user_id('使用者名稱')->as(function () {
            return $this->user->name;
        });

    //禁用行操作列
    $grid->disableActions();
    //禁用分頁條
    $grid->disablePagination();
    //禁用建立按鈕
    $grid->disableCreateButton();
    //禁用查詢過濾器
    $grid->disableFilter();
    //禁用行選擇checkbox
    $grid->disableRowSelector();
    //禁用
    $grid->disableTools();
    //禁用匯出
    $grid->disableExport();
    //設定分頁選擇器選項
    $grid->perPages([10, 20, 30, 40, 50]);

    $grid->actions(function (Grid\Displayers\Actions        $actions) {
        $actions->disableView();
        $actions->disableEdit();
        $actions->disableDelete();
    });

5.     js swal 使用
$script = <<<SCRIPT
        $('button[type=submit]').on('click',function(e){
            event.preventDefault();
            swal({
                title: '請妥善儲存好助記詞!',
                text: '遺失後不能恢復!',
                type: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: '確認提交',
                cancelButtonText: "取消",
            }).then(function (isConfirm) {
                if (isConfirm.value == true ){
                     $("form").submit();
                }else{
                    event.preventDefault();
                    return false;
                }
            }).catch(swal.noop);
        });
SCRIPT;
                Admin::script($script);
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章