SHARE
TWEET

controller

wahyudian Jun 19th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public function store(Request $req){
  2.  
  3.         $me = auth()->user();
  4.         $today = Carbon::now()->format('d');
  5.         $countOffer = Offer::whereMonth('created_at',Carbon::now()->format('m'))->count();
  6.         $offernumber = \Functions::generateOfferNumber($countOffer);
  7.         $spancopsetting = unserialize($this->settings::get('spancop_items'));
  8.         $activity = Activity::where('customer_id',$req['customer_id'])
  9.         ->whereDay('created_at',$today)
  10.         ->first();
  11.         // $spancopActivity=$activity->category!=null ? unserialize($activity->category) : [];
  12.  
  13.         $offer = Offer::create([
  14.             'offer_number'=>$offernumber,
  15.             'sales_id'=>$me->id,
  16.             'customer_id'=>$req['customer_id'],
  17.         ]);
  18.         $dataproduct=[];
  19.         foreach($req['product'] as $key=>$val){
  20.             $dataproduct[$val]=[
  21.                 'quantity'=>$req['quantity'][$key],
  22.                 'discount'=>$req['discount'][$key]
  23.             ];
  24.         }
  25.  
  26.         $offer->products()->sync($dataproduct);
  27.  
  28.  
  29.         return redirect()->route('users.show',$req['customer_id']);
  30.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top