encore/laravel-admin

http://laravel.com/

http://kejyun.github.io/Laravel-4-Docum ... roduction/
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

encore/laravel-admin

文章 yehlu »

https://github.com/z-song/laravel-admin

代碼: 選擇全部

Laravel 5.2
composer require encore/laravel-admin "dev-master"

Laravel 5.3
composer require encore/laravel-admin "1.3.x-dev"

Laravel 5.1
composer require encore/laravel-admin "1.1.x-dev"
config/app.php

代碼: 選擇全部

//Providers
Encore\Admin\Providers\AdminServiceProvider::class

代碼: 選擇全部

php artisan vendor:publish --tag=laravel-admin
Copied File [/vendor/encore/laravel-admin/config/admin.php] To [/config/admin.php]
Copied Directory [/vendor/encore/laravel-admin/assets] To [/public/packages/admin]
Publishing complete for tag [laravel-admin]!

代碼: 選擇全部

php artisan admin:install
Migrated: 2016_01_04_173148_create_admin_tables
Admin directory was created: /app/Admin
HomeController file was created: /app/Admin/Controllers/HomeController.php
ExampleController file was created: /app/Admin/Controllers/ExampleController.php
Bootstrap file was created: /app/Admin/bootstrap.php
Routes file was created: /app/Admin/routes.php

代碼: 選擇全部

php artisan admin:make LicenceController --model=App\\Models\\Licence
app/Admin/routes.php

代碼: 選擇全部

$router->resource('licences', LicenceController::class);
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: encore/laravel-admin

文章 yehlu »

繁體語系檔

vendor/encore/laravel-admin/lang/zh_TW/lang.php

代碼: 選擇全部

<?php

return [
    'online' => '在線',
    'login' => '登陸',
    'logout' => '登出',
    'name' => '名稱',
    'username' => '用戶名',
    'password' => '密碼',
    'remember_me' => '記住我',

    'list' => '列表',
    'new' => '新增',
    'create' => '創建',
    'delete' => '刪除',
    'edit' => '編輯',
    'view' => '查看',
    'reset' => '撤銷',
    'export' => '導出',
    'batch_delete' => '批量刪除',
    'save' => '保存',
    'refresh' => '刷新',
    'order' => '排序',
    'expand' => '展開',
    'collapse' => '收起',
    'filter' => '過濾器',
    'close' => '關閉',

    'action' => '操作',
    'title' => '標題',
    'description' => '簡介',
    'back_to_list' => '返回列表',
    'submit' => '提交',
    'menu' => '菜單',
    'input' => '輸入',
    'succeeded' => '成功',
    'failed' => '失敗',
    'delete_confirm' => '確認刪除?',
    'delete_succeeded' => '刪除成功 !',
    'delete_failed' => '刪除失敗 !',

    'choose' => '選擇',
    'choose_file' => '選擇文件',
    'choose_image' => '選擇圖片',

    'more' => '更多',
    'deny' => '無權訪問',

    'administrator' => '管理員',
    'roles' => '角色',
    'permissions' => '權限',
    'slug' => '標識',

    'created_at' => '創建時間',
    'updated_at' => '更新時間',

    'alert' => '注意',

    'parent_id' => '父ID',
    'icon' => '圖標',
    'uri' => '路徑',

    'operation_log' => '操作日誌',
];

yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

可以在后台登录处加入验证码

文章 yehlu »

https://github.com/z-song/laravel-admin/issues/129

https://github.com/greggilbert/recaptcha

in AuthController.php

代碼: 選擇全部

public function postLogin(Request $request)
    {
        $credentials = $request->only(['username', 'password', 'g-recaptcha-response']);

        $validator = Validator::make($credentials, [
            'username' => 'required',
            'password' => 'required',
            'g-recaptcha-response' => 'required|recaptcha',
        ]);
        unset($credentials['g-recaptcha-response']);
        if ($validator->fails()) {
            return Redirect::back()->withInput()->withErrors($validator);
        }

        if (Auth::guard('admin')->attempt($credentials)) {
            return Redirect::intended(config('admin.prefix'));
        }

        return Redirect::back()->withInput()->withErrors(['username' => $this->getFailedLoginMessage()]);
    }
Login.blade.php

代碼: 選擇全部

