/** * Display a listing of the resource. * * @return Response */ public function index() { $this->view_data['rental_services'] = RentalService::active()->get(); $this->view_data['purchase_services'] = PurchaseService::active()->get(); $this->view_data['costs'] = Config::get('constants.costs'); return view($this->view_data['view_path_root'] . '.index', $this->view_data); }
public function run() { DB::table('rental_services')->delete(); RentalService::create(['number_in_row' => 1, 'title' => 'Boxes', 'price' => 100, 'image' => 'boxes.png', 'status' => 0, 'max_quantity' => 20]); RentalService::create(['number_in_row' => 2, 'title' => 'Boxes with books', 'price' => 200, 'image' => 'boxes_with_books.png', 'status' => 0, 'max_quantity' => 10]); RentalService::create(['number_in_row' => 3, 'title' => 'Moving cart', 'price' => 250, 'image' => 'cart.png', 'status' => 0, 'max_quantity' => 1]); RentalService::create(['number_in_row' => 4, 'title' => 'Single bed cover', 'price' => 500, 'image' => 'single_bed.png', 'status' => 0, 'max_quantity' => 5]); RentalService::create(['number_in_row' => 5, 'title' => 'Double bed cover', 'price' => 700, 'image' => 'double_bed.png', 'status' => 0, 'max_quantity' => 5]); RentalService::create(['number_in_row' => 6, 'title' => 'Queen bed cover', 'price' => 800, 'image' => 'queen_bed.png', 'status' => 0, 'max_quantity' => 5]); RentalService::create(['number_in_row' => 7, 'title' => 'Moving Tape', 'price' => 100, 'image' => 'tape.png', 'status' => 0, 'max_quantity' => 1]); RentalService::create(['number_in_row' => 8, 'title' => 'Cardboard Boxes', 'price' => 250, 'image' => 'cardboard.png', 'status' => -1, 'max_quantity' => 1]); RentalService::create(['number_in_row' => 9, 'title' => 'Gloves', 'price' => 150, 'image' => 'gloves.png', 'status' => 0, 'max_quantity' => 1]); RentalService::create(['number_in_row' => 10, 'title' => 'Bubble Wraps', 'price' => 700, 'image' => 'bubble_wrap.png', 'status' => 0, 'max_quantity' => 1]); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $input = $request->all(); $res['status'] = 400; $res['message'] = ''; $res['errors'] = []; $rental_services = RentalService::active()->get(); $purchase_services = PurchaseService::active()->get(); $data['costs'] = Config::get('constants.costs'); $data['rental_services'] = []; foreach ($rental_services as $rental_service) { if (!isset($input[$rental_service->id . '___rental'])) { $res['message'] = 'An error occour, please refresh page and try again.'; return response()->json($res); } $data['rental_services'][$rental_service->id]['title'] = $rental_service->title; $data['rental_services'][$rental_service->id]['quantity'] = (int) $input[$rental_service->id . '___rental']; $data['rental_services'][$rental_service->id]['unit_price'] = (double) $rental_service->price; $data['rental_services'][$rental_service->id]['price'] = $data['rental_services'][$rental_service->id]['quantity'] * $data['rental_services'][$rental_service->id]['unit_price']; } // $data['purchase_services'] = []; // foreach ($purchase_services as $purchase_service) { // if(!isset($input[$purchase_service->id.'___purchase'])){ // $res['message'] = 'An error occour, please refresh page and try again.'; // return response()->json($res); // } // $data['purchase_services'][$purchase_service->id]['title'] = $purchase_service->title; // $data['purchase_services'][$purchase_service->id]['quantity'] = (int) $input[$purchase_service->id.'___purchase']; // $data['purchase_services'][$purchase_service->id]['unit_price'] = (float) $purchase_service->price; // $data['purchase_services'][$purchase_service->id]['price'] = $data['purchase_services'][$purchase_service->id]['quantity'] * $data['purchase_services'][$purchase_service->id]['unit_price']; // } $data['delievery_info'] = []; $data['delievery_info']['preferred_delivery_address'] = $input['preferred_delivery_address']; $data['delievery_info']['building_name'] = $input['building_name']; $data['delievery_info']['room_no'] = $input['room_no']; $data['delievery_info']['phone_no'] = $input['phone_no']; $data['bank_details'] = []; $data['bank_details']['bank_name'] = $input['bank_name']; $data['bank_details']['account_no'] = $input['account_no']; $data['bank_details']['reveiver_name'] = $input['reveiver_name']; $res['data'] = $data; $res['status'] = 200; return response()->json($res); }