/**
  * Store a newly created resource in storage.
  * POST /locations
  *
  * @return Response
  */
 public function store()
 {
     //        $validator = Location::validate(Input::only('address', 'title', 'phone', 'fax', 'description', 'url'));
     $location = new Location();
     $location->name = Input::get('location');
     $location->tiele = Input::get('title');
     $location->address = Input::get('address');
     $location->phone = Input::get('phone');
     $location->fax = Input::get('fax');
     $location->description = Input::get('description');
     $location->email = Input::get('email');
     $location->hours = Input::get('hours');
     $location->alt_txt = Input::get('alt_txt');
     if (Input::hasFile('photo')) {
         $photo = Input::file('photo');
         $filename = time() . '-' . $photo->getClientOriginalName();
         $destination = public_path() . '/img/' . $filename;
         if (!File::exists($destination)) {
             try {
                 $photo_path = $photo->move(public_path() . '/img/', $filename);
                 $location->url = $filename;
             } catch (Fileexception $e) {
                 return 'Sorry, Could not upload the file! Please, try again later!!';
             }
         } else {
             return 'This File already exist!! Please, upload another file!!!';
         }
     }
     $location->save();
     return Redirect::to('alllocations')->with('message', 'Photo uploaded Successfully');
 }
 public function add($attr, $image)
 {
     $model = new Post();
     $model->setAttributes($attr);
     $model->date = time();
     $model->post_comment_count = 0;
     $model->post_like_count = 0;
     $image_url = null;
     if (isset($image)) {
         $image_url = UploadHelper::getUrlUploadSingleImage($image, $attr['user_id']);
     }
     $location = new Location();
     $location->longitude = $attr['lng'];
     $location->latitude = $attr['lat'];
     $location->name = $attr['name'];
     $location->save(FALSE);
     $model->image = $image_url;
     $model->location_id = $location->location_id;
     if ($model->save(FALSE)) {
         $subject_arr = json_decode($attr['subject'], true);
         foreach ($subject_arr as $item) {
             $subject_post = new PostSubject();
             $subject_post->post_id = $model->post_id;
             $subject_post->subject_id = $item;
             $subject_post->save(FALSE);
         }
         return TRUE;
     }
     return FALSE;
 }
 public function save()
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $pin = Input::get('pin');
     if (isset($pin)) {
         $location = Location::where('pin', '=', $pin)->where('status', '=', 'active')->first();
         if (!isset($location)) {
             $location = new Location();
             $location->country = 'India';
             $location->state = Input::get('state');
             $location->city = Input::get('city');
             $location->pin = $pin;
             $location->status = 'active';
             $location->created_at = date("Y-m-d h:i:s");
             $location->updated_at = date("Y-m-d h:i:s");
             $location->save();
             return json_encode(array('message' => 'done'));
         } else {
             return json_encode(array('message' => 'duplicate'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('locations')->truncate();
     $locationClusterCmb = new Location();
     $locationClusterCmb->code = "CLS_001";
     $locationClusterCmb->name = "Colombo";
     $locationClusterCmb->location_type_id = 1;
     $locationClusterCmb->parent_location_id = 0;
     $locationClusterCmb->save();
     $locationRegMah = new Location();
     $locationRegMah->code = "REG_001";
     $locationRegMah->name = "Maharagama";
     $locationRegMah->location_type_id = 2;
     $locationRegMah->parent_location_id = $locationClusterCmb->id;
     $locationRegMah->save();
     $locationRegG5 = new Location();
     $locationRegG5->code = "REG_002";
     $locationRegG5->name = "Gampaha";
     $locationRegG5->location_type_id = 2;
     $locationRegG5->parent_location_id = $locationClusterCmb->id;
     $locationRegG5->save();
     $locationTmpNug = new Location();
     $locationTmpNug->code = "TMP_001";
     $locationTmpNug->name = "Nugegoda";
     $locationTmpNug->location_type_id = 3;
     $locationTmpNug->parent_location_id = $locationRegMah->id;
     $locationTmpNug->save();
 }
Beispiel #5
0
 public function action_add()
 {
     if (Session::has('id')) {
         $account = Account::find(Session::get('id'));
         if ($account) {
             if (Input::has('address') && Input::has('city') && Input::has('postal_code')) {
                 $location = new Location();
                 $location->address = strip_tags(Input::get('address'));
                 $location->city = strip_tags(Input::get('city'));
                 $location->postal_code = strip_tags(Input::get('postal_code'));
                 if ($location->save()) {
                     return true;
                 } else {
                     return false;
                 }
             } else {
                 die('address, city or psotal_code not set');
             }
         } else {
             die('inconsistant session data');
         }
     } else {
         die('session id not found');
     }
 }
 public function add()
 {
     $location = new LocationForm();
     $form = $location->form();
     if ($this->request->isPost()) {
         $form->setFieldValues($this->request->getPost());
         if ($form->isValid()) {
             $country_name = $this->request->getPost('lace-country-name');
             //get country
             $country_iso3 = $this->request->getPost('lace-country-iso3');
             //get iso3
             $country_iso2 = $this->request->getPost('lace-country-iso2');
             //get iso2
             $post_code = $this->request->getPost('lace-postcode');
             //get post code
             $enabled = $this->request->getPost('lace-enabled');
             //get enabled
             $location = new Location();
             $location->save(['name' => $country_name, 'iso_code_3' => $country_iso3, 'iso_code_2' => $country_iso2, 'postcode_required' => isset($post_code) ? $post_code : 0, 'status' => isset($enabled) ? $enabled : 0]);
             //redirect to country
             $this->session->setRequestValue('success', 'Country Successfully Added', 1);
             $this->response->redirect($this->request->getBasePath() . '/' . $this->request->getPath(0) . '/locations');
         }
     }
     $this->setView('location/add_country');
     $this->view->title = 'Add Location';
     $this->view->form = $form;
     $this->response->setBody($this->view->render());
     $this->response->send();
 }
Beispiel #7
0
 private function createNewUserLocation($latitude, $longitude, $user)
 {
     $userLocation = new Location();
     $userLocation->user_id = $user->id;
     $userLocation->latitude = $latitude;
     $userLocation->longitude = $longitude;
     return $userLocation->save();
 }
Beispiel #8
0
 public function testLocationModel()
 {
     $location = new Location();
     $location->name = '';
     $location->longitude = '33.979700';
     $location->latitude = '-84.001750';
     $location->description = 'A challenging maze';
     $location->save();
 }
Beispiel #9
0
 /**
  * Creates a new location and returns the location Object.
  * @return [type] [description]
  */
 public function createLocation($name, $address, $website, $advisor_id = 0)
 {
     $location = new Location();
     $location->name = $name;
     $location->address = $address;
     $location->website = $website;
     $location->advisor_id = $advisor_id;
     $location->save();
     return $location;
 }
 public function store()
 {
     $location = new Location();
     $location->code = Input::get('code');
     $location->name = Input::get('name');
     $location->address = Input::get('address');
     $location->contact = Input::get('contact');
     $location->save();
     Session::flash('message', 'Sukses menambahkan cabang baru!');
 }
Beispiel #11
0
 public function testDelete()
 {
     $loc = new Location();
     $loc->setBuildingID(1);
     $loc->setRoom(9999);
     $loc->save();
     $this->assertTrue(Location::locationExists($loc->getBuildingId(), $loc->getRoom()) != false);
     $loc->delete();
     $this->assertTrue(!Location::locationExists($loc->getBuildingId(), $loc->getRoom()));
 }
 public function handleCreate()
 {
     $location = new Location();
     $location->name = Input::get('name');
     $location->longitude = Input::get('longitude');
     $location->latitude = Input::get('latitude');
     $location->description = Input::get('description');
     $location->save();
     return Redirect::action('LocationController@showList');
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Location();
     if (isset($_POST['Location'])) {
         $model->attributes = $_POST['Location'];
         if ($model->save()) {
             $this->redirect(array('show', 'id' => $model->lid));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  * POST /location
  *
  * @return Response
  */
 public function store()
 {
     $location = new Location();
     $location->address = Input::get('address');
     $location->city = Input::get('city');
     $location->state = Input::get('state');
     $location->zip = Input::get('zip');
     $location->save();
     $locations = Location::orderBy('created_at', 'desc')->paginate(6);
     return Redirect::action('LocationController@index');
 }
 public function actionShowLocation()
 {
     $model = new Location();
     if (isset($_POST['Location'])) {
         $model->attributes = $_POST['Location'];
         $model->scenario = 'mandatory';
         if ($model->save()) {
             echo 'saved';
         }
     }
     $this->render('_location_form', array('model' => $model));
 }
Beispiel #16
0
 public static function initializeLocation($accountId, $options)
 {
     // Figure out the proper domain name. We could do a lot more here...
     // Is this a real domain name? If not, use the IP address instead, by default, or initial setup is a pain
     $domain = isset($options['domain']) ? $options['domain'] : network::guessServerIP();
     $location = new Location();
     $location['account_id'] = $accountId;
     $location['name'] = isset($options['name']) ? $options['name'] : 'Main Location';
     $location['domain'] = $domain;
     $location->save();
     return $location->location_id;
 }
 /**
  * Store a newly created location in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Location::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $location = new Location();
     $location->name = Input::get('name');
     $location->description = Input::get('description');
     $location->save();
     return Redirect::route('locations.index')->withFlashMessage('Store has been successfully created!');
 }
Beispiel #18
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Location();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Location'])) {
         $model->attributes = $_POST['Location'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->Location_ID));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 20; $i += 1) {
         $venue = new Location();
         $venue->title = $faker->company;
         $venue->address = $faker->streetAddress;
         $venue->city = $faker->city;
         $venue->state = $faker->stateAbbr;
         $venue->zip = 78201;
         $venue->save();
     }
 }
 public function run()
 {
     $codes = [75001, 75201, 78701, 73344, 75006, 78154, 75006, 75078, 75094, 75135];
     $faker = Faker::create();
     for ($i = 0; $i < 11; $i++) {
         $location = new Location();
         $location->address = $faker->streetAddress;
         $location->city = $faker->city;
         $location->state = $faker->stateAbbr;
         $location->zip = $codes[rand(0, sizeof($codes) - 1)];
         $location->save();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('location_name' => 'required|min:2|unique:locations', 'location_charge' => 'required|integer');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $s = new Location();
         $s->location_name = Input::get('location_name');
         $s->location_charge = Input::get('location_charge');
         $s->save();
         return Redirect::to('locations')->with('success', 'Location Created Successfully');
     } else {
         return Redirect::to('locations/create')->withErrors($validator)->withInput();
     }
 }
 public function run()
 {
     $faker = Faker::create();
     /*foreach(range(1, 10) as $index)*/
     for ($i = 0; $i < 50; $i++) {
         $location = new Location();
         $location->title = $faker->company;
         $location->address = $faker->streetAddress;
         $location->city = $faker->city;
         $location->state = $faker->stateAbbr;
         $location->zip = $faker->postcode;
         $location->save();
     }
 }
Beispiel #23
0
 /**
  * Registers new principal and school for platform access
  * @return [type] [description]
  */
 public function register()
 {
     $this->setSEO(array("title" => "Register School"));
     $view = $this->getActionView();
     if (RequestMethods::post("action") == "register") {
         $user = new \User(array("name" => RequestMethods::post("name"), "email" => RequestMethods::post("email"), "phone" => RequestMethods::post("phone"), "username" => strtolower(implode("", explode(" ", RequestMethods::post("name")))), "password" => Markup::encrypt("password"), "admin" => 0));
         $user->save();
         $location = new Location(array("user_id" => $user->id, "address" => RequestMethods::post("address"), "city" => RequestMethods::post("city"), "latitude" => "", "longitude" => ""));
         $location->save();
         $organization = new Organization(array("user_id" => $user->id, "name" => RequestMethods::post("sname"), "location_id" => $location->id, "phone" => RequestMethods::post("sphone"), "logo" => ""));
         $organization->save();
         $view->set("success", true);
     }
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     //
     $accounts = Account::all();
     foreach ($accounts as $account) {
         for ($i = 0; $i < 2; $i++) {
             $l = new Location();
             $l->address = "123 fake St.";
             $l->city = "Vancouver";
             $l->postal_code = "V8V3X4";
             $l->account_id = $account->id;
             $l->save();
         }
     }
 }
Beispiel #25
0
 public function actionCreate()
 {
     $model = new Location();
     if (isset($_POST['Location'])) {
         $model->setAttributes($_POST['Location']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     //
     $accounts = Account::all();
     foreach ($accounts as $account) {
         for ($i = 1; $i <= 5; $i++) {
             $location = new Location();
             $location->address = "{$i} blah St.";
             $location->city = "Vancouver";
             $location->postal_code = "v8v2v3";
             $location->account_id = $account->id;
             $location->save();
         }
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Location();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Location'])) {
         $model->attributes = $_POST['Location'];
         if ($model->save()) {
             Flashes::addInfoFlash(Yii::t('amo', 'Location created successfully'));
             $this->redirect(array('view', 'id' => $model->lid));
         } else {
             Flashes::addErrorFlash(Yii::t('amo', 'Could not create the location.') . '  ' . Yii::t('amo', 'Please, try again later.'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Beispiel #28
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Location($this->action->id);
     if (isset($_POST['Location'])) {
         // collect user input data
         $model->attributes = $_POST['Location'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The new "{title}" location record has been successfully created.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     }
     $this->render($this->action->id, array('model' => $model));
 }
 public function save()
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $location = new Location();
     $location->city = Input::get('city');
     $location->state = Input::get('state');
     $location->pin = Input::get('pin');
     $location->country = 'India';
     $location->status = 'active';
     $location->created_at = date('Y-m-d h:i:s');
     $location->save();
     return json_encode(array('message' => 'done'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     if (BELocationHelper::validateLoca()) {
         $location = new Location();
         $name = Input::get('name');
         $p_id = Input::get('p_id');
         $location->name = $name;
         $location->p_id = $p_id;
         $location->save();
         Session::flash('status', true);
         return Redirect::route('admin.location.index');
     } else {
         Session::flash('status', false);
         return Redirect::route('admin.location.create')->withInput();
     }
 }