angularjs - How to save Laravel relations with one line code? -


i have idea i'm not sure if possible laravel.

i'm using angularjs on frontend, , i'm posting data backend. data structure same of backend.

please check data format understand doing : http://www.jsoneditoronline.org/?id=04c946bc1bb5bec217b45d191f3ad51a

models related between others (like hasmany, belongsto et...)

how save data currently?

public function store(request $request) {      $data=$request->all();     $invoice=invoice::create($data);      foreach ($data['invoice_products'] $invoiceproduct) {         $invoiceproduct['tax_1_id']=$invoiceproduct['tax_1']['id'];         $invoiceproduct['tax_2_id']=$invoiceproduct['tax_2']['id'];         $invoice->invoiceproduct->create($invoiceproduct)        }     return $invoice; } 

so, question there way save data single line code this;

public function store(request $request) {      return $invoice=invoice::savewithrelations($request->all());  } 

i want that, because relations defined well. great kind of saving. there way this?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -