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


PHP Country::find方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $country = Country::find($request->country_id);
     $city = City::find($request->city_id);
     $state = State::find($request->state_id);
     return ['country' => $country->name, 'city' => $city->name, 'state' => $state->name];
 }
开发者ID:etciberoamerica,项目名称:robotica,代码行数:12,代码来源:CountryController.php

示例2: saveReferees

 public function saveReferees(Season $season, Competition $competition, Request $request)
 {
     $data = $request->all();
     $competition->referees()->wherePivot('season_id', '=', $season->id)->detach();
     $pairs = $this->getPairs($season, $competition);
     foreach ($pairs as $pair) {
         $pair->active = 0;
         $pair->save();
     }
     $response = ['refs' => array(), 'crefs' => array()];
     $country = Country::find($data['country']);
     $refs = json_decode($data['referees'], true);
     foreach ($refs as $ref) {
         $newRef = $competition->storeReferee($ref, $season, 0, $country);
         if (array_key_exists('styled', $ref)) {
             if ($ref['styled'] == 'new') {
                 $newRef['location'] = Location::find($newRef->location_id)->name;
                 array_push($response['refs'], $newRef);
             }
         }
     }
     $crefs = json_decode($data['court_referees'], true);
     foreach ($crefs as $cref) {
         $newRef = $competition->storeReferee($cref, $season, 1, $country);
         if (array_key_exists('styled', $cref)) {
             if ($cref['styled'] == 'new') {
                 $newRef['location'] = Location::find($newRef->location_id)->name;
                 array_push($response['crefs'], $newRef);
             }
         }
     }
     $response['pairs'] = $this->getPairs($season, $competition)->toArray();
     return $response;
 }
开发者ID:dinocata,项目名称:Delegiranje,代码行数:34,代码来源:CompetitionController.php

示例3: create

 public function create(ApplicationRequest $request)
 {
     $services = Service::join('service_visas', 'services.id', '=', 'service_visas.service_id')->select('services.id', 'services.name', 'min_process', 'max_process')->orderBy('min_process')->orderBy('max_process')->where('country_id', '=', $request->get('country'))->groupBy('services.id')->get();
     $service = $services->first();
     $states = DB::table('states')->orderBy('name', 'asc')->lists('name', 'id');
     $countries = Country::orderBy('name')->lists('name', 'id');
     $country = Country::find($request->get('country'));
     return View('apply', ['services' => $services->lists('title', 'id'), 'service' => $service, 'country' => $country, 'countries' => $countries, 'states' => $states]);
 }
开发者ID:zangee3,项目名称:avs,代码行数:9,代码来源:CartController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $country = Country::find($id);
     //return $gender;
     if (count($country) > 0) {
         $statusCode = 200;
         $response = ['id' => $country->id, 'Country' => $country->country];
     } else {
         $response = ["error" => "Country doesn`t exist"];
         $statusCode = 404;
     }
     return response($response, $statusCode)->header('Content-Type', 'application/json');
 }
开发者ID:vinPopulaire,项目名称:SPtool,代码行数:20,代码来源:CountriesApiController.php

示例5: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if ($this->option('all')) {
         foreach (Country::all() as $country) {
             $country->import();
             sleep(5);
         }
     } elseif ($this->argument('country')) {
         $country = Country::find($this->argument('country'));
         if (count($country)) {
             $country->import();
         }
     }
 }
开发者ID:santakani,项目名称:santakani.com,代码行数:19,代码来源:CountryImport.php

示例6: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     if ($request['countryId'] != 0) {
         $retcountry = Country::whereId($request['countryId'])->first();
         if ($retcountry) {
             $country = Country::find($request['countryId']);
             $country->name = $request['name'];
             $country->save();
             Session::flash('message', 'Country Updated Successfully');
         }
     } else {
         $country = new Country();
         $country->name = $request['name'];
         $country->save();
         Session::flash('message', 'Country added Successfully');
     }
     return Redirect::to('country');
 }
开发者ID:premsingh4github,项目名称:recruitment,代码行数:23,代码来源:CountryController.php

