当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::create方法代码示例

本文整理汇总了PHP中Location::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::create方法的具体用法?PHP Location::create怎么用?PHP Location::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Location的用法示例。


在下文中一共展示了Location::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Location::$rules);
     if ($validation->passes()) {
         $this->location->create($input);
         return Redirect::route('admin.locations.index');
     }
     return Redirect::route('admin.locations.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
开发者ID:jacobDaeHyung,项目名称:Laravel-Real-Estate-Manager,代码行数:15,代码来源:LocationsController.php

示例2: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Location::create([]);
     }
 }
开发者ID:kenkode,项目名称:xaraerp,代码行数:7,代码来源:LocationsTableSeeder.php

示例3: create

 public static function create($data)
 {
     session_start();
     $headers = apache_request_headers();
     $token = $headers['X-Auth-Token'];
     if ($token != $_SESSION['form_token']) {
         header('Invalid CSRF Token', true, 401);
         return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
     } else {
         if (isset($data['name']) && empty($data['name'])) {
             return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Location Name is required'), JSON_PRETTY_PRINT);
         } else {
             if (isset($data['x_coord']) && empty($data['x_coord'])) {
                 return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'X Coordinate is required'), JSON_PRETTY_PRINT);
             } else {
                 if (isset($data['y_coord']) && empty($data['y_coord'])) {
                     return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Y Coordinate is required'), JSON_PRETTY_PRINT);
                 } else {
                     $var = ['name' => $data['name'], 'x' => $data['x_coord'], 'y' => $data['y_coord'], 'description' => $data['description'], 'landarea' => $data['landarea'], 'image_path' => $data['image_path']];
                     Location::create($var);
                 }
             }
         }
     }
 }
开发者ID:jbagaresgaray,项目名称:DECISION-SUPPORT-SYSTEM,代码行数:25,代码来源:controller.php

示例4: loadRelated

 /**
  * @param array $attributes
  */
 public function loadRelated(array $attributes)
 {
     parent::loadRelated($attributes);
     if (isset($attributes['location'])) {
         $this->location = Location::create($attributes['location']);
     }
 }
开发者ID:zelenin,项目名称:telegram-bot-api,代码行数:10,代码来源:Venue.php

示例5: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         Location::create(['location_name' => $faker->company, 'location_street' => $faker->streetAddress, 'location_city' => $faker->city, 'location_state' => $faker->stateAbbr, 'location_zip' => $faker->postcode]);
     }
 }
开发者ID:Bare-Bones-Events,项目名称:Event-Planner,代码行数:7,代码来源:LocationsTableSeeder.php

示例6: store

 /**
  * 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::create($data);
     return Redirect::route('locations.index');
 }
开发者ID:julianfresco,项目名称:rideShareLog,代码行数:14,代码来源:LocationsController.php

示例7: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('locations', function (Blueprint $table) {
         $table->increments('id');
         $table->string('location')->unique();
         $table->timestamps();
     });
     Location::create(['location' => 'Baguio City']);
     Location::create(['location' => 'Gen San']);
 }
开发者ID:anthon-alindada,项目名称:gaming-88,代码行数:15,代码来源:2014_12_15_131606_create_locations_table.php

示例8: parseInput

 /**
  * Фабрикует класс, обрабатывающий сообщение
  * @param  array $m Сообщение на вход
  * @return object    Класс, ответственный за данный тип сообщения
  */
 public static function parseInput($m)
 {
     if (empty($m['message_id'])) {
         return NULL;
     }
     if (!empty($m['text'])) {
         $command = Command::create($m);
         return $command ? $command : TextMessage::create($m);
     } elseif (!empty($m['location'])) {
         return Location::create($m);
     }
 }
开发者ID:steelice,项目名称:TelegramBot,代码行数:17,代码来源:Message.php

