本文整理汇总了PHP中Address::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::find方法的具体用法?PHP Address::find怎么用?PHP Address::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::find方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHtmlByOutlet
public static function getHtmlByOutlet($addressId)
{
$address = Address::find($addressId);
if (!empty($address)) {
return Address::where('city_id', $address->city_id)->lists('address', 'id');
}
return null;
}
示例2: getData
/**
* Show a list of all the users formatted for Datatables.
*
* @return Datatables JSON
*/
public function getData()
{
$Model = $this->modelName;
$models = $Model::select($this->dataTableColumns);
$actions = ['<a href="{{{ URL::to(\'iframe\') }}}"
data-action="edit"
data-type="' . $this->name . '"
data-id="{{ $id }}"
data-url="{{{ URL::to(\'' . $this->name . '/\' . $id . \'/edit\' ) }}}"
class="iframe btn btn-xs btn-default">{{{ Lang::get(\'button.edit\') }}}</a>', '<a href="{{{ URL::to(\'' . $this->name . '/\' . $id . \'/delete\' ) }}}" class="modal-popup btn btn-xs btn-danger">{{{ Lang::get(\'button.delete\') }}}</a>'];
return Datatables::of($models)->add_column('country', function ($row) {
return Address::find($row->address_id)->country->name;
})->add_column('actions', implode(' ', $actions))->remove_column('id')->remove_column('address_id')->make();
}
示例3: test_getById
public function test_getById()
{
//$this->faker->addProvider(new Faker\Provider\Internet($this->faker));
//$p=$this->faker->password;
return;
$customer = $this->service->getById(1);
$this->assertNotNull($customer);
$customer->load('defaultAddress.country', 'defaultAddress.zone', 'addresses.country', 'addresses.zone');
$sql = $customer->addresses()->toSql();
$sql = $customer->defaultAddress()->toSql();
$this->assertEquals(1, $customer->addresses->count());
$this->assertNotNull($customer->defaultAddress);
$address = Address::find($customer->defaultAddress->id);
$sql = $address->customer()->toSql();
$this->assertNotNull($address->customer);
}
示例4: postConfigSave
public function postConfigSave()
{
if (Payment::VeryPayment() == false) {
return View::make('clinic.payment.renews-payment');
}
$data = array("name" => Input::get("name"), "insurance" => Input::get("insurance"), "lang" => Input::get("lang"), "picture" => Input::file("picture"), "phone" => Input::get("phone"));
$rules = array("name" => 'required|min:1|max:255', "insurance" => 'required|min:1|max:255', "lang" => 'required|min:1|max:10', "picture" => 'mimes:jpeg,gif,png', "phone" => 'required|numeric|min:1');
$messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen :attribute debe ser jpg, git, png');
$validation = Validator::make(Input::all(), $rules, $messages);
//si la validación falla redirigimos al formulario de registro con los errores
//y con los campos que nos habia llenado el usuario
if ($validation->fails()) {
return Redirect::to('/clinic/config-data/')->withErrors($validation)->withInput();
} else {
$id = Input::get("id");
$clinic = Clinic::find($id);
$clinic->name = Input::get("name");
$clinic->phone = Input::get("phone");
$clinic->insurances = Input::get("insurance");
if (Input::file('picture') != NULL) {
//agrega imagen de logo
$file_logo = Input::file('picture');
$ext = Input::file('picture')->getClientOriginalExtension();
$nameIMG = date('YmdHis');
$logo = $nameIMG . '.' . $ext;
$logo = 'assets/clinic/images/logo/logo_' . $logo;
$file_logo->move("assets/clinic/images/logo/", $logo);
$clinic->picture = $logo;
}
$clinic->save();
$adress = Address::find($clinic->address_id);
$adress->my_address = Input::get("address");
$adress->save();
$lang = Option::where('name', $clinic->id . '-clinic-lang')->first();
if ($lang) {
$lang->key = Input::get("lang");
$lang->save();
} else {
$langadd = new Option();
$langadd->key = Input::get("lang");
$langadd->name = $clinic->id . '-clinic-lang';
$langadd->save();
}
return Redirect::back();
}
}
示例5: index
/**
* Display a listing of people
*
* @return Response
*/
public function index()
{
$person = Person::create(array('name' => 'Sharad'));
$inputAddress = array(array('name' => 'Thamel'), array('name' => 'Thahity'));
$addressIds = array();
foreach ($inputAddress as $id => $addressData) {
$address = Address::find($id) ?: new Address();
$address->fill($addressData);
$address->save();
$addressIds[] = $address->id;
}
$changes = $person->addresses()->sync($addressIds);
// Delete the unused addresses
/*foreach ($changes['detached'] as $detachedAddressId)
{
$address = Address::find($detachedAddressId);
if (!empty($address)) $address->delete();
}
*/
}
示例6: QualifyingCirculation
function client_print_for_approval()
{
$qualifying_circulation_id = $this->params['named']['qualifying_circulation_id'];
$printing_centers = $this->Session->read('Auth.PrintingCenter');
$printing_center_ids = Set::extract('/id', $printing_centers);
App::import('Model', 'QualifyingCirculation');
$QualifyingCirculation = new QualifyingCirculation();
$options = array('conditions' => array('QualifyingCirculation.id' => $qualifying_circulation_id, 'QualifyingCirculation.printing_center_id' => $printing_center_ids));
$qualifyingCirculation = $QualifyingCirculation->find('first', $options);
App::import('Model', 'Address');
$objAddress = new Address();
$options = array('conditions' => array('Address.id' => $qualifyingCirculation['DuplicateCopy']['0']['address_id']));
$addr = $objAddress->find('first', $options);
$qualifyingCirculation['DuplicateCopy'][0]['Address'] = $addr['Address'];
$qualifyingCirculation['DuplicateCopy'][0]['City'] = $addr['City'];
$qualifyingCirculation['DuplicateCopy'][0]['State'] = $addr['State'];
$qualifyingCirculation['DuplicateCopy'][0]['Zone'] = $addr['Zone'];
$qualifyingCirculation['DuplicateCopy'][0]['Country'] = $addr['Country'];
// Printing Center Details
App::import('Model', 'PrintingCenter');
$objPrintingCenter = new PrintingCenter();
$optionsPrintingCenter = array('contain' => array('Address', 'Membership', 'PrintedAt', 'Membership.Publication', 'Membership.Edition'), 'conditions' => array('PrintingCenter.id' => $qualifyingCirculation['PrintingCenter']['id']));
$printingCenter = $objPrintingCenter->find('first', $optionsPrintingCenter);
unset($qualifyingCirculation['PrintingCenter']['PrintingCenter']);
unset($qualifyingCirculation['PrintingCenter']['QualifyingCirculation']);
unset($qualifyingCirculation['PrintingCenter']['CreatedBy']);
unset($qualifyingCirculation['PrintingCenter']['ModifiedBy']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['User']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['Address']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['Proposer1Representative']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['Proposer2Representative']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['CreatedBy']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['ModifiedBy']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['MembershipPayment']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['PrintingCenter']);
unset($qualifyingCirculation['PrintingCenter']['Membership']['Representative']);
// HoldingCompany.Address
App::import('Model', 'HoldingCompany');
$objHoldingCompany = new HoldingCompany();
$optionsHoldingCompany = array('contain' => array('Address'), 'conditions' => array('HoldingCompany.id' => $printingCenter['Membership']['HoldingCompany'][0]['id']));
$holdingCompany = $objHoldingCompany->find('first', $optionsHoldingCompany);
// PrintingCenterAuditorBranch
App::import('Model', 'PrintingCenterAuditorBranch');
$objPrintingCenterAuditorBranch = new PrintingCenterAuditorBranch();
$optionsPrintingCenterAuditorBranch = array('contain' => array('AuditorBranch', 'AuditorBranch.AuditorFirm'), 'conditions' => array('PrintingCenterAuditorBranch.printing_center_id' => $printingCenter['PrintingCenter']['id'], 'PrintingCenterAuditorBranch.regular_period_id' => $qualifyingCirculation['QualifyingCirculation']['regular_period_id']));
$printingCenterAuditorBranch = $objPrintingCenterAuditorBranch->find('first', $optionsPrintingCenterAuditorBranch);
$options = array('conditions' => array('Address.id' => $printingCenterAuditorBranch['AuditorBranch']['Address']['id']), 'contain' => array('Country', 'Zone', 'State', 'District', 'City'));
$addr = $objAddress->find('first', $options);
$printingCenterAuditorBranch['AuditorBranch']['Address'] = $addr['Address'];
$printingCenterAuditorBranch['AuditorBranch']['Address']['Country'] = $addr['Country'];
$printingCenterAuditorBranch['AuditorBranch']['Address']['Zone'] = $addr['Zone'];
$printingCenterAuditorBranch['AuditorBranch']['Address']['State'] = $addr['State'];
$printingCenterAuditorBranch['AuditorBranch']['Address']['District'] = $addr['District'];
$printingCenterAuditorBranch['AuditorBranch']['Address']['City'] = $addr['City'];
App::import('Model', 'SaleType');
App::import('Model', 'TradeTerm');
$SaleType = new SaleType();
$TradeTerm = new TradeTerm();
$saleTypes = $SaleType->find('list');
$subscriptionTypes = $TradeTerm->SubscriptionType->find('list');
App::import('Model', 'City');
$objCities = new City();
$cities = $objCities->find('all', array('conditions' => array('City.id' => Set::extract('/city_id', $qualifyingCirculation['WhiteForm']))));
$this->set(compact('saleTypes', 'subscriptionTypes', 'qualifyingCirculation', 'cities', 'printingCenter', 'holdingCompany', 'printingCenterAuditorBranch'));
}
示例7: editAddress
/**
* Show the form for editing the specified country.
*
* @param int $id
* @return Response
*/
public function editAddress($id)
{
$address = Address::find($id);
if (!empty($address)) {
$countries = array('' => '') + Country::lists('country', 'id');
$cities = array('' => '') + City::lists('city', 'id');
// Title
$title = Lang::get('site/addresses/title.address_update');
// mode
$mode = 'edit';
return View::make('site/addresses/create_edit', compact('title', 'mode', 'countries', 'cities', 'address'));
} else {
return Redirect::to('site/addresses')->with('error', Lang::get('site/addresses/messages.does_not_exist'));
}
}
示例8: listAddresses
public function listAddresses($ref_id, $ref_type)
{
App::uses("Address", "Model");
$address = new Address();
return $address->find("all", array('conditions' => array('id !=' => $current_item_id)));
}
示例9: edit
/**
* Show the form for editing the specified address.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$address = Address::find($id);
return View::make('addresses.edit', compact('address'));
}
示例10: getEdit
public function getEdit($id)
{
$item = Item::find($id);
$document = Item::find($id)->document();
$type = $item->document->os_type;
switch ($type) {
case 'movables' || 'value_movables':
$variable = Item::find($id)->variable();
return View::make('items.edit', array('item' => $item, 'document' => $document, 'variable' => $variable));
break;
case 'car':
$variable = Item::find($id)->variable();
$car = Car::find($id)->car();
return View::make('items.edit', array('item' => $item, 'document' => $document, 'variable' => $variable, 'car' => $car));
break;
case 'buildings':
$variable = Item::find($id)->variable();
$building = Item::find($id)->building();
$address = Address::find($id)->address();
return View::make('items.edit', array('item' => $item, 'document' => $document, 'building' => $building, 'variable' => $variable, 'address' => $address));
break;
case 'parcels':
$parcel = Item::find($id)->parcel();
$address = Address::find($id)->address();
return View::make('items.edit', array('item' => $item, 'document' => $document, 'parcel' => $parcel, 'address' => $address));
break;
}
}
示例11: QualifyingCirculation
function _setQualifyingCirculation($printing_center_id, $regularPeriodId)
{
App::import('Model', 'QualifyingCirculation');
$QualifyingCirculation = new QualifyingCirculation();
$options = array('conditions' => array('QualifyingCirculation.printing_center_id' => $printing_center_id, 'QualifyingCirculation.regular_period_id' => $regularPeriodId));
$qualifyingCirculation = $QualifyingCirculation->find('first', $options);
App::import('Model', 'Address');
$objAddress = new Address();
if (!empty($qualifyingCirculation['DuplicateCopy'])) {
$options = array('conditions' => array('Address.id' => $qualifyingCirculation['DuplicateCopy']['0']['address_id']));
$addr = $objAddress->find('first', $options);
$qualifyingCirculation['DuplicateCopy'][0]['Address'] = $addr['Address'];
$qualifyingCirculation['DuplicateCopy'][0]['City'] = $addr['City'];
$qualifyingCirculation['DuplicateCopy'][0]['District'] = $addr['District'];
$qualifyingCirculation['DuplicateCopy'][0]['State'] = $addr['State'];
$qualifyingCirculation['DuplicateCopy'][0]['Zone'] = $addr['Zone'];
$qualifyingCirculation['DuplicateCopy'][0]['Country'] = $addr['Country'];
}
return $qualifyingCirculation;
}
示例12: setFlag
/**
* Set value of a flag. Unsets all other addresses for that user.
* Called by using Addresses::setFlagname($address)
*
* @param mixed $objectOrId primary address id or object instance
*/
private function setFlag($address)
{
if (!is_object($address)) {
$address = Address::find($address);
}
if ($userId = $address->user_id) {
Address::where('user_id', '=', self::userId())->update(array('is_billing' => false));
$address->{'is_billing'} = true;
$address->save();
}
}
示例13: json_encode
$editAddress->complement = $complement;
$editAddress->neighborhood = $neighborhood;
$editAddress->city = $city;
$editAddress->state = $state;
if ($editAddress->save()) {
$data['msg'] = 'Address saved successfully!';
$data['id'] = $editAddress->id;
} else {
$data['msg'] = 'An error occurred while saving the address!';
}
$contactList->response()->header('Content-Type', 'application/json');
echo json_encode($data);
});
// Delete address
$contactList->delete("/addresses/:id", function ($id) use($contactList) {
$address = Address::find($id);
$countAddress = Address::where('contactId', '=', $address->contactId)->count();
if ($countAddress > 1) {
if ($address->delete()) {
$data['msg'] = 'Address deleted successfully!';
} else {
$data['msg'] = 'An error occurred while deleting the address!';
}
} else {
$data['msg'] = 'The contact should have at least one address!';
}
$contactList->response()->header('Content-Type', 'application/json');
echo json_encode($data);
});
// Check email address
$contactList->post("/checkemail", function () use($contactList) {
示例14: postStore
/**
* Store a newly created job in storage.
*
* @return Response
*/
public function postStore()
{
$data = Input::all();
if ($data["job_category_id"] == "none" || intval($data["job_category_id"]) <= 0) {
$data["job_category_id"] = "";
}
//if($data["job_sub_category_id"]=="none"||intval($data["job_sub_category_id"])<=0)
// $data["job_sub_category_id"]=null;
$newAddressRequiredIf = "address_id,==,0";
$rules = array('job_title' => 'required|min:5|max:150', 'job_description' => 'required|min:10', 'start_date' => 'required|date', 'address_id' => 'required', 'favorites' => 'requiredIfAttribute:private,==,1', 'latitude' => 'requiredIfAttribute:' . $newAddressRequiredIf, 'address1' => 'requiredIfAttribute:' . $newAddressRequiredIf, 'city' => 'requiredIfAttribute:' . $newAddressRequiredIf, 'state' => 'requiredIfAttribute:' . $newAddressRequiredIf, 'zipcode' => 'requiredIfAttribute:' . $newAddressRequiredIf, 'company_or_label' => 'requiredIfAttribute:' . $newAddressRequiredIf, 'compensation' => 'required', 'job_category_id' => 'required');
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$data["start_date"] = date("Y-m-d", strtotime($data["start_date"]));
$user = Sentry::getUser();
$employer = Employer::find($user->getId());
$data["user_id"] = $user->id;
$data['job_status_id'] = $employer->subscription != null && $employer->subscription->activeSubscription() ? JobStatus::$OPEN : JobStatus::$DRAFT;
if ($data["address_id"] <= 0) {
$data["is_primary"] = false;
$data["address_type_id"] = AddressType::$OTHER;
$address = Address::Create($data);
$data["address_id"] = $address->id;
} else {
$address = Address::find($data["address_id"]);
$data['company_or_label'] = $address->company_or_label;
$data['address1'] = $address->address1;
$data['address2'] = $address->address2;
$data['state'] = $address->state;
$data['city'] = $address->city;
$data['zipcode'] = $address->zipcode;
$data['latitude'] = $address->latitude;
$data['longitude'] = $address->longitude;
/* $data=array_merge($data,$address);
if(trim($address['company_or_label'])=='')
$data['company_or_label']='';*/
}
//var_dump($data);
$data['job_description'] = strip_tags($data['job_description']);
if ($data['private']) {
if ($data['job_status_id'] != JobStatus::$DRAFT) {
$data['job_status_id'] = JobStatus::$PRIVATE;
}
}
$job = Job::create($data);
if ($data['private']) {
foreach ($data['favorites'] as $fav) {
JobFavorite::create(array('user_id' => $fav, 'job_id' => $job->id));
if ($data['job_status_id'] != JobStatus::$DRAFT) {
$user = User::find($fav);
$this->NotifyFavorite($user, $job);
}
}
}
if (isset($data['job_certification'])) {
foreach ($data['job_certification'] as $cert) {
JobCertification::create(array('job_id' => $job->id, 'certification_id' => $cert));
}
}
/*$studentAddresses=Address::join('users_groups','users_groups.user_id','=','addresses.user_id')
->join('user_notifications','user_notifications.user_id','=','addresses.user_id')
->where('user_notifications.notification_type','=',NotificationType::$EDUEMAIL)
->where('users_groups.group_id','=',Group::$STUDENT)
->select('addresses.user_id',Address::distanceSelectStatement($data['latitude'],$data['longitude'],'distance','addresses'))
->groupBy('student_job_preferences.user_id')
->having("distance","<=",50)
->get();
$studentProfiles=StudentProfile::join('student_job_preferences', 'student_job_preferences.user_id','=','student_profile.user_id')
->where('student_job_preferences.job_category_id','=',$data["job_category_id"])
->whereIn('student_job_preferences.user_id',$studentAddresses->lists('user_id'))
->groupBy('student_job_preferences.user_id')
->get();
$studentProfiles->load('user');
var_dump($studentProfiles);
*/
if ($data['job_status_id'] == JobStatus::$OPEN) {
//return Redirect::action("JobsController@anyShow", array("id"=>$job->id));
return Redirect::action("JobsController@anyEmployerOpen");
} else {
return Redirect::action("EmployerController@anySubscription");
}
}