예제 #1
0
 public function store(Request $request, $orgId)
 {
     $orgOrder = new OrganizationOrder();
     $orgOrder->fill($request->input('OrganizationOrder', []));
     $orgOrder->due_by = date("Y-m-d H:i:s", strtotime($orgOrder->due_by));
     $orgRestaurant = DB::select('select id from organizations_restaurants where organization_id=? and restaurant_id=? limit 1', [$orgId, $request->input('restaurant_id')]);
     $orgOrder->organization_restaurant_id = $orgRestaurant[0]->id;
     if ($orgOrder->isValid()) {
         $orgOrder->save();
         return redirect()->route('orgorder.index', ['orgId' => $orgId]);
     } else {
         return redirect()->route('orgorder.create', ['orgId' => $orgId])->withErrors($orgOrder->getErrors())->withInput();
     }
 }