示例7: update

 /**
  * Updates the specified User node in the graph
  *
  * @param $name Node 'name' label to match when saving a User
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($name)
 {
     // Get the request params
     $userUpdate = Request::all();
     // Find the matching User node
     $user = User::whereName($name)->first();
     // Find the matching Group with which this User is associated
     $newGroup = Group::find($userUpdate['group']);
     // If we've changed the user group, then detach the existing group
     // relation and create a new relation in its place.
     if ($newGroup['id'] != $user->group->id) {
         $user->group()->detach();
         $user->group()->save($newGroup);
     }
     // Find the matching Country with which this User is associated
     $newCountry = Country::find($userUpdate['country']);
     // Detach the previous nationality relation, and save the new one
     // TODO: don't detach and save unless it's changed!
     $user->country()->detach();
     $user->country()->save($newCountry);
     // Update the User details
     $user->update($userUpdate);
     return redirect()->action('Admin\\UserController@index')->with('status', 'User has been updated.');
 }
开发者ID:bstapleton,项目名称:pi-community,代码行数:30,代码来源:UserController.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['title' => 'required']);
     $country = Country::find($id);
     if ($request->file('edit-country-flag')) {
         $this->validate($request, ['edit-country-flag' => 'required|image|mimes:jpeg,jpg,png,bmp,gif,svg']);
         $flagFile = $country->flag_path . $country->flag_name;
         if (\File::isFile($flagFile)) {
             \File::delete($flagFile);
         }
         $file = $request->file('edit-country-flag');
         $country_flag_path = $this->_country_flag_path;
         $country_flag_name = $file->getClientOriginalName();
         $file->move($country_flag_path, $country_flag_name);
         $country->flag_name = $country_flag_name;
         $country->flag_path = $country_flag_path;
     }
     $country->title = $request->get('title');
     $country->save();
     flash()->success('', 'Redaguota!');
     return Redirect::to('/dashboard/countries/');
 }
开发者ID:leloulight,项目名称:RealMadrid,代码行数:29,代码来源:CountriesController.php

示例9: country

 public function country()
 {
     return Country::find($this->country_id);
 }
开发者ID:jdeugarte,项目名称:twitter,代码行数:4,代码来源:User.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $post_all = Post::latest()->published()->paginate(5);
     //get one to many
     $post = Post::find(11);
     if ($post) {
         $comments = $post->comments()->get();
     }
     //$comments->posts()->where('active', 1)->get();
     //$comments = Post::find(11)->comments()->where('title', 'foo')->first();
     //inverse
     $comment = Comment::find(1);
     if ($comment) {
         $post_found = $comment->post->title;
     }
     //many to many
     $user = User::find(32);
     if ($user) {
         $roles = $user->roles;
     }
     //$roles2 = User::find(11)->roles()->orderBy('role')->get();
     //Has Many Through
     $country = Country::find(1);
     $post_by_country = $country->posts;
     //Polymorphic
     //foreach ($post->likes as $like) {}
     //inverse
     $like = Like::find(1);
     if ($like) {
         $likeable = $like->likeable;
     }
     //Many To Many Polymorphic
     //$post = App\Post::find(1);
     //foreach ($post->tags as $tag) {}
     //inverse
     $tag = Tag::find(1);
     //Querying Relationship Existence
     // Retrieve all posts that have at least one comment...
     //$posts = Post::has('comments')->get();
     // Retrieve all posts that have three or more comments...
     $posts = Post::has('comments', '>=', 3)->get();
     // Retrieve all posts that have at least one comment with votes...
     //$posts = Post::has('comments.votes')->get();
     // Retrieve all posts with at least one comment containing words like foo%
     // $posts = Post::whereHas('comments', function ($query) {//orWhereHas
     //     $query->where('content', 'like', 'foo%');
     // })->get();
     //Eager loading
     $post2 = Post::with('user')->get();
     //Eager Loading Multiple Relationships
     //Sometimes you may need to eager load several different relationships in a single operation. To do so, just pass additional arguments to the with method:
     //$books = Post::with('user', 'publisher')->get();
     //Nested Eager Loading
     //To eager load nested relationships, you may use "dot" syntax. For example, let's eager load all of the book's authors and all of the author's personal contacts in one Eloquent statement:
     //$books = App\Book::with('author.contacts')->get();
     //Constraining Eager Loads
     //Sometimes you may wish to eager load a relationship, but also specify additional query constraints for the eager loading query. Here's an example:
     // $users = App\User::with(['posts' => function ($query) {
     //     $query->where('title', 'like', '%first%');
     // }])->get();
     //In this example, Eloquent will only eager load posts that if the post's title column contains the word first. Of course, you may call other query builder to further customize the eager loading operation:
     // $users = App\User::with(['posts' => function ($query) {
     //     $query->orderBy('created_at', 'desc');
     // }])->get();
     //Lazy Eager Loading
     //Sometimes you may need to eager load a relationship after the parent model has already been retrieved. For example, this may be useful if you need to dynamically decide whether to load related models:
     //$books = App\Book::all();
     // if ($someCondition) {
     //     $books->load('author', 'publisher');
     // }
     //If you need to set additional query constraints on the eager loading query, you may pass a Closure to the load method:
     // $books->load(['author' => function ($query) {
     //     $query->orderBy('published_date', 'asc');
     // }]);
     return view('posts.index', compact('post', 'comments', 'post_found', 'user', 'roles', 'roles2', 'country', 'post_by_country', 'likeable', 'tag', 'post2', 'post_all'));
 }
开发者ID:TraianAlex,项目名称:laravel4,代码行数:81,代码来源:PostController.php

示例11: postUpdate

	public function postUpdate(Request $request)
	{
		$arr_return = array(
					'status' => 'error',
					'message'=>''
				);
		$time =date('H:i:s', time());
		$id_return_purchaseorder = session('current_returnpurchaseorder') !== null ? session('current_returnpurchaseorder') : 0;
		if($id_return_purchaseorder){
			$returnpurchaseorder = ReturnPurchaseorder::find($id_return_purchaseorder);
			session(['current_returnpurchaseorder' => $returnpurchaseorder['id']]);
			$time = date('H:i:s', strtotime($returnpurchaseorder->date));
		}else{

			$returnpurchaseorder = new ReturnPurchaseorder;
			$returnpurchaseorder->date = date("Y-m-d H:i:s");
			$returnpurchaseorder->created_by = \Auth::user()->id;
			$returnpurchaseorder->save();
			Log::create_log(\Auth::user()->id,'App\ReturnPurchaseorder','Tạo mới đơn hàng trả nhà cung cấp số '.$returnpurchaseorder->id);
			session(['current_returnpurchaseorder' => $returnpurchaseorder->id]);
		}
		$log = '';
		$old_company_id = $returnpurchaseorder->company_id;
		if($returnpurchaseorder->status == 0){
			$address = Address::where('module_id','=',$returnpurchaseorder->id)
						->where('module_type','=','App\ReturnPurchaseorder')->first();
			if(!$address){
				$address = new Address;
			}
			if($request->has('company_id')  && $returnpurchaseorder->company_id != $request->input('company_id')){
				$old = Company::find($returnpurchaseorder->company_id);
				if(!$old){
					$old = (object) ['name'=>''];
				}
				$new = Company::find($request->input('company_id'));
				$log .= 'công ty từ "'.$old->name.'" thành "'.$new->name.'" ';
			}
			if($returnpurchaseorder->company_id == $request->input('company_id')){

				if($request->has('user_id')  && $returnpurchaseorder->user_id != $request->input('user_id')){
					$old = User::find($returnpurchaseorder->user_id);
					if(!$old){
						$old = (object) ['name'=>''];
					}
					$new = User::find($request->input('user_id'));
					$log .= 'người liên hệ từ "'.$old->name.'" thành "'.$new->name.'" ';
				}

				$old_date=date("Y-m-d",strtotime($returnpurchaseorder->date));
				$new_date = date("Y-m-d",strtotime($request->input('date')));
				if($request->has('date')  && $old_date != $new_date){
					$log .= 'ngày từ "'.$old_date.'" thành "'.$new_date.'" ';
				}

				if($request->has('company_phone')  && $returnpurchaseorder->company_phone != $request->input('company_phone')){
					$log .= 'số điện thoại từ "'.$returnpurchaseorder->company_phone.'" thành "'.$request->input('company_phone').'" ';
				}

				if($request->has('company_email')  && $returnpurchaseorder->company_email != $request->input('company_email')){
					$log .= 'email từ "'.$returnpurchaseorder->company_email.'" thành "'.$request->input('company_email').'" ';
				}
				if($request->has('address')  && $address->address != $request->input('address')){
					$log .= 'địa chỉ từ "'.$address->address.'" thành "'.$request->input('address').'" ';
				}
				if($request->has('town_city')  && $address->town_city != $request->input('town_city')){
					$log .= 'quận huyện từ "'.$address->town_city.'" thành "'.$request->input('town_city').'" ';
				}

				if($request->has('province_id')  && $address->province_id != $request->input('province_id')){
					$old = Province::find($address->province_id);
					$new = Province::find($request->input('province_id'));
					if(!$old){
						$old = (object) ['name'=>''];
					}
					$log .= 'tỉnh thành từ "'.$old->name.'" thành "'.$new->name.'" ';
				}
				if($request->has('country_id')  && $address->country_id != $request->input('country_id')){
					$old = Country::find($address->country_id);
					$new = Country::find($request->input('country_id'));
					if(!$old){
						$old = (object) ['name'=>''];
					}
					$log .= 'quốc gia từ "'.$old->name.'" thành "'.$new->name.'" ';
				}
			}
			$returnpurchaseorder->company_id = $request->has('company_id') ? $request->input('company_id') : 0;
			$returnpurchaseorder->user_id = $request->has('user_id') ? $request->input('user_id') : 0;
			$returnpurchaseorder->date = $request->has('date') ? date("Y-m-d H:i:s",strtotime($request->input('date').' '.$time)) : date("Y-m-d H:i:s");
			$returnpurchaseorder->company_phone = $request->has('company_phone') ? $request->input('company_phone') : '';
			$returnpurchaseorder->company_email = $request->has('company_email') ? $request->input('company_email') : '';
			$address_id = isset($returnpurchaseorder->address_id) ? $returnpurchaseorder->address_id : 0;

			

			$address->module_id  = $returnpurchaseorder->id;
			$address->module_type  = 'App\\ReturnPurchaseorder';
			$address->address  = $request->has('address') ? $request->input('address') : '';
			$address->town_city  = $request->has('town_city') ? $request->input('town_city') : '';
			$address->zip_postcode  = $request->has('zip_postcode') ? $request->input('zip_postcode') : '';
			$address->country_id  = $request->has('country_id') ? $request->input('country_id') : 0;
//.........这里部分代码省略.........
开发者ID:kamitori,项目名称:khuongnhi2,代码行数:101,代码来源:ReturnPurchaseordersController.php

示例12: getDeleteinfo

 public function getDeleteinfo(Request $request)
 {
     if ($request->has("id")) {
         $country = Country::find(Input::get("id"));
         if ($country) {
             $country->delete();
             $response = array('status' => ['error' => 0, 'note' => '删除成功'], 'influence' => 1);
             return json_encode($response);
         } else {
             //未找到stu_id
             $response = array('status' => ['error' => 1, 'note' => '未找到id'], 'influence' => 0);
             return json_encode($response);
         }
     } else {
         //没有stu_id参数
         $response = array('status' => ['error' => -1, 'note' => '需要id'], 'influence' => 0);
         return json_encode($response);
     }
 }
开发者ID:ChenPeiyuan,项目名称:student-infomation-manager,代码行数:19,代码来源:CountryManageController.php

示例13: run

 /**
  * Run the database seeds.
  */
 public function run()
 {
     $country = Country::find(1);
     $language = Language::find(1);
     User::create(['id' => 1, 'name' => 'John', 'surname' => 'Doe', 'username' => 'Doe', 'password' => base64_encode('123'), 'email' => 'doe.john@nomail.com', 'direction' => 'going up', 'enabled' => true, 'country_id' => $country->id, 'language_id' => $language->id]);
 }
开发者ID:juboba,项目名称:Luminosity,代码行数:9,代码来源:UserTableSeeder.php

示例14: getList

 public function getList($country)
 {
     if (!Auth::check()) {
         return Redirect::to('leads/login');
     }
     $leads = Lead::where('user_id', '=', Auth::user()->id)->where('Country', '=', $country)->orderBy('Country');
     return view('leads.view')->with('country', Country::find($country))->with('leads', $leads->paginate(10))->with('leads_count', $leads->count());
 }
开发者ID:avivhazor,项目名称:EveryLeads,代码行数:8,代码来源:LeadsController.php

示例15: postDelete

 /**
  * Remove the specified resource from storage.
  *
  * @param $id
  * @return Response
  */
 public function postDelete(DeleteRequest $request, $id)
 {
     $country = Country::find($id);
     $country->delete();
 }
开发者ID:alex311982,项目名称:laravel5_online_support,代码行数:11,代码来源:CountryController.php


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