form>
...
      <div class="form-group has-feedback {!! !$errors->has('g-recaptcha-response') ?: 'has-error' !!}">

        @if($errors->has('g-recaptcha-response'))
          @foreach($errors->get('g-recaptcha-response') as $message)
            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i>{{$message}}</label></br>
          @endforeach
        @endif

        {!! Recaptcha::render() !!}
      </div>
...
</form>
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: encore/laravel-admin

文章 yehlu »

代碼: 選擇全部

Oops! Something went wrong.
 

In `Macroable.php` line `52` : Method format does not exist.

代碼: 選擇全部

            $grid->column('date_start', '起始日期')->sortable()->format('YYYY-MM-DD');
 不能下 format 的參數        
            $grid->column('date_start', '起始日期')->sortable();
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: encore/laravel-admin

文章 yehlu »

代碼: 選擇全部

 InvalidArgumentException In FilesystemManager.php line 121 :

Driver [] is not supported.
config/filesystems.php

代碼: 選擇全部

        'admin' => [
            'driver' => 'local',
            'root' => public_path('upload'),
            'visibility' => 'public',
        ],
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

關連欄位寫入

文章 yehlu »

代碼: 選擇全部

            $form->saving(function (Form $form) {

            if(  $form->model()->sns->name <> $form->name){
                $form->model()->sns->name = $form->name;
                $form->model()->sns->save();
            }

            });


yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

operation_log_settings

文章 yehlu »

https://github.com/z-song/laravel-admin/pull/418

2017-02-24日以後沒作用了
是設定檔需加上啟用操作記錄

config/admin.php

代碼: 選擇全部

    'operation_log' => [
        'active' => true,
        'exclude_methods' => ['GET'],
        'max_age_in_days' => 100,
    ],

yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: encore/laravel-admin 昇級出錯

文章 yehlu »

找不到 admin/route

app/Admin/route.php

代碼: 選擇全部

use Illuminate\Routing\Router;

Admin::registerHelpersRoutes();

Route::group([
    'prefix' => config('admin.prefix'),
    'namespace' => Admin::controllerNamespace(),
    'middleware' => ['web', 'admin'],
], function (Router $router) {

    $router->get('/', 'HomeController@index');

});
app/Admin/bootstrap.php

代碼: 選擇全部

Encore\Admin\Form::forget(['map', 'editor']);
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

如何讓Grid第一次不自動取出資料?

文章 yehlu »

https://github.com/z-song/laravel-admin/issues/557

代碼: 選擇全部

    protected function grid(Request $request)
    {
        return Admin::grid(Topic::class, function (Grid $grid) use ($request) {
       ......
            if (request()->has('topic_id')) {

            }
       }

yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

依條件顯示刪除或修改圖示

文章 yehlu »

代碼: 選擇全部

            $grid->actions(function ($actions) {
                $actions->disableDelete();
                if ($actions->row->user_id <> Admin::user()->id) {
                    $actions->disableEdit();
                }
            });
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

表單修改前後做資料相關事情

文章 yehlu »

http://z-song.github.io/laravel-admin/# ... m-callback

代碼: 選擇全部

//保存前回调
$form->saving(function (Form $form) {
    //...
                if (substr(url()->previous(), -6) == 'create');{
                    $form->key_user = Admin::user()->id;
                }
                $form->mod_user = Admin::user()->id;    
});

//保存后回调
$form->saved(function (Form $form) {
    //...
});
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

$form->editor

文章 yehlu »

富文本编辑框
编辑器组件引用了网络资源,默认关闭,如果要开启这个组件参考form组件管理.

代碼: 選擇全部

$form->editor($column[, $label]);
要在 app/Admin/bootstrap.php 開啟

代碼: 選擇全部

//Encore\Admin\Form::forget(['map', 'editor']);
Encore\Admin\Form::forget(['map']);
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: encore/laravel-admin Tree 排序欄位

文章 yehlu »

預設是用 order 這是資料庫的保留存

修改

代碼: 選擇全部

vendor/encore/laravel-admin/src/Traits/ModelTree.php
vendor/encore/laravel-admin/src/Auth/Database/Menu.php
model

代碼: 選擇全部

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $this->setParentColumn('parent_id');
        $this->setOrderColumn('orders');
        $this->setTitleColumn('title');
    }
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

js

文章 yehlu »

app/Admin/bootstrap.php

代碼: 選擇全部

Admin::js('js/newinv.js');
Controller

代碼: 選擇全部

            Admin::script('calculatetax();');
回覆文章

回到「laravel」