示例9: create

 /**
  * Creates a clan object with the given data
  * @param array $data an associative array to fill up the members of the
  * clan class
  * @return Clan a clan object with the data given as it's members
  */
 public static function create(array $data) : Clan
 {
     $clan = new Clan();
     parent::fill($data, $clan);
     if (is_array($clan->location)) {
         $clan->location = Location::create($clan->location);
     }
     if (is_array($clan->memberList)) {
         $members = [];
         foreach ($clan->memberList as $member) {
             $members[] = Player::create($member);
         }
         $clan->memberList = $members;
     }
     return $clan;
 }
开发者ID:snowiow,项目名称:cocurl,代码行数:22,代码来源:Clan.php

示例10: store

 /**
  * This function will grab input data for both the Location and CalendarEvent models
  * and store the newly created Location and CalendarEvent
  * @return Response
  */
 public function store()
 {
     // Grab the Input data for the everything
     $input = Input::only('name', 'address', 'city', 'state', 'postal_code', 'start_time', 'end_time', 'title', 'description', 'price');
     //validate:form exceptions handled in start/global.php
     $this->calendarEventForm->validate($input);
     if (Input::get('location') == -1) {
         $location = Location::create($input);
         $locationId = $location->id;
     } else {
         $locationId = Input::get('location');
     }
     $calendarEvent = CalendarEvent::create(array('start_time' => Input::get('start_time'), 'end_time' => Input::get('end_time'), 'title' => Input::get('title'), 'description' => Input::get('description'), 'price' => Input::get('price'), 'location_id' => $locationId, 'user_id' => Auth::id()));
     return Response::json(CalendarEvent::with('user', 'location')->where('user_id', Auth::id())->get());
     // On Successful Creation Show The Event Page
     // return Redirect::action('CalendarEventsController@show', $calendarEvent->id);
 }
开发者ID:C-a-p-s-t-o-n-e,项目名称:capstone.dev,代码行数:22,代码来源:CalendarEventsController.php

示例11: addorupdateLcnsAndPrsnAddr

 private function addorupdateLcnsAndPrsnAddr($person_id, $postedData){
     //for person addresses.
     //office address
     $ofcaddrid = $postedData->ofcaddresses[0]->id;
     if($postedData->isofcaddress){
         $addrattributes = array(
             "street" => $postedData->ofcaddresses[0]->street,
             "locality" => $postedData->ofcaddresses[0]->locality,
             "city" => $postedData->ofcaddresses[0]->city,
             "state" => $postedData->ofcaddresses[0]->state,
             "country" => $postedData->ofcaddresses[0]->country,
             "pincode" => $postedData->ofcaddresses[0]->pincode,
             "remarks" => $postedData->ofcaddresses[0]->remarks
             );
         if($ofcaddrid > 0){
             $addrdata = \Location::find($ofcaddrid);
             $addrdata->update_attributes($addrattributes);
         }else{
             $addrdata = \Location::create($addrattributes);
             $this->createPersonAddress($person_id, $addrdata->id, "office");
         }
     }else{
         $this->deletePersonLocations($person_id, $ofcaddrid, "office");
     }
     
     //residence address
     $rsdaddrid = $postedData->rsdaddresses[0]->id;
     if($postedData->isrsdaddress){
         $addrattributes = array(
             "street" => $postedData->rsdaddresses[0]->street,
             "locality" => $postedData->rsdaddresses[0]->locality,
             "city" => $postedData->rsdaddresses[0]->city,
             "state" => $postedData->rsdaddresses[0]->state,
             "country" => $postedData->rsdaddresses[0]->country,
             "pincode" => $postedData->rsdaddresses[0]->pincode,
             "remarks" => $postedData->rsdaddresses[0]->remarks
             );
         if($rsdaddrid > 0){
             $addrdata = \Location::find($rsdaddrid);
             $addrdata->update_attributes($addrattributes);
         }else{
             $addrdata = \Location::create($addrattributes);
             $this->createPersonAddress($person_id, $addrdata->id, "residence");
         }
     }else{
         $this->deletePersonLocations($person_id, $rsdaddrid, "residence");
     }
     
     //other address
     $otheraddrid = $postedData->otheraddresses[0]->id;
     if($postedData->isotheraddress){
         $addrattributes = array(
             "street" => $postedData->otheraddresses[0]->street,
             "locality" => $postedData->otheraddresses[0]->locality,
             "city" => $postedData->otheraddresses[0]->city,
             "state" => $postedData->otheraddresses[0]->state,
             "country" => $postedData->otheraddresses[0]->country,
             "pincode" => $postedData->otheraddresses[0]->pincode,
             "remarks" => $postedData->otheraddresses[0]->remarks
             );
         if($otheraddrid > 0){
             $addrdata = \Location::find($otheraddrid);
             $addrdata->update_attributes($addrattributes);
         }else{
             $addrdata = \Location::create($addrattributes);
             $this->createPersonAddress($person_id, $addrdata->id, "other");
         }
     }else{
         $this->deletePersonLocations($person_id, $otheraddrid, "other");
     }
 }
