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


PHP Country::with方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $user = Country::with('states', 'states.cities')->find(101)->toArray();
     echo '<pre>';
     print_r($user);
     echo '</pre>';
     die;
 }
开发者ID:surajch,项目名称:ensue-me,代码行数:13,代码来源:TestController.php

示例2: 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]);
 }
开发者ID:kamitori,项目名称:khuongnhi2,代码行数:44,代码来源:CompaniesController.php

示例3: anyEntry

	public function anyEntry(Request $request,$id=null)
	{
		\DB::enableQueryLog();
		if(isset($id) && $id!=null){
			$id_return_purchaseorder = $id;
			$returnpurchaseorder = ReturnPurchaseorder::find($id_return_purchaseorder);
			if($returnpurchaseorder != null){
				session(['current_returnpurchaseorder' => $returnpurchaseorder['id']]);
			}else{
				return redirect('returnpurchaseorders');
			}
		}else{
			$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']]);
			}else{
				$returnpurchaseorder = ReturnPurchaseorder::get()->last();
				if($returnpurchaseorder){
					session(['current_returnpurchaseorder' => $returnpurchaseorder['id']]);
				}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]);
				}
			}
		}
		$address = Address::where('module_id','=',$returnpurchaseorder->id)
					->where('module_type','=','App\ReturnPurchaseorder')->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();
			$purchaseorder['province_name'] = $country_province['province_name'];
			$purchaseorder['country_name'] = $country_province['country_name'];
		}else{
			$purchaseorder['province_name'] = '';
			$purchaseorder['country_name'] = '';
		}
		if($address){
			$address = $address->toArray();
		}else{
			$address = array();
		}
		$returnpurchaseorder = $returnpurchaseorder->toArray();
		$returnpurchaseorder['province_name'] = isset($country_province->province_name)?$country_province->province_name:'';
		$returnpurchaseorder['country_name'] = isset($country_province->country_name)?$country_province->country_name:'';
		// var_dump(DB::getQueryLog());
		// pr($returnpurchaseorder);die;

		//Init array
		$distributes = array();
		$oums = array();
		$users = array();
		$countries = array();
		$list_product = array();

		//Get value array
		$distributes = Company::getDistributeList()->with('address')->get()->toArray();
		$oums = Oum::orderBy('name')->get()->toArray();
		$users = User::get();
		$countries = Country::with('provinces')->get()->toArray();

		$arr_product = MProduct::where('module_type','=','App\ReturnPurchaseorder')
						->where('module_id','=',$returnpurchaseorder['id'])
						->lists('product_id');

		Session::forget('product_of_rpo'.session('current_returnpurchaseorder'));
		foreach ($arr_product as $key => $value) {
			Session::put('product_of_rpo'.session('current_returnpurchaseorder').".".$value , $value);
		}

		$view_list_product = self::getListProduct();

		$arr_create = ReturnPurchaseorder::select('users.name','return_purchaseorders.created_at')
					->leftJoin('users','users.id','=','return_purchaseorders.created_by')
					->where('return_purchaseorders.id','=',$returnpurchaseorder['id'])
					->get()->first()->toArray();

		$arr_update = ReturnPurchaseorder::select('users.name','return_purchaseorders.updated_at')
					->leftJoin('users','users.id','=','return_purchaseorders.updated_by')
					->where('return_purchaseorders.id','=',$returnpurchaseorder['id'])
					->get()->first()->toArray();
		$this->layout->arr_create = $arr_create;
		$this->layout->arr_update = $arr_update;

		$this->layout->content=view('returnpurchaseorder.entry',[	'distributes'=>$distributes,
										'users'=>$users,
										'countries'=>$countries,
										'returnpurchaseorder'=>$returnpurchaseorder,
										'address'=>$address,
										'oums'=>$oums,
										'view_list_product'=>$view_list_product
//.........这里部分代码省略.........
开发者ID:kamitori,项目名称:khuongnhi2,代码行数:101,代码来源:ReturnPurchaseordersController.php

示例4: getById

 public function getById($id)
 {
     $country = Country::with('translations')->find($id);
     return $country;
 }
开发者ID:manogi,项目名称:gfw-qm,代码行数:5,代码来源:EloquentCountryRepository.php


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