LoginSignup
10
7

More than 5 years have passed since last update.

laravel-admin gridの「操作」列にボタンを追加する

Posted at

gridにボタンを追加する

下記のようにURLを指定することで、別のController等へ直接リンクを張ることが出来る。

    protected function grid()
    {
        $grid = new Grid(new YourModel);

        $grid->id('ID')->sortable();
        $grid->created_at('Created at');
        $grid->updated_at('Updated at');

        //「操作」列にボタンの追加
        $grid->actions(function ($actions) {
          //form等のURLを指定する。
            $actions->prepend('<a href="/admin/testform/'.$actions->getKey().'/edit"><button type="button" class="btn btn-primary btn-xs">テストボタン</button></a></br>');
        });
        return $grid;
    }

下記のように表示される

テストボタン.PNG

10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7