コード例 #1
0
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'mobile' => 'required']);
     $store = new Store();
     $store->fill($request->all());
     $store->save();
     return response()->json(['id' => $store->id]);
 }
コード例 #2
0
ファイル: StoreController.php プロジェクト: elconejito/bang
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Create the new Store
     $store = new Store();
     $store->label = $request->label;
     $store->notes = $request->notes;
     // Save it
     $store->save();
     session()->flash('message', 'Store has been saved');
     session()->flash('message-type', 'success');
     return redirect()->action('StoreController@index');
 }
コード例 #3
0
ファイル: StoreController.php プロジェクト: kelvinmbwilo/VVS
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $item = new Store();
     $item->status = "active";
     $item->name = $request->input("name");
     $item->code = $request->input("code");
     $item->recipient_id = Auth::user()->recipient_id;
     $item->net_volume = $request->input("net_volume");
     $item->store_type = $request->input("store_type");
     $item->notes = $request->has("notes") ? $request->input("notes") : "";
     $item->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Add Store named " . $item->name));
     return $item;
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $store = new Store();
     $store->brand_id = (int) $request->brand_id;
     $store->payment_type = (int) $request->payment_type;
     //        $store->day = implode(',',$request->day);
     $store->store_name = $request->store_name;
     $store->address = $request->address;
     $store->latitude = $request->latitude;
     $store->longitude = $request->longitude;
     $store->opening_time = $request->opening_time;
     $store->closing_time = $request->closing_time;
     $store->highlights = $request->highlights;
     $store->price_range = $request->price_range;
     $store->save();
     return redirect('admin/stores');
 }
コード例 #5
0
 public function store(Request $request)
 {
     $rules = ['name' => 'required', 'address' => 'required', 'lat' => 'required|numeric', 'long' => 'required|numeric'];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     $store = new Store();
     $store->name = $request->get('name');
     $store->address = $request->get('address');
     $store->lat = $request->get('lat');
     $store->long = $request->get('long');
     $store->url = "blaaah";
     $store->save();
     $request->session()->flash('message', 'Store successfuly added');
     return redirect()->back();
 }
コード例 #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('stores')->truncate();
     $page_token = null;
     while (true) {
         $api_id = "AIzaSyCWhdA9YqfE9lIbFlFLLPbyZvEwR8hdyQ4";
         if (is_null($page_token)) {
             $get_data = http_build_query(['query' => 'Drugstores in the Philippines', 'key' => $api_id]);
             $results = file_get_contents('https://maps.googleapis.com/maps/api/place/textsearch/json?' . $get_data, false);
             $results = json_decode($results);
             foreach ($results->results as $result) {
                 $store = new Store();
                 $store->name = $result->name;
                 $store->address = $result->formatted_address;
                 $store->url = $result->icon;
                 $store->lat = $result->geometry->location->lat;
                 $store->long = $result->geometry->location->lng;
                 $store->save();
             }
             $page_token = $results->next_page_token;
         } else {
             $api_id = "AIzaSyBlrchX9elMViPeAvmcqaN74sftBGKNMNs";
             $get_data = http_build_query(['query' => 'Drugstores in Philippines', 'key' => $api_id, 'pagetoken' => $page_token]);
             $results = file_get_contents('https://maps.googleapis.com/maps/api/place/textsearch/json?' . $get_data, false);
             $results = json_decode($results);
             foreach ($results->results as $result) {
                 $store = new Store();
                 $store->name = $result->name;
                 $store->address = $result->formatted_address;
                 $store->url = $result->icon;
                 $store->lat = $result->geometry->location->lat;
                 $store->long = $result->geometry->location->lng;
                 $store->save();
             }
             if (is_null($results->next_page_token)) {
                 break;
             } else {
                 $page_token = $results->next_page_token;
             }
         }
     }
 }
コード例 #7
0
ファイル: ErpController.php プロジェクト: jokuf/erp-obt
 public function postWarehouse(Request $request)
 {
     $input = \Input::all();
     $rules = array('master_group' => 'required|min:3|max:80');
     $v = \Validator::make($input, $rules);
     try {
         if ($v->passes()) {
             $masterCategory = new Store();
             $masterCategory->name = $input['master_group'];
             $masterCategory->user_id = Auth::user()->id;
             //$masterCategory ->visible=5;
             $masterCategory->save();
             return redirect('dash/warehouse');
         } else {
             return redirect('/dash/warehouse/')->withErrors($v);
         }
     } catch (\Illuminate\Database\QueryException $e) {
         $this->command->error("SQL Error: " . $e->getMessage() . "\n");
     } finally {
         return redirect('/dash/warehouse/');
     }
 }
