如何在Laravel数据透视表附加字段中保存图像

时间:2018-08-31 10:11:42

标签: laravel

我与一个额外的数据透视字段具有belongsToMany关系

模型

public function store(Request $request)
    {
        $submission = New Submission;
        $Submission->total_submission = $request->total_submission;
        $Submission->save(); 


        $sync_data = [];
        for ($i = 0; $i < count ($request->item_id); $i++)
        $sync_data[$request->item_id[$i]] = ['amount' => $request->amount[$i]];
        $Submission->items()->sync($sync_data);

        return redirect('submission');
     }

控制器

let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .left
let attributes = [NSAttributedStringKey.foregroundColor:UIColor.black,
                  NSAttributedStringKey.paragraphStyle:paragraph]
self.navigationBar.titleTextAttributes = attributes

现在,我想添加另一个包含图像的字段。如何将图像保存到数据库。

0 个答案:

没有答案