duanqiu2064 2016-10-19 23:12
浏览 42
已采纳

Laravel-Backpack图像场调试

I have a problem with saving one field, how can I debug? dd in AdvertController.php has no effect. All other fields are stored properly.

AdvertController.php

class AdvertController extends Controller
{
public function store(Requests\StoreAdvertPostRequest $request)
    {
        dd($request->input('photo'));
    }

AdvertCrudController.php

public function edit($id)
{

    $articlePicture = Advert::find($id)->photos[0]->file_name;

    $path = 'uploads/photos/' . $articlePicture;

    $this->crud->addField([
        'name' => 'photo',
        'label' => 'Profile Image',
        'type' => 'image',
        'value' => $path,
        'crop' => true,
        'aspect_ratio' => 0.75,
    ]);

    return parent::edit($id);
}

Finally, I would also like to pass the coordinates of the crop to store method.

  • 写回答

2条回答 默认 最新

  • doufu2396 2016-10-21 04:23
    关注

    The "store" method is only called when creating an entry, not editing. Perhaps you were trying to edit? Then the dd() should be placed inside the update() method. But that's in the CrudController, not the regular one. I have no idea what your regular controller does.

    Usually when the value does not get stored in the database it's because you forgot to place the column in the $fillable attribute on the model.

    Also, because this is an upload field, you should create a mutator that also places the file on disk. The "image" field documentation has it.

    Cheers!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)