本文整理汇总了PHP中app\models\Location::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::save方法的具体用法?PHP Location::save怎么用?PHP Location::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Location
的用法示例。
在下文中一共展示了Location::save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
for ($i = 0; $i < 100; $i++) {
$location = new Location();
$location->latitude = -33.876173 + $this->getRandomArbitrary(-0.2, 0.2);
$location->longitude = 151.209859 + $this->getRandomArbitrary(-0.2, 0.2);
$location->save();
}
}
示例2: actionCreate
/**
* Creates a new Location model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Location();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例3: actionCreate
/**
* Creates a new Location model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Location();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', "Location <strong>{$model->title}</strong> created.");
return $this->redirect(['index']);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: run
public function run()
{
DB::table('locations')->delete();
//Create Location
$location = new Location();
$location->name = 'Nonlocated';
$location->save();
$location = new Location();
$location->name = 'Tools';
$location->save();
DB::table('metrics')->delete();
$metric = new Metric();
$metric->name = "Stk";
$metric->symbol = "stk";
$metric->save();
}
示例5: addUser
public function addUser()
{
if ($this->validate()) {
$user = new Users();
$location = new Location();
$user->name = $this->name;
$user->email = $this->email;
$user->save();
$location->user_id = $user->id;
$location->city_id = $this->city;
$location->region_id = $this->region;
$location->country_id = $this->country;
$location->save();
return true;
}
return false;
}
示例6: createOrFetchLocation
/**
* Checks the DB to see if a location with the same name exists, otherwise create it
*
* @author Daniel Melzter
* @since 3.0
* @param $asset_location string
* @return Location
*/
public function createOrFetchLocation($asset_location)
{
foreach ($this->locations as $templocation) {
if (strcasecmp($templocation->name, $asset_location) == 0) {
$this->log('Location ' . $asset_location . ' already exists');
return $templocation;
}
}
// No matching locations in the collection, create a new one.
$location = new Location();
if (!empty($asset_location)) {
$location->name = $asset_location;
$location->address = '';
$location->city = '';
$location->state = '';
$location->country = '';
$location->user_id = $this->option('user_id');
if (!$this->option('testrun')) {
if ($location->save()) {
$this->locations->add($location);
$this->log('Location ' . $asset_location . ' was created');
return $location;
} else {
$this->log('Location', $location->getErrors());
return $location;
}
} else {
$this->locations->add($location);
return $location;
}
} else {
$this->log('No location given, so none created.');
return $location;
}
}
示例7: location
public function location()
{
$hideWhereAmI = true;
$location = new Location();
$location->load();
if (!empty($_GET)) {
$location = new Location();
if (!empty($_GET['lat']) and !empty($_GET['lng'])) {
$location->getPoint()->setLat($_GET['lat']);
$location->getPoint()->setLng($_GET['lng']);
$location->save();
} elseif (!empty($_GET['cep'])) {
$address = new Address();
$address->setZipcode($_GET['cep']);
$geocode = $this->api->geocode($address);
if (!empty($geocode)) {
$location->getPoint()->setLat($geocode->getLat());
$location->getPoint()->setLng($geocode->getLng());
$revgeocode = $this->api->revgeocode($geocode->getLat(), $geocode->getLng());
$location->setAddress($revgeocode);
$location->save();
} else {
$this->redirect("profile/location");
}
} elseif (!empty($_GET['cityState'])) {
if (!strstr($_GET['cityState'], ',')) {
$this->redirect("profile/location");
}
$cityStateToUpper = strtoupper($_GET['cityState']);
list($cityField, $stateField) = \explode(',', $cityStateToUpper);
$city = new City();
$city->setName(trim($cityField));
$city->setState(trim($stateField));
$address = new Address();
$address->setCity(new City($city));
$geocode = $this->api->geocode($address);
if (!empty($geocode)) {
$location->getPoint()->setLat($geocode->getLat());
$location->getPoint()->setLng($geocode->getLng());
$location->getAddress()->setCity($city);
$location->save();
} else {
$this->redirect("profile/location");
}
}
$this->redirect("/");
}
$title = 'Onde estou';
return compact('title', 'geocode', 'hideWhereAmI', 'location');
}
示例8: fire
//.........这里部分代码省略.........
}
}
}
$this->comment('Full Name: ' . $user_name);
$this->comment('First Name: ' . $first_name);
$this->comment('Last Name: ' . $last_name);
$this->comment('Username: ' . $user_username);
$this->comment('Email: ' . $user_email);
$this->comment('Category Name: ' . $user_asset_category);
$this->comment('Item: ' . $user_asset_name);
$this->comment('Manufacturer ID: ' . $user_asset_mfgr);
$this->comment('Model No: ' . $user_asset_modelno);
$this->comment('Serial No: ' . $user_asset_serial);
$this->comment('Asset Tag: ' . $user_asset_tag);
$this->comment('Location: ' . $user_asset_location);
$this->comment('Purchase Date: ' . $user_asset_purchase_date);
$this->comment('Purchase Cost: ' . $user_asset_purchase_cost);
$this->comment('Notes: ' . $user_asset_notes);
$this->comment('Company Name: ' . $user_asset_company_name);
$this->comment('------------- Action Summary ----------------');
if ($user_username != '') {
if ($user = User::MatchEmailOrUsername($user_username, $user_email)->whereNotNull('username')->first()) {
$this->comment('User ' . $user_username . ' already exists');
} else {
$user = new \App\Models\User();
$password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
$user->first_name = $first_name;
$user->last_name = $last_name;
$user->username = $user_username;
$user->email = $user_email;
$user->permissions = '{user":1}';
$user->password = bcrypt($password);
$user->activated = 1;
if ($user->save()) {
$this->comment('User ' . $first_name . ' created');
} else {
$this->error('ERROR CREATING User ' . $first_name . ' ' . $last_name);
$this->error($user->getErrors());
}
}
} else {
$user = new User();
}
// Check for the location match and create it if it doesn't exist
if ($location = Location::where('name', e($user_asset_location))->first()) {
$this->comment('Location ' . $user_asset_location . ' already exists');
} else {
$location = new Location();
if ($user_asset_location != '') {
$location->name = e($user_asset_location);
$location->address = '';
$location->city = '';
$location->state = '';
$location->country = '';
$location->user_id = 1;
if (!$this->option('testrun') == 'true') {
if ($location->save()) {
$this->comment('Location ' . $user_asset_location . ' was created');
} else {
$this->error('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
$this->error($location->getErrors());
}
} else {
$this->comment('Location ' . $user_asset_location . ' was (not) created - test run only');
}
} else {
示例9: storeLocation
public function storeLocation(Request $request)
{
$latitude = $request->input('latitude');
$longitude = $request->input('longitude');
$location = new Location();
$location->latitude = $latitude;
$location->longitude = $longitude;
$location->save();
}
示例10: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Location $location)
{
$location->region = $request->get('region');
$location->save();
return response()->json($location->toArray());
}
示例11: store
/**
* Validates and stores a new location created via the Create Asset form modal.
*
* @todo Check if a Form Request would work better here.
* @author [A. Gianotto] [<snipe@snipe.net>]
* @see AssetsController::getCreate() method that makes the form
* @since [v1.0]
* @return String JSON
*/
public function store()
{
$new['currency'] = Setting::first()->default_currency;
// create a new location instance
$location = new Location();
// Save the location data
$location->name = e(Input::get('name'));
$location->currency = Setting::first()->default_currency;
//e(Input::get('currency'));
$location->address = '';
//e(Input::get('address'));
// $location->address2 = e(Input::get('address2'));
$location->city = e(Input::get('city'));
$location->state = '';
//e(Input::get('state'));
$location->country = e(Input::get('country'));
// $location->zip = e(Input::get('zip'));
$location->user_id = Auth::user()->id;
// Was the location created?
if ($location->save()) {
return JsonResponse::create($location);
}
// failure
$errors = $location->errors();
return JsonResponse::create(["error" => "Failed validation: " . print_r($location->getErrors(), true)], 500);
}
示例12: checkin
public function checkin($placeId = null)
{
if (empty($placeId)) {
$this->redirect('/');
}
$place = $this->api->getPlace(array('placeid' => $placeId));
$placeName = $place->getName();
$url = ApontadorApi::encurtaUrl($place->getPlaceUrl());
$status = "Eu estou em " . $place->getName() . ". " . $url . " #checkin via @sitechegamos";
if (!empty($_POST) && $place instanceof Place) {
$location = new Location();
$location->setPoint($place->getPoint());
$location->setAddress($place->getAddress());
$location->save();
$checkinData = array('placeId' => $place->getId(), 'placeName' => $place->getName(), 'term' => $place->getName(), 'lat' => $place->getPoint()->getLat(), 'lng' => $place->getPoint()->getLng());
$checkinData['url'] = isset($_POST['url']) ? $_POST['url'] : $url;
$checkinData['status'] = isset($_POST['status']) ? str_replace("\n", " ", $_POST['status']) : $status;
$checkinData['providers'] = isset($_POST['providers']) ? $_POST['providers'] : array();
$checkedin = $this->doCheckin($checkinData);
if ($checkedin) {
$this->redirect('/places/checkins/' . $placeId);
} else {
$this->redirect($place->getPlaceUrl());
}
}
$providers = array();
if (OauthController::isLogged('apontador')) {
$providers['apontador'] = "Apontador";
}
if (OauthController::isLogged('foursquare')) {
$providers['foursquare'] = "Foursquare";
}
if (OauthController::isLogged('twitter')) {
$providers['twitter'] = "Twitter";
}
if (OauthController::isLogged('facebook')) {
$providers['facebook'] = "Facebook";
}
if (OauthController::isLogged('orkut')) {
$providers['orkut'] = "Orkut";
}
if (count($providers) == 0) {
OauthController::verifyLogged('apontador');
}
$location = new Location();
$location->load();
$title = 'Check-in em ' . $placeName;
return compact('title', 'providers', 'status', 'location');
}