本文整理汇总了PHP中app\Address::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::where方法的具体用法?PHP Address::where怎么用?PHP Address::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Address
的用法示例。
在下文中一共展示了Address::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: usage
/**
* Check whether a user is using an address
* @param $address_id
* @param $user_id
* @return int
*/
public function usage($address_id, $user_id)
{
if ($this->usage->where('address_id', '=', $address_id)->where('user', '=', $user_id)->first()) {
return 1;
}
return 0;
}
示例2: meta
/**
* @return $this
*/
public function meta()
{
$img_url = 'http://d14d0ey1pb5ifb.cloudfront.net/';
$property = \App\Property::where(['meta_set' => 0, 'status' => '1'])->orderBy('package', 'DESC')->first();
$address = \App\Address::where(['property_id' => $property->property_id])->first();
$images = \App\Image::where(['property_id' => $property->property_id])->orderBy('pos', 'ASC')->get();
return view('dashboard.meta')->with(compact(['property', 'address', 'images', 'img_url']));
}
示例3: retrieveOrCreate
/**
* attempts to find a matching address before creating a new instance
*/
public static function retrieveOrCreate(array $attributes = [])
{
// TODO: look up address attributes to find a match
$existing_addr = Address::where('street', $attributes['street'])->where('city', $attributes['city'])->where('state', $attributes['state'])->where('zip1', $attributes['zip1'])->first();
if ($existing_addr) {
return $existing_addr;
}
return Address::create($attributes);
}
示例4: getIndex
public function getIndex(Request $request)
{
$address = \App\Address::where('user_id', '=', \Auth::id())->get()->first();
if (is_null($address)) {
\Session::flash('flash_message', 'Please create an address for your account');
return redirect('addresses/create');
}
$accounts = \App\Account::where('user_id', '=', \Auth::id())->orderBy('id', 'ASC')->get();
return view('account.index')->with('accounts', $accounts);
}
示例5: getEdit
public function getEdit($id = null)
{
$address = \App\Address::where('user_id', '=', \Auth::id())->get()->first();
if (is_null($address)) {
\Session::flash('flash_message', 'Address not found');
return redirect('addresses/create');
}
$stateModel = new \App\State();
$states_for_dropdown = $stateModel->getStatesForDropdown();
return view('address.edit')->with('address', $address)->with(['states_for_dropdown' => $states_for_dropdown]);
}
示例6: addresses
public function addresses($location, $sub_location)
{
/*
$addresses = Address::where('location_id', $location)
->where('sub_location_id',$sub_location)
->lists('name_eng', 'id');
*/
$addresses = Address::where('location_id', $location)->where('sub_location_id', $sub_location)->get()->map(function ($key) {
return ['text' => $key->name_eng, 'value' => $key->id];
})->toArray();
return $addresses;
}
示例7: anyEntry
public function anyEntry(Request $request, $id = null)
{
if (isset($id) && $id != null) {
$company = Company::find($id);
if ($company != null) {
session(['current_company' => $company->id]);
} else {
return redirect('companies');
}
} else {
$id = session('current_company') !== null ? session('current_company') : 0;
$address_id = session('current_address') !== null ? session('current_address') : 0;
if ($id) {
$company = Company::find($id);
session(["current_company" => $company->id]);
} else {
$company = Company::get()->last();
if ($company) {
session(["current_company" => $company->id]);
} else {
$company = new Company();
$company->save();
session(['current_company' => $company->id]);
}
}
}
$address = Address::where('module_id', '=', $company->id)->where('module_type', '=', 'App\\Company')->first();
$address_province = isset($address->province_id) ? $address->province_id : 0;
$country_province = Province::addSelect('provinces.name as province_name')->where('provinces.id', '=', $address_province)->addSelect('countries.name as country_name')->leftJoin('countries', 'countries.id', '=', 'provinces.country_id')->first();
if ($country_province) {
$country_province->toArray();
$company['province_name'] = $country_province['province_name'];
$company['country_name'] = $country_province['country_name'];
} else {
$company['province_name'] = '';
$company['country_name'] = '';
}
$countries = array();
$company_type = array();
$countries = Country::with('provinces')->get()->toArray();
$company_type = CompanyType::get()->toArray();
$company->toArray();
$this->layout->content = view('company.entry', ['company' => $company, 'address' => $address, 'countries' => $countries, 'company_type' => $company_type]);
}
示例8: handleCreateMailType
public function handleCreateMailType()
{
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Reduce Credit before approve email
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$receiver_address = Address::where('id', Request::get('receiver_address_id'))->first();
if (!$receiver_address || $receiver_address->user_id != Auth::user()->id) {
return redirect('home')->with("error", "มีบางอย่างผิดพลาด");
}
$mail_type = DB::table('mailtypes')->where('id', Request::get('mail_type_id'))->first();
if ($mail_type->price > Auth::user()->credits) {
return redirect('home')->with('error', 'เครดิตของคุณไม่เพียงพอ');
}
$mail = new Mail();
$mail->user_id = Auth::user()->id;
$mail->mail_type_id = Request::get('mail_type_id');
$mail->content = Request::get('content');
$mail->receiver_name = $receiver_address->name;
$mail->receiver_address_line_1 = $receiver_address->address_line_1;
$mail->receiver_address_line_2 = $receiver_address->address_line_2;
$mail->receiver_address_line_3 = $receiver_address->address_line_3;
$mail->receiver_postcode = $receiver_address->postcode;
$mail->status = 0;
if (Request::get('sender_address_id') != 0) {
$sender_address = Address::where('id', Request::get('sender_address_id'))->first();
if (!$sender_address || $sender_address->user_id != Auth::user()->id || $sender_address->is_sender == false) {
return redirect('home')->with("error", "มีบางอย่างผิดพลาด Test");
}
$mail->sender_name = $sender_address->name;
$mail->sender_address_line_1 = $sender_address->address_line_1;
$mail->sender_address_line_2 = $sender_address->address_line_2;
$mail->sender_address_line_3 = $sender_address->address_line_3;
$mail->sender_postcode = $sender_address->postcode;
}
$mail->save();
$User = User::find(Auth::user()->id);
$User->credits -= $mail_type->price;
$User->save();
return redirect('home')->with("msg", "บันทึกจดหมายของท่านแล้ว");
}
示例9: edit
public function edit(Request $request)
{
$user = Auth::user();
$account = $request->only('user');
$info = $request->except('user', 'other_address', 'email', '_token');
$user->update($account['user']);
$user->info()->update($info);
if ($request->has('other_address') and $user->is('legal')) {
$addresses = $request->input('other_address');
$address_ids = [];
foreach ($addresses as $address) {
if (!empty($address)) {
$item = $user->addresses()->create(['address' => $address]);
$address_ids[] = $item->id;
}
}
Address::where('user_id', $user->id)->whereNotIn('id', $address_ids)->delete();
}
$input = $request->all();
$input['city'] = $user->info->city;
$input['province'] = $user->info->province;
return ['hasCallback' => '1', 'callback' => 'user_info', 'hasMsg' => '1', 'msg' => 'data inserted successfully', 'returns' => $input];
}
示例10: getUpdatePaymentAddressCustomer
public function getUpdatePaymentAddressCustomer()
{
View::share(['navigator' => \NavigatorHelper::getNavigatorBarFE(), 'sideBar' => \NavigatorHelper::getSideBarFE()]);
if (!Session::has('user')) {
return redirect_errors('You login yet!');
}
$user = Session::get('user');
if ($user['role_id'] != Role::CUS_ROLE_ID) {
return redirect_errors('You are not Customer!');
}
$customer = new Customer();
$cusInfo = $customer->with('user')->where('user_id', $user['id'])->first()->toArray();
$current_City = Address::find($cusInfo['city_id'])->id;
$cities = Address::where('parent_id', 0)->get()->toArray();
$state = Address::find($cusInfo['state_id'])->toArray();
return view('change_payment_address.index')->with(['info' => $cusInfo, 'currentCity' => $current_City, 'cities' => $cities, 'state' => $state]);
}
示例11: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$user = Auth::user();
$addresses = Address::where(['customer_id' => $user->id])->get();
return view('dashboard.customer.addressList', ['addresses' => $addresses]);
}
示例12: checkOutResume
/**
* Starts the checkout process.
*
* @param int $addressId The address id selected to be copied
* @return Response
*/
public function checkOutResume($addressId)
{
$user = \Auth::user();
$cart = Order::ofType('cart')->with('details')->where('user_id', $user->id)->first();
$cartDetail = OrderDetail::where('order_id', $cart->id)->get();
$address = Address::find($addressId);
$totalAmount = 0;
$totalItems = 0;
//Checks if the user selected an address that belongs to him/her
$userAddress = Address::where('user_id', $user->id)->where('id', $address->id)->first();
if ($userAddress) {
//Checks if the user has points for the cart price and the store has stock
$total_points = 0;
foreach ($cartDetail as $orderDetail) {
$product = Product::find($orderDetail->product_id);
$totalItems += $orderDetail->quantity;
$totalAmount += $orderDetail->quantity * $orderDetail->price;
if ($product->stock < $orderDetail->quantity) {
return redirect()->route('orders.show_cart')->withErrors(array('main_error' => array(trans('store.insufficientStock'))));
}
}
//Checks if the user has points for the cart price
if ($user->current_points < $total_points && config('app.payment_method') == 'Points') {
return redirect()->route('orders.show_cart')->withErrors(array('main_error' => array(trans('store.cart_view.insufficient_funds'))));
} else {
//Copies the Address to a new one and attaches it to the order or replaces the old one
$cartAddress = Address::find($cart->address_id);
if (!$cartAddress) {
//if the order does not has an address yet
$newAddress = new Address();
$newAddress->line1 = $address->line1;
$newAddress->line2 = $address->line2;
$newAddress->phone = $address->phone;
$newAddress->name_contact = $address->name_contact;
$newAddress->zipcode = $address->zipcode;
$newAddress->city = $address->city;
$newAddress->country = $address->country;
$newAddress->state = $address->state;
$newAddress->save();
$cart->address_id = $newAddress->id;
$cart->save();
$cartAddress = $newAddress;
} else {
//if the order needs to be updated
$cartAddress->line1 = $address->line1;
$cartAddress->line2 = $address->line2;
$cartAddress->phone = $address->phone;
$cartAddress->name_contact = $address->name_contact;
$cartAddress->zipcode = $address->zipcode;
$cartAddress->city = $address->city;
$cartAddress->country = $address->country;
$cartAddress->state = $address->state;
$cartAddress->save();
}
$panel = array('center' => ['width' => '12']);
//Sets the resume option to use the same view
$isResume = true;
$is_logged = true;
return view('orders.cart', compact('cart', 'user', 'panel', 'isResume', 'cartAddress', 'totalItems', 'totalAmount'));
}
} else {
return redirect()->route('orders.show_cart')->withErrors(array('main_error' => array(trans('store.errorOnAddress'))));
}
}
示例13: saveAddress
public function saveAddress(Request $request, $territoryId = null, $addressId = null)
{
if (!$this->hasAccess($request)) {
return Response()->json(['error' => 'Access denied.'], 500);
}
if (empty($territoryId)) {
return ['error' => 'Territory not found', 'message' => 'Territory not found'];
}
if (Gate::denies('update-addresses')) {
return Response()->json(['error' => 'Method not allowed'], 403);
}
if (!empty($addressId)) {
try {
$newAddress = $this->unTransform($request->all(), 'address');
$address = Address::findOrFail($addressId);
$street = Street::findOrFail($address->street_id)->first();
// if(!$street->is_apt_building)
// $newAddress['lat'] = 0;
$data = $address->update($newAddress);
} catch (Exception $e) {
$data = ['error' => 'Address not updated', 'message' => $e->getMessage()];
}
} else {
// dd($request->all());
// dd($this->unTransform($request->all(), 'address'));
try {
// return ['data' => ['street_street' => empty($request->input('street_street')), 'all' => $request->all()]];
$transformedData = $this->unTransform($request->all(), 'address');
if (!empty($request->input('street_street'))) {
$transformedData['street'] = [['street' => $request->input('street_street'), 'isAptBuilding' => $request->input('street_isAptBuilding')]];
}
// return ['data' => $transformedData];
$territory = Territory::findOrFail($territoryId);
if (!empty($transformedData['street'])) {
$street = Street::where('street', $transformedData['street'][0]['street'])->first();
if (empty($street)) {
$street = Street::create($transformedData['street'][0]);
}
// $addressWithStreet = ($address && $street) ? $address->street()->associate($street) : $address;
$transformedData['street_id'] = $street ? $street->id : null;
}
$address = Address::where(['address' => $transformedData['address'], 'street_id' => $transformedData['street_id'], 'apt' => !empty($transformedData['apt']) ? $transformedData['apt'] : ''])->first();
// Address alredy exist?
if (!empty($address)) {
// If inactive, make it active
// dd($address);
if ($address['inactive']) {
$address['inactive'] = 0;
$data = $address->update(['inactive', $address['inactive']]);
}
// If in another territory?
if ($territoryId != $address->territory_id) {
$territoryBelongs = Territory::findOrFail($address->territory_id);
// Error: "This address belongs to territory number []"
return Response()->json(['error' => 'This address belongs to territory ' . $territoryBelongs->number . '. Please contact Admin about moving this address.', 'data' => ''], 202);
} else {
return Response()->json(['error' => 'This address already exists in this territory.', 'data' => ''], 202);
}
} else {
$address = !empty($territory) ? $territory->addresses()->create($transformedData) : null;
}
$data = $address && !empty($transformedData['notes']) ? $address->notes()->create($transformedData['notes'][0]) : $address;
} catch (Exception $e) {
$data = ['error' => 'Address not added', 'message' => $e->getMessage()];
// {"error":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '200-23' for key 'addresses_address_street_id_unique' (SQL: insert into `addresses` (`name`, `address`, `street_id`, `territory_id`, `updated_at`, `created_at`) values (Jean Marc, 200, 23, 34, 2016-01-14 18:36:49, 2016-01-14 18:36:49))"}
}
}
return ['data' => $data];
}
示例14: function
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/protected-resource', ['middleware' => 'oauth', function () {
$usage = \App\Usage::where('user_id', '=', \Auth::user()->id)->where('usageActivity', '=', 1)->first()->address_id;
$address = \App\Address::where('id', '=', $usage)->first()->address;
//return Response::json(['address' => $address]);
//return redirect()->route('shelves', ['address' => $address]);
return Redirect::to('http://localhost:34000/locate/import?address=' . $address);
}]);
Route::get('/shelves', ['as' => 'shelves'], function () {
return redirect('http://localhost:34000/cart/cart');
});
Route::get('oauth/authorize', ['as' => 'oauth.authorize.get', 'middleware' => ['check-authorization-params', 'auth'], function () {
// display a form where the user can authorize the client to access it's data
$authParams = Authorizer::getAuthCodeRequestParams();
$formParams = array_except($authParams, 'client');
$formParams['client_id'] = $authParams['client']->getId();
return View::make('oauth.authorization_form', ['params' => $formParams, 'client' => $authParams['client']]);
}]);
Route::post('oauth/authorize', ['as' => 'oauth.authorize.post', 'middleware' => ['csrf', 'check-authorization-params', 'auth'], function () {
示例15: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(BusinessRegRequest $request, $id)
{
$biz = Biz::findorFail($id);
$biz->name = $request->input('name');
$biz->contactname = $request->input('contactname');
$biz->email = $request->input('email');
$biz->website = $request->input('website');
$biz->phone1 = $request->input('phone1');
$biz->phone2 = $request->input('phone2');
$biz->user_id = \Auth::id();
$biz->save();
$add = Address::where('biz_id', $biz->id)->first();
$add->street = $request->input('address');
$add->lga_id = $request->input('lga');
$add->state_id = $request->input('state');
$add->save();
$category = $request->input('cats');
// $catNames= [];
// $biz->cats()->delete();
/* foreach ($category as $cat) {
if( $existingCat = Cat::where('name', $cat)->first()) {
$catNames[]= $existingCat;
}
else{
$newCat = new Cat();
$newCat ->name = $cat;
$newCat->save();
$catNames[]=$newCat;
}
}
$biz->cats()->saveMany($catNames); */
$biz->cats()->sync($category);
$subs = $request->input('sub');
// $real= [];
// $biz->subcats()->delete();
/* foreach ($subs as $sub) {
if( $existingSub = SubCat::where('name', $sub)->first()) {
$real[]= $existingSub;
}
else{
$newSub = new SubCat();
$newSub ->name = $sub;
$newCat->save();
$real[]=$newSub;
}
}
$biz->subcats()->saveMany($real); */
$biz->subcats()->sync($subs);
return redirect("/admin/biz/")->withSuccess("Changes Updated");
}