duanqiu2064 2016-10-19 15: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-20 20: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部