sanca

manyToMany

May 1st, 2021 (edited)
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. /**
  2.  * PACKAGE CONTROLLER
  3.  * code attach
  4.  */
  5.  
  6. $weddingPackage->weddingServices()->attach(
  7.     $request->services,
  8.     [
  9.         'qty' => $request->qty,
  10.         'total' => $request->hargaService
  11.     ]
  12. );
  13.  
  14. /**
  15.  * Model Package
  16.  */
  17.  
  18. public function weddingServices()
  19. {
  20.     return $this->belongsToMany(WeddingService::class, 'wed_pack_serv', 'wed_pack_id', 'wed_serv_id')->withPivot(['qty', 'total']);
  21. }
  22.  
  23. /**
  24.  * Model service
  25.  */
  26.  
  27. public function weddingPackages()
  28. {
  29.     return $this->belongsToMany(WeddingPackage::class, 'wed_pack_serv', 'wed_pack_id', 'wed_serv_id')->withPivot(['qty', 'total']);
  30. }
Add Comment
Please, Sign In to add comment