Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function store(Request $req){
- $me = auth()->user();
- $today = Carbon::now()->format('d');
- $countOffer = Offer::whereMonth('created_at',Carbon::now()->format('m'))->count();
- $offernumber = \Functions::generateOfferNumber($countOffer);
- $spancopsetting = unserialize($this->settings::get('spancop_items'));
- $activity = Activity::where('customer_id',$req['customer_id'])
- ->whereDay('created_at',$today)
- ->first();
- // $spancopActivity=$activity->category!=null ? unserialize($activity->category) : [];
- $offer = Offer::create([
- 'offer_number'=>$offernumber,
- 'sales_id'=>$me->id,
- 'customer_id'=>$req['customer_id'],
- ]);
- $dataproduct=[];
- foreach($req['product'] as $key=>$val){
- $dataproduct[$val]=[
- 'quantity'=>$req['quantity'][$key],
- 'discount'=>$req['discount'][$key]
- ];
- }
- $offer->products()->sync($dataproduct);
- return redirect()->route('users.show',$req['customer_id']);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement