dqm83011 2017-05-17 11:24
浏览 23

too long

I have a task - insert a custom column in one of our admin pages, where I can to call method from Model for each entry, generated by backpack CRUD generator. I have found in official documentations statement that looks like what I need here:

https://laravel-backpack.readme.io/v3.0/docs/crud-columns-types#section-roll-your-own

But there is nothing about how to implement this in the controller right way. So I have tried to do just like this

Controller:

$status = [
        'label' => 'Status',
        'name'  => 'status',
        'type'  => 'text'
    ];
$this->crud->addColumn($status);

and as mentinoned in documentation, I have create my own blade file in

resources\views\vendor\backpack\crud\columns

Here it is:

{{-- status --}}
<td>{{ $entry->isBlocked }}</td>

Where isBlocked is method in my Model. I have an error about database and nothing is working. Please say is it even possible to do what I wnat and if it is - please say how to do it right way both in view and controller

Thankyou!

  • 写回答

1条回答 默认 最新

  • douli2063 2017-05-23 10:38
    关注

    Let's check your code

     $status = [
            'label' => 'Status',
            'name'  => 'isBlocked', // your column name 
            'type'  => 'status' // your blade name, e.g status.blade.php
          ];
    
    $this->crud->addColumn($status);
    

    and inside status.blade.php

    {{-- status --}}
    <td>{{ $entry->{$column['name'] }}</td>
    

    Any question, please comment

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c