コード例 #8
0
ファイル: StoreController.php プロジェクト: vikassaini26/yarn
 public function postAdditem()
 {
     // dd()
     $validator = Validator::make(Input::all(), ['item_name' => 'required', 'item_type' => 'required', 'quantity' => 'required', 'units' => 'required', 'order_id' => 'required', 'vendor_id' => 'required']);
     if ($validator->fails()) {
         //dd($validator);
         return redirect('store/additem')->withErrors($validator)->withInput();
     } else {
         //$date = date('Y-m-d H:i:s');
         $new_item = new Store();
         $new_item->item_name = Input::get('item_name');
         $new_item->units = Input::get('units');
         $new_item->item_type = Input::get('item_type');
         $new_item->order_id = Input::get('order_id');
         $new_item->vendor_id = Input::get('vendor_id');
         $new_item->quantity = Input::get('quantity');
         $new_item->item_description = Input::get('item_description');
         $new_item->item_added_by = Auth::id();
         $new_item->save();
         return redirect('store/additem')->with('new_item', 'New item added in store succesfully');
     }
 }
コード例 #9
0
 public function run()
 {
     $start_date = '';
     $end_date = '';
     $folderpath = 'database/seeds/seed_files';
     $folders = File::directories($folderpath);
     $latest = '11232015';
     foreach ($folders as $value) {
         $_dir = explode("/", $value);
         $cnt = count($_dir);
         $name = $_dir[$cnt - 1];
         $latest_date = DateTime::createFromFormat('mdY', $latest);
         $now = DateTime::createFromFormat('mdY', $name);
         if ($now > $latest_date) {
             $latest = $name;
         }
     }
     $file_path = $folderpath . "/" . $latest . "/Store Mapping.xlsx";
     echo (string) $file_path, "\n";
     // dd($file_path);
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('audit_templates')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->template)) {
                 $template = AuditTemplate::where('template', $row->template)->first();
                 if (count($template) == 0) {
                     $newtemplate = new AuditTemplate();
                     $newtemplate->template_code = $row->channel_code;
                     $newtemplate->template = $row->template;
                     $newtemplate->save();
                 }
             }
         });
     });
     DB::table('grade_matrixs')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->enrollment_type)) {
                 $matrix = GradeMatrix::where('desc', $row->enrollment_type)->first();
                 if (count($matrix) == 0) {
                     $newmatrix = new GradeMatrix();
                     $newmatrix->desc = $row->enrollment_type;
                     $newmatrix->save();
                 }
             }
         });
     });
     DB::table('users')->truncate();
     DB::table('role_user')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->fullname)) {
                 $userlist = explode("/", $row->fullname);
                 $emaillist = explode("/", $row->email);
                 // dd($row);
                 for ($i = 0; $i < count($userlist); $i++) {
                     $user = User::where('username', $row->username)->first();
                     if (count($user) == 0) {
                         if (empty($emaillist[$i])) {
                             $email = strtolower($row->username . "@unilever.com");
                         } else {
                             $email = strtolower($emaillist[$i]);
                         }
                         $newuser = User::create(array('name' => strtoupper($userlist[$i]), 'email' => $email, 'username' => $row->username, 'password' => Hash::make('password')));
                         $newuser->roles()->attach(3);
                     } else {
                         // $user->name = strtoupper($row->fullname);
                         // $user->username = $row->username;
                         // $user->email = strtolower($row->email);
                         // $user->update();
                         // if(!$user->hasRole('field')){
                         // 	$user->roles()->attach(3);
                         // }
                         // echo $user->hasRole('field');
                     }
                 }
             }
         });
     });
     DB::table('accounts')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $account = Account::where('account', $row->account)->first();
                 if (count($account) == 0) {
                     $newaccount = new Account();
                     $newaccount->account = $row->account;
                     $newaccount->save();
                 }
             }
         });
     });
     DB::table('customers')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 // var_dump($row);
                 $account = Account::where('account', $row->account)->first();
                 if (!empty($account)) {
                     $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first();
                     if (count($customer) == 0) {
                         $newcustomer = new Customer();
                         $newcustomer->account_id = $account->id;
                         $newcustomer->customer_code = $row->customer_code;
                         $newcustomer->customer = $row->customer;
                         $newcustomer->save();
                     }
                 }
             }
         });
     });
     DB::table('areas')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $account = Account::where('account', $row->account)->first();
                 if (!empty($account)) {
                     $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first();
                     if (!empty($customer)) {
                         $area = Area::where('customer_id', $customer->id)->where('area', $row->area)->first();
                         if (count($area) == 0) {
                             $newarea = new Area();
                             $newarea->customer_id = $customer->id;
                             $newarea->area = $row->area;
                             $newarea->save();
                         }
                     }
                 }
             }
         });
     });
     DB::table('regions')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $region = Region::where('region_code', $row->region_code)->where('region', $row->region)->first();
                 if (count($region) == 0) {
                     $newregion = new Region();
                     $newregion->region_code = $row->region_code;
                     $newregion->region = $row->region;
                     $newregion->save();
                 }
             }
         });
     });
     DB::table('distributors')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $dis = Distributor::where('distributor_code', $row->distributor_code)->where('distributor', $row->distributor)->first();
                 if (count($dis) == 0) {
                     $newdis = new Distributor();
                     $newdis->distributor_code = $row->distributor_code;
                     $newdis->distributor = strtoupper($row->distributor);
                     $newdis->save();
                 }
             }
         });
     });
     DB::table('stores')->truncate();
     DB::table('store_user')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $account = Account::where('account', $row->account)->first();
                 if (!empty($account)) {
                     $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first();
                     if (!empty($customer)) {
                         $region = Region::where('region_code', $row->region_code)->first();
                         $dis = Distributor::where('distributor_code', $row->distributor_code)->first();
                         $store = Store::where('account_id', $account->id)->where('customer_id', $customer->id)->where('region_id', $region->id)->where('distributor_id', $dis->id)->where('store_code', $row->store_code)->where('store', $row->store_name)->first();
                         if (count($store) == 0) {
                             $template = AuditTemplate::where('template', $row->template)->first();
                             $matrix = GradeMatrix::where('desc', $row->enrollment_type)->first();
                             $newstore = new Store();
                             $newstore->account_id = $account->id;
                             $newstore->customer_id = $customer->id;
                             $newstore->region_id = $region->id;
                             $newstore->distributor_id = $dis->id;
                             $newstore->store_code = $row->store_code;
                             $newstore->store = $row->store_name;
                             $newstore->grade_matrix_id = $matrix->id;
                             $newstore->audit_template_id = $template->id;
                             $newstore->save();
                             $emaillist = explode("/", $row->email);
                             for ($i = 0; $i < count($emaillist); $i++) {
                                 if (empty($emaillist[$i])) {
                                     $email = strtolower($row->username . "@unilever.com");
                                 } else {
                                     $email = strtolower($emaillist[$i]);
                                 }
                                 $user = User::where('email', $email)->first();
                                 $newstore->users()->attach($user->id);
                             }
                         } else {
                             $emaillist = explode("/", $row->email);
                             for ($i = 0; $i < count($emaillist); $i++) {
                                 if (empty($emaillist[$i])) {
                                     $email = strtolower($row->username . "@unilever.com");
                                 } else {
                                     $email = strtolower($emaillist[$i]);
                                 }
                                 $user = User::where('email', $email)->first();
                                 $store->users()->attach($user->id);
                             }
                         }
                     }
                 }
             }
         });
     });
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
コード例 #10
0
 public function AddStore(Request $request)
 {
     // Start Check Authorization
     /**
      * 1. FullAccess - 1
      * 2. HRD - 3
      * 3. Creator - 5
      * 4. Handler - 7
      */
     $invalid_auth = 1;
     $authRole = Auth::user()->UserRoles->role;
     if ($authRole == 5 or $authRole == 1 or $authRole == 3) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('project/view/' . $request->input('id_project'));
     }
     // End Check Authorization
     // Count Rows //
     $cont = count($request->all()) - 2;
     $count = $cont / 1;
     // Validation //
     $validation = Validator::make($request->all(), ['name' => 'required|max:255']);
     // Check if it fails //
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     $store = new Store();
     $author = Auth::user()->id;
     if ($count > 1) {
         for ($i = 2; $i <= $count; $i++) {
             $stor = $i;
             $stor = new Store();
             $id_urut = $i;
             $name_post = "ID" . $i . "_name";
             $name = $request->input($name_post);
             // save store data into database //
             $stor->name = $name;
             $stor->status = 0;
             $stor->id_projects = $request->input('id_project');
             $stor->save();
         }
     }
     // save variant data into database //
     $store->name = $request->input('name');
     $store->id_projects = $request->input('id_project');
     $stor->status = 0;
     $store->save();
     Alert::success('Berhasil menambahkan toko!')->persistent("Close");
     return redirect('project/view/' . $request->input('id_project'))->with('message', 'Kamu baru saja menambahkan toko!');
 }
コード例 #11
0
 public function AddStore(Request $request)
 {
     // Count Rows //
     $cont = count($request->all()) - 2;
     $count = $cont / 1;
     // Validation //
     $validation = Validator::make($request->all(), ['name' => 'required|max:255']);
     // Check if it fails //
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     $store = new Store();
     $author = Auth::user()->id;
     if ($count > 1) {
         for ($i = 2; $i <= $count; $i++) {
             $stor = $i;
             $stor = new Store();
             $id_urut = $i;
             $name_post = "ID" . $i . "_name";
             $name = $request->input($name_post);
             // save store data into database //
             $stor->name = $name;
             $stor->status = 0;
             $stor->id_projects = $request->input('id_project');
             $stor->save();
         }
     }
     // save variant data into database //
     $store->name = $request->input('name');
     $store->id_projects = $request->input('id_project');
     $stor->status = 0;
     $store->save();
     Alert::success('Berhasil menambahkan toko!')->persistent("Close");
     return redirect('project/view/' . $request->input('id_project'))->with('message', 'Kamu baru saja menambahkan toko!');
 }