本文整理汇总了PHP中Country::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::where方法的具体用法?PHP Country::where怎么用?PHP Country::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPostPage
public function getPostPage()
{
$obj = new BaseController();
$campusid = $this->getDevice();
if ($campusid == 0) {
$countryname = $obj->getCountryName();
if ($countryname == 'NONE') {
return Redirect::route('selectcampus-get');
} else {
//check whether the country name exists inthe db
$locationcountry = Country::where('name', '=', $countryname);
if ($locationcountry->count()) {
$locationcountrycode = $locationcountry->first()->code;
$locationcountrycode = strtolower($locationcountrycode);
return Redirect::route('selectcountryid', $locationcountrycode);
} else {
return Redirect::route('selectcampus-get');
}
}
}
$college = Institution::whereHas('Branch', function ($query) use($campusid) {
$query->where('id', '=', $campusid);
})->first();
View::share('college', $college);
$mycampus = Branch::where('id', '=', $campusid)->first();
View::share('mycampus', $mycampus);
if (Auth::user()) {
return View::make('member.post');
}
return View::make('guest.post');
}
示例2: saveModel
protected function saveModel($airport = false)
{
if (Input::get('id')) {
$airport = Airport::find(Input::get('id'));
}
if (!$airport) {
$airport = new Airport();
}
$airport->name = Input::get('name');
$address = $airport->address()->first() ?: new Address();
$country = Country::where('name', Input::get('country'))->first();
$address->country()->associate($country);
$address->address = Input::get('address_address');
$address->postal_code = Input::get('address_postal_code');
$address->city = Input::get('address_city');
$address->state_province = Input::get('address_state_province');
$address->phone = Input::get('address_phone');
$address->fax = Input::get('address_fax');
$address->email = Input::get('address_email');
$address->website = Input::get('address_website');
$address->save();
$airport->address()->associate($address);
$hotel->save();
return $airport;
}
示例3: updateWineryDetail
public static function updateWineryDetail($id, $input)
{
$winery = Winery::where('id', $id)->first();
$error_code = ApiResponse::OK;
if ($winery) {
if (!empty($input)) {
if (!empty($input['brand_name'])) {
$winery->brand_name = $input['brand_name'];
}
if (!empty($input['country_id'])) {
if (Country::where('id', $input['country_id'])->first()) {
$winery->country_id = $input['country_id'];
} else {
$winery->country_id = null;
}
}
if (!empty($input['region'])) {
$winery->region = $input['region'];
}
if (!empty($input['description'])) {
$winery->description = $input['description'];
}
$winery->save();
$data = $winery->toArray();
} else {
$error_code = ApiResponse::MISSING_PARAMS;
$data = $input;
}
} else {
$error_code = ApiResponse::UNAVAILABLE_WINERY;
$data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_WINERY);
}
return array("code" => $error_code, "data" => $data);
}
示例4: timeline
public static function timeline()
{
$user_id = Session::get('user_id');
$error_code = ApiResponse::OK;
$user_timeline = array();
$user_timeline[] = $user_id;
$user_follow = Follow::where('from_id', $user_id)->orderBy('updated_at', 'asc')->get();
if (isset($user_follow)) {
foreach ($user_follow as $user) {
$user_timeline[] = $user->to_id;
}
}
$pagination = ApiResponse::pagination();
if ($pagination == false) {
$error_code = ApiResponse::URL_NOT_EXIST;
$data = ApiResponse::getErrorContent(ApiResponse::URL_NOT_EXIST);
} else {
$page = $pagination['page'];
$limit = $pagination['limit'];
$ratings = Rating::whereIn('user_id', $user_timeline)->whereNotNull('wine_unique_id')->with('profile')->with('wine')->orderBy('updated_at', 'desc')->forPage($page, $limit)->get();
if (count($ratings) == 0) {
$data = array();
} else {
foreach ($ratings as $rating) {
$winery = Winery::where('id', $rating->wine->winery_id)->first();
$rating->winery = $winery;
$country = Country::where('id', $rating->winery->country_id)->first();
if ($country) {
$rating->winery->country_name = $country->country_name;
} else {
$rating->winery->country_name = null;
}
$like = Like::where('user_id', $user_id)->where('rating_id', $rating->id)->first();
if ($like) {
$rating->liked = true;
} else {
$rating->liked = false;
}
$wishlist = Wishlist::where('user_id', $user_id)->where('wine_unique_id', $rating->wine_unique_id)->first();
if ($wishlist) {
$rating->wishlist = true;
} else {
$rating->wishlist = false;
}
$rating->wine->image_url = Wine::getImageWineFromServer($user_id, $rating->wine->wine_unique_id, $rating->wine->image_url);
if ($rating->wine->wine_flag != null) {
$rating->wine->wine_flag = URL::asset($rating->wine->wine_flag);
}
if ($rating->profile->image != null) {
$rating->profile->image = URL::asset($rating->profile->image);
}
}
$data = $ratings->toArray();
}
}
return array("code" => $error_code, "data" => $data);
}
示例5: viewNoResult
public function viewNoResult()
{
// Filtering
$country = Country::where('val', 1)->lists('country', 'id');
$city = City::where('val', 1)->lists('city', 'id');
$filter_tours = Tour::where('val', 1)->get();
$filter_cities = City::where('val', 1)->get();
return array('filter_tours' => $filter_tours, 'filter_cities' => $filter_cities, 'country' => $country, 'city' => $city);
}
示例6: run
public function run()
{
// Uncomment the below to wipe the table clean before populating
DB::table('locations')->truncate();
$country = Country::where('name_en', 'Kuwait')->first();
$locations = array(['country_id' => $country->id, 'name_ar' => 'سالمية', 'name_en' => 'Salmiya', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
// Uncomment the below to run the seeder
DB::table('locations')->insert($locations);
}
示例7: saveModel
protected function saveModel($contact = false)
{
if (Input::get('id')) {
$contact = Contact::find(Input::get('id'));
}
if (!$contact) {
$contact = new Contact();
}
$contact->function = Input::get('function');
$contact->first_name = Input::get('first_name');
$contact->last_name = Input::get('last_name');
$contact->references = Input::get('references');
$contact->notes = Input::get('notes');
$address = $contact->address()->first() ?: new Address();
$address_input = Input::get('address');
$country = Country::where('name', Input::get('country'))->first();
if ($country) {
$address->country()->associate($country);
}
$address->address = isset($address_input['address']) ? $address_input['address'] : '';
$address->postal_code = isset($address_input['postal_code']) ? $address_input['postal_code'] : '';
$address->city = isset($address_input['city']) ? $address_input['city'] : '';
$address->state_province = isset($address_input['state_province']) ? $address_input['state_province'] : '';
$address->phone = isset($address_input['phone']) ? $address_input['phone'] : '';
$address->fax = isset($address_input['fax']) ? $address_input['fax'] : '';
$address->email = isset($address_input['email']) ? $address_input['email'] : '';
$address->website = isset($address_input['website']) ? $address_input['website'] : '';
$address->save();
$contact->address()->associate($address);
$contact->save();
$parentQuery = Input::get('parent_model');
if (!empty($parentQuery)) {
$parentModel = null;
switch ($parentQuery) {
case 'events':
$relation = 'events';
$parentModel = 'Events';
break;
case 'company':
$relation = 'companies';
$parentModel = 'Company';
break;
case 'venue':
$relation = 'venues';
$parentModel = 'Venue';
break;
default:
break;
}
if (!empty($parentModel)) {
$contact->{$relation}()->detach($parentModel::find(Input::get('parent_id')));
$contact->{$relation}()->attach($parentModel::find(Input::get('parent_id')));
}
}
return $contact;
}
示例8: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
// Se valida si llega u filtro para consultar, de lo contrario se retorna la lista completa.
if (Input::get(Config::get('constants.QUERY'))) {
$countriesList = Country::where('countryId', 'LIKE', '%' . Input::get(Config::get('constants.QUERY')) . '%')->orWhere('name', 'LIKE', '%' . Input::get(Config::get('constants.QUERY')) . '%')->get();
} else {
$countriesList = Country::all();
}
return $this->respondWithCollection($countriesList, new CountryTransformer());
}
示例9: testGetTimelineSuccess
public function testGetTimelineSuccess()
{
$this->setUpRating();
$this->setUpCountry();
$this->setUpWineNote();
$this->setUpProfile();
$_params = $this->_params;
$_params['user_id'] = "user_id";
$response = $this->_getAuth($_params);
$error_code = ApiResponse::OK;
$user_timeline = array();
$user_timeline[] = $this->_user_id;
$user_follow = Follow::where('from_id', $this->_user_id)->orderBy('updated_at', 'asc')->get();
if (isset($user_follow)) {
foreach ($user_follow as $user) {
$user_timeline[] = $user->to_id;
}
}
$pagination = ApiResponse::pagination();
$page = $pagination['page'];
$limit = $pagination['limit'];
$wine = Wine::with('winery')->forPage($page, $limit)->get();
$ratings = Rating::whereIn('user_id', $user_timeline)->whereNotNull('wine_unique_id')->with('profile')->with('wine')->forPage($page, $limit)->get();
foreach ($ratings as $rating) {
$winery = Winery::where('id', $rating->wine->winery_id)->first();
$rating->winery = $winery;
$country = Country::where('id', $rating->winery->country_id)->first();
$rating->winery->country_name = $country->country_name;
$like = Like::where('user_id', $this->_user_id)->where('rating_id', $rating->id)->first();
if ($like) {
$rating->liked = true;
} else {
$rating->liked = false;
}
$wishlist = Wishlist::where('user_id', $this->_user_id)->where('wine_unique_id', $rating->wine_unique_id)->first();
if ($wishlist) {
$rating->wishlist = true;
} else {
$rating->wishlist = false;
}
if ($rating->wine->image_url != null) {
$rating->wine->image_url = URL::asset($rating->wine->image_url);
}
if ($rating->wine->wine_flag != null) {
$rating->wine->wine_flag = URL::asset($rating->wine->wine_flag);
}
if ($rating->profile->image != null) {
$rating->profile->image = URL::asset($rating->profile->image);
}
$rating->winery = $rating->winery->toArray();
}
$data = $ratings;
$this->assertEquals(array("code" => ApiResponse::OK, "data" => $ratings->toArray()), json_decode($response->getContent(), true));
}
示例10: setCountryAttribute
public function setCountryAttribute($value)
{
if (strlen($value) == 2) {
$this->attributes['country_a2'] = strtoupper($value);
} else {
$operator = \Config::get('database.default') == 'pgsql' ? 'ilike' : 'like';
$country = Country::where('name', $operator, $value)->first();
if ($country) {
$this->attributes['country_a2'] = $country->a2;
}
}
$this->attributes['country_name'] = Addresses::countryName($this->attributes['country_a2']);
}
示例11: boot
public static function boot()
{
parent::boot();
static::saving(function ($address) {
if (config('addressable.geocode')) {
$address->geocode();
}
if (empty($address->country_id)) {
$defaultCountry = config('addressable.default_country');
$country = Country::where('cca2', '=', $defaultCountry)->first(['id']);
$address->country_id = $country->id;
}
});
}
示例12: getProduct
public function getProduct($id)
{
$phones = Product::find($id);
if ($id <= 9) {
$countrys = Country::where('category_id', '=', '1')->get();
$networks = Network::where('category_id', '=', '1')->get();
} elseif ($id <= 12) {
$countrys = Country::where('category_id', '=', '2')->get();
$networks = Network::where('category_id', '=', '2')->get();
} elseif ($id <= 15) {
$countrys = Country::where('category_id', '=', '3')->get();
$networks = Network::where('category_id', '=', '3')->get();
}
return View::make('products.product')->with('phones', $phones)->with('networks', $networks)->with('countrys', $countrys);
}
示例13: show
public function show($id)
{
if (Auth::user()) {
$countryId = Auth::user()->country_id;
} else {
$location = GeoIPFacade::getLocation();
$countryId = Country::where('country_code', '=', $location['isoCode'])->first()->id;
}
$questionCountry = QuestionsCountry::firstOrNew(array('country_id' => $countryId, 'question_id' => $id));
$questionCountry->count++;
$questionCountry->save();
// Get all the blog posts
$question = Question::where('questions.id', '=', $id)->with('answer')->first();
return view('questions.view_question', compact('question'));
}
示例14: postSelectPackage
public function postSelectPackage()
{
//verify the user input and create account
$validator = Validator::make(Input::all(), array('Package' => 'required'));
if ($validator->fails()) {
return Redirect::route('advanced_squeeb-get')->withInput()->with('global', 'Please select a package.');
} else {
$package = Input::get('Package');
View::share('package', $package);
//check for the world package
if ($package == 'pkg1') {
$countries = Country::all();
View::share('countries', $countries);
$obj = new BaseController();
$countryid = 0;
$countryname = $obj->getCountryName();
if ($countryname != 'NONE') {
$locationcountry = Country::where('name', '=', $countryname);
if ($locationcountry->count()) {
$countryid = $locationcountry->first()->id;
$colleges = Institution::where('country_id', '=', $countryid)->get();
View::share('colleges', $colleges);
}
}
View::share('countryid', $countryid);
return View::make('guest.advancedselectcollege');
} else {
if ($package == 'pkg2') {
$countries = Country::all();
View::share('countries', $countries);
$obj = new BaseController();
$countryid = 0;
$countryname = $obj->getCountryName();
if ($countryname != 'NONE') {
$locationcountry = Country::where('name', '=', $countryname);
if ($locationcountry->count()) {
$countryid = $locationcountry->first()->id;
}
}
View::share('countryid', $countryid);
return View::make('guest.advancedpostcountry')->with('msg', 'Country Squeeb Package');
}
}
if ($package == 'pkg3') {
return View::make('guest.advancedpost')->with('msg', 'World Squeeb Package');
}
}
}
示例15: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('territories', function ($table) {
$table->increments('id')->unsigned();
$table->string('name', 25);
$table->string('county', 2);
$table->string('municipality', 2)->nullable();
$country = Country::where('name', 'Sweden')->first();
$table->integer('country_id')->unsigned()->default($country->id);
$table->foreign('country_id')->references('id')->on('countries')->onDelete('CASCADE')->onUpdate('CASCADE');
$table->engine = 'InnoDB';
});
Schema::table('territories', function () {
$sql = file_get_contents(base_path() . '/scripts/db/populate_territory.sql');
DB::statement($sql);
DB::statement('update territories set country_id=(select id from countries where name=\'Sweden\')');
});
}