开发者ID:Rajagunasekaran,项目名称:BACKUP,代码行数:71,代码来源:Menu.php

示例12: add

 /**
  * @throws LocationIDMissingException
  */
 public static function add()
 {
     if ($_GET['action'] == "add_child" and $_GET['id'] or $_GET['action'] == "add") {
         if ($_GET['nextpage'] == 1) {
             $page_1_passed = true;
             if (!$_POST['name']) {
                 $page_1_passed = false;
                 $error = "You must enter a name";
             }
         } else {
             $page_1_passed = false;
             $error = "";
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("location/admin/location/add.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&');
             $template->set_var("params", $params);
             if ($error) {
                 $template->set_var("error", $error);
             } else {
                 $template->set_var("error", "");
             }
             $type_array = Location::list_types();
             $result = array();
             $counter = 0;
             if (is_array($type_array) and count($type_array) >= 1) {
                 foreach ($type_array as $key => $value) {
                     if ($_POST['type_id'] == $value['id']) {
                         $result[$counter]['selected'] = "selected='selected'";
                     } else {
                         $result[$counter]['selected'] = "";
                     }
                     $result[$counter]['value'] = $value['id'];
                     $result[$counter]['content'] = $value['name'];
                     $counter++;
                 }
             }
             $template->set_var("type_array", $result);
             if ($_POST['name']) {
                 $template->set_var("name", $_POST['name']);
             } else {
                 $template->set_var("name", "");
             }
             if ($_POST['additional_name']) {
                 $template->set_var("additional_name", $_POST['additional_name']);
             } else {
                 $template->set_var("additional_name", "");
             }
             $template->output();
         } else {
             $location = new Location(null);
             if ($_GET['action'] == "add_child" and is_numeric($_GET['id'])) {
                 $toid = $_GET['id'];
             } else {
                 $toid = null;
             }
             if ($_POST['prefix'] == "1") {
                 $show_prefix = true;
             } else {
                 $show_prefix = false;
             }
             $paramquery = $_GET;
             unset($paramquery['action']);
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&');
             if ($location->create($toid, $_POST['type_id'], $_POST['name'], $_POST['additional_name'], $show_prefix)) {
                 Common_IO::step_proceed($params, "Add Location", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Add Location", "Operation Failed", null);
             }
         }
     } else {
         throw new LocationIDMissingException();
     }
 }
开发者ID:suxinde2009,项目名称:www,代码行数:80,代码来源:admin_location.io.php

示例13: ajax_add_entry

 public function ajax_add_entry()
 {
     $response = array('success' => 0, 'error' => 'Something went wrong. Please try again.');
     if (wp_verify_nonce($_POST['entry_nonce'], 'entry-nonce')) {
         $miles = strlen(trim($_POST['miles'])) > 0 && is_numeric($_POST['miles']) ? abs(trim($_POST['miles'])) : 1;
         $location = new Location();
         if ($_POST['location_id'] > 0) {
             $location->id = $_POST['location_id'];
             $location->read();
             if (!$location->user_id == get_current_user_id()) {
                 $location->id = 0;
             }
         }
         if ($location->id == 0) {
             $location->user_id = get_current_user_id();
             $location->title = strlen(trim($_POST['title'])) > 0 ? trim($_POST['title']) : 'New Location';
             $location->miles = $miles;
             $location_id = Location::checkTitle($location->user_id, $location->title);
             if ($location_id > 0) {
                 $location->id = $location_id;
                 $location->update();
             } else {
                 $location->create();
             }
         }
         $entry = new Entry();
         $entry->user_id = get_current_user_id();
         $entry->entry_date = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'];
         $entry->mode = $_POST['mode'];
         $entry->miles = $miles;
         $entry->location = $location;
         $entry->create();
         if ($entry->id > 0) {
             $response['success'] = 1;
             $response['id'] = $entry->id;
             $response['title'] = $entry->location->title;
             $response['miles'] = number_format($entry->miles, 2);
             $response['day'] = $_POST['day'];
         }
     }
     header('Content-Type: application/json');
     echo json_encode($response);
     exit;
 }
开发者ID:TonyDeStefano,项目名称:Walk-Bike-Bus-Plugin,代码行数:44,代码来源:Controller.php

示例14: select

    static function select($query, $bindings = array(), $useReadPdo = true)
    {
        return static::connection()->select($query, $bindings = array(), $useReadPdo = true);
    }
}
class Location extends Model
{
    use GeoDistanceTrait;
    protected $fillable = ['name', 'lat', 'lng'];
    public $timestamps = false;
}
Capsule::table('locations')->truncate();
Location::create(['name' => 'Cardiff', 'lat' => 51.4833, 'lng' => 3.1833]);
Location::create(['name' => 'Newport', 'lat' => 51.5833, 'lng' => 3.0]);
Location::create(['name' => 'Swansea', 'lat' => 51.6167, 'lng' => 3.95]);
Location::create(['name' => 'London', 'lat' => 51.5072, 'lng' => 0.1275]);
/*for ($i = 0; $i < 1000; $i++)
{
    Location::create(['location' => $i, 'lat' => $i, 'lng' => $i, 'updated_at' => $i, 'created_at' => $i]);
}*/
$I = new UnitTester($scenario);
$lat = 51.4833;
$lng = 3.1833;
$location = new Location();
$locations = $location->lat($lat)->lng($lng)->within(20, 'miles')->get();
$I->wantTo('find locations within 5 miles');
$locations = Location::within(5, 'miles', $lat, $lng)->get();
$I->assertEquals(1, $locations->count(), 'One location found within 5 miles');
$I->wantTo('find 2 locations within 132000 feet (25 miles)');
$locations = Location::within(132000, 'feet', $lat, $lng)->get();
$I->assertEquals(2, $locations->count(), 'One location found within 132000 feet');
开发者ID:cssjockey,项目名称:geodistance,代码行数:31,代码来源:geodistanceCept.php

示例15: saveOrder

 /**
  * saveOrder
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function saveOrder($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $items = array();
         $purchaseOrder = PurchaseOrder::get(trim($param->CallbackParameter->purchaseOrder->id));
         if (!$purchaseOrder instanceof PurchaseOrder) {
             throw new Exception('Invalid PurchaseOrder passed in!');
         }
         $comment = trim($param->CallbackParameter->comments);
         $purchaseOrder->addComment(Comments::TYPE_WAREHOUSE, $comment);
         $products = $param->CallbackParameter->products;
         $outStandingOrders = array();
         $invoiceNos = array();
         foreach ($products->matched as $item) {
             $product = Product::get(trim($item->product->id));
             if (!$product instanceof Product) {
                 throw new Exception('Invalid Product passed in!');
             }
             if (isset($item->product->EANcode)) {
                 $EANcode = trim($item->product->EANcode);
                 $productcodes = ProductCode::getAllByCriteria('pro_code.productId = :productId and pro_code.typeId = :typeId', array('productId' => $product->getId(), 'typeId' => ProductCodeType::ID_EAN), true, 1, 1);
                 if (count($productcodes) > 0) {
                     $productcodes[0]->setCode($EANcode)->save();
                 } else {
                     ProductCode::create($product, ProductCodeType::get(ProductCodeType::ID_EAN), $EANcode);
                 }
             }
             if (isset($item->product->UPCcode)) {
                 $UPCcode = trim($item->product->UPCcode);
                 $productcodes = ProductCode::getAllByCriteria('pro_code.productId = :productId and pro_code.typeId = :typeId', array('productId' => $product->getId(), 'typeId' => ProductCodeType::ID_UPC), true, 1, 1);
                 if (sizeof($productcodes)) {
                     $productcodes[0]->setCode($UPCcode)->save();
                 } else {
                     ProductCode::create($product, ProductCodeType::get(ProductCodeType::ID_UPC), $UPCcode);
                 }
             }
             if (isset($item->product->warehouseLocation) && ($locationName = trim($item->product->warehouseLocation)) !== '') {
                 $locs = Location::getAllByCriteria('name = ?', array($locationName), true, 1, 1);
                 $loc = count($locs) > 0 ? $locs[0] : Location::create($locationName, $locationName);
                 $product->addLocation(PreferredLocationType::get(PreferredLocationType::ID_WAREHOUSE), $loc);
             }
             $serials = $item->serial;
             $totalQty = 0;
             foreach ($serials as $serial) {
                 $qty = trim($serial->qty);
                 $totalQty += intval($qty);
                 $serialNo = trim($serial->serialNo);
                 $unitPrice = trim($serial->unitPrice);
                 $invoiceNo = trim($serial->invoiceNo);
                 $invoiceNos[] = $invoiceNo;
                 $comments = trim($serial->comments);
                 ReceivingItem::create($purchaseOrder, $product, $unitPrice, $qty, $serialNo, $invoiceNo, $comments);
             }
             OrderItem::getQuery()->eagerLoad('OrderItem.order', 'inner join', 'ord', 'ord.id = ord_item.orderId and ord.active = 1 and ord.type = :ordType and ord_item.productId = :productId and ord.statusId in ( :statusId1, :statusId2, :statusId3)');
             $orderItems = OrderItem::getAllByCriteria('ord_item.active = 1', array('ordType' => Order::TYPE_INVOICE, 'productId' => $product->getId(), 'statusId1' => OrderStatus::ID_INSUFFICIENT_STOCK, 'statusId2' => OrderStatus::ID_ETA, 'statusId3' => OrderStatus::ID_STOCK_CHECKED_BY_PURCHASING));
             if (count($orderItems) > 0) {
                 $orders = array();
                 foreach ($orderItems as $orderItem) {
                     if (!array_key_exists($orderItem->getOrder()->getId(), $orders)) {
                         $orders[$orderItem->getOrder()->getId()] = $orderItem->getOrder()->getJson();
                     }
                 }
                 $outStandingOrders[$product->getId()] = array('product' => $product->getJson(), 'recievedQty' => $totalQty, 'outStandingOrders' => array_values($orders));
             }
         }
         $results['outStandingOrders'] = count($outStandingOrders) > 0 ? array_values($outStandingOrders) : array();
         $results['item'] = PurchaseOrder::get($purchaseOrder->getId())->getJson();
         $invoiceNos = array_unique($invoiceNos);
         $results['invoiceNos'] = $invoiceNos;
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:87,代码来源:ReceivingController.php


注:本文中的Location::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。