0

Can I save image for 2 tables in db with same file request?

in controller

$combo                 = new Combo;
if ($request->hasFile('image') && $request->file('image')->isValid()) {
   $combo->addMediaFromRequest('image')->toMediaCollection('combos');
}

$menuItem                 = new MenuItem;
if ($request->hasFile('image') && $request->file('image')->isValid()) {
   $combo->addMediaFromRequest('image')->toMediaCollection('menu-items');
}

Can someone help me fix this code to save it? Thank you very much for your help

  • 1
    Welcome! [Here's how to ask a proper "Where's the bug / Fix my code" question](https://meta.stackoverflow.com/a/253788/11107541). Can you please read it and apply what you learn to improve your question? You can also read [ask] for further guidance. – starball Jan 06 '23 at 01:27

0 Answers0