本文整理匯總了PHP中app\models\Property::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Property::where方法的具體用法?PHP Property::where怎麽用?PHP Property::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Property
的用法示例。
在下文中一共展示了Property::where方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getIndex
/**
* Show the application dashboard.
*
* @return Response
*/
public function getIndex(Request $request)
{
//return $sub;
Session::put('month', $this->monthName());
if (isset($request->c)) {
if (Session::has('member')) {
$member = Member::find(Session::get('member')->id);
$property = $member->properties()->where('code', '=', $request->c)->first();
Session::put('property', $property);
return view('property.index');
}
} else {
if (Session::has('hotel')) {
if (Session::has('member')) {
$property = Property::where("code", '=', Session::get('hotel'))->first();
Session::put('property', $property);
return view('property.index');
}
} else {
if (Session::has('property')) {
return view('property.index');
} else {
return redirect('/member/property');
}
}
}
}
示例2: getPropertyList
public function getPropertyList($user_id, $date)
{
$query = Property::where('user_id', '<>', $user_id);
if (empty($date)) {
$query->where('bid_start_date_time', '>', Carbon::now())->orWhere('bid_close_date_time', '>', Carbon::now());
}
return $query->orderBy('bid_start_date_time', 'asc')->get();
}
示例3: postLogin
public function postLogin(Request $request)
{
$messages = ['username.required' => 'กรุณาใส่รหัสผู้ใช้', 'username.exists' => 'ไม่มีรหัสผู้ใช้ดังกล่าวในระบบ', 'password.required' => 'กรุณาใส่พาสเวิร์ด'];
$validator = Validator::make($request->all(), ['username' => 'required|exists:ch_employee,username', 'password' => 'required'], $messages);
//$request->session()->put('data', 'value');
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}
if (Session::has('hotel')) {
$property = Property::where("code", '=', Session::get('hotel'))->first();
if ($property) {
$member = $property->employees()->where("username", "=", $request->username)->first();
if (Hash::check($request->password, $member->password)) {
$request->session()->put('member', $member);
return redirect('/property');
} else {
return redirect()->back()->withErrors(['พาสเวิร์ดหรือชื่อผู้ใช้ของคุณไม่สัมพันธ์กัน'])->withInput();
}
}
}
return redirect('/');
}
示例4: parseNewhomesourceProperty
public static function parseNewhomesourceProperty($url)
{
if (!$url) {
return null;
}
$dataSourceId = 1001;
$html = new \simple_html_dom();
$httpClient = new GuzzleHttp\Client();
try {
$contents = $httpClient->get($url)->getBody()->getContents();
} catch (GuzzleHttp\Exception\RequestException $e) {
throw new FunFangException("訪問 {$url} 時出錯!" . $e->getMessage());
}
$html->load($contents);
$planIdEle = $html->find('#PlanId', 0);
if (!$planIdEle) {
throw new FunFangException('您輸入的URL可能不正確,解析失敗!');
}
$planId = $planIdEle->value;
//先從數據庫中查找
if ($planId) {
$record = Property::where('DataSourceId', $dataSourceId)->where('DataId', $planId)->first();
if ($record) {
$html->clear();
return $record;
}
}
//如果數據庫中沒有記錄,從html中解析並保存到數據庫
$record = new Property();
$record->DataSourceId = $dataSourceId;
$record->DataId = trim($planId);
$record->ReferenceUrl = $url;
$communityId = $html->find('#CommunityId', 0)->value;
$specId = $html->find('#SpecId', 0)->value;
//照片需要通過另外的API獲取,必須的參數:communityId、planId、specId、isPreview
$photoRes = $httpClient->post('http://www.newhomesource.com/detailgetgallery', ['form_params' => ['communityId' => $communityId, 'planId' => $planId, 'specId' => $specId, 'isPreview' => 'False']]);
$photoObj = json_decode($photoRes->getBody()->getContents());
$photoUrls = [];
foreach ($photoObj->PropertyMediaLinks as $photo) {
//type:i是圖片,v是視頻
if ($photo->Type == 'i') {
array_push($photoUrls, 'http://nhs-dynamic.bdxcdn.com/' . $photo->Url);
}
}
$record->PhotoUrls = implode(',', $photoUrls);
//價格
$listPrice = $html->find('#nhs_DetailsDescriptionAreaWrapper .nhs_DetailsPrice span', 0)->plaintext;
$record->ListPrice = str_replace(',', '', str_replace('$', '', $listPrice));
foreach ($html->find('#nhs_HomeDetailsHeaderBrandHomesSqFt ul li') as $li) {
$text = $li->plaintext;
if (StringUtil::containsIgnoreCase($text, 'Bedrooms')) {
//臥室數
$bedrooms = str_ireplace('Bedrooms', '', $text);
$bedrooms = str_replace(' ', '', $bedrooms);
$record->Bedrooms = $bedrooms;
} else {
if (StringUtil::containsIgnoreCase($text, 'Bathrooms')) {
//浴室數
$bathrooms = str_ireplace('Bathrooms', '', $text);
$bathrooms = str_replace(' ', '', $bathrooms);
$record->BathsFull = intval($bathrooms);
$record->BathsHalf = intval($bathrooms) == $bathrooms ? 0 : 1;
} else {
if (StringUtil::containsIgnoreCase($text, 'sq.ft.')) {
//麵積
$structureSqFt = str_ireplace('sq.ft.', '', $text);
$structureSqFt = str_replace(',', '', $structureSqFt);
$record->StructureSqFt = $structureSqFt;
} else {
if (StringUtil::containsIgnoreCase($text, 'Garages')) {
//停車位
$garageSpaces = str_ireplace('Garages', '', $text);
$garageSpaces = str_replace(' ', '', $garageSpaces);
$record->GarageSpaces = $garageSpaces;
}
}
}
}
}
$description = $html->find('#nhs_DetailDescriptionArea', 0)->plaintext;
$description = str_replace(' ', '', $description);
$record->Description = $description;
//解析坐標位置
$jsonStr = $html->find('#nhs_HomeDetailv2 script', 0)->innertext;
$obj = json_decode($jsonStr);
$lat = $obj->Geo->latitude;
$lng = $obj->Geo->longitude;
$addressRes = $httpClient->get("http://ditu.google.cn//maps/api/geocode/json?latlng={$lat},{$lng}");
$addressJson = json_decode($addressRes->getBody()->getContents());
if ($addressJson->status == 'OK') {
$addressObj = GoogleGeoHelper::getAddress($addressJson->results);
}
if ($addressObj) {
$record->State = $addressObj->state;
$record->County = $addressObj->county;
$record->City = $addressObj->city;
$streetNumber = property_exists($addressObj, 'streetNumber') ? $addressObj->streetNumber : '';
$street = property_exists($addressObj, 'street') ? $addressObj->street : '';
$record->Address = "{$streetNumber} {$street}";
$record->PostalCode = $addressObj->postalCode;
//.........這裏部分代碼省略.........
示例5: fetch
/**
* 通過MLSID或第三方網站URL獲取房源
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
* @throws \Exception
*/
public function fetch(Request $request)
{
$this->validate($request, ['type' => 'required', 'q' => 'required']);
//搜索內容
$q = trim($request->q);
//判斷搜索類型
if ($request->type == 0) {
//MLSID
$model = Property::where('MLSNumber', $q)->first();
if ($model) {
//return view('property._detail', ['record' => $record]);
$view = view('property._detail', ['record' => $model]);
return response()->json(['model' => $model, 'view' => $view]);
}
throw new Exception('未找到!');
} else {
if ($request->type == 1) {
//第三方網站URL
$domain = UrlUtil::getMainDomain($q);
if (StringUtil::equalsIgnoreCase($domain, 'loopnet.com')) {
$model = Util::parseLoopnetProperty($q);
$view = view('property._detail', ['model' => $model])->render();
return response()->json(['model' => $model, 'view' => $view]);
} else {
if (StringUtil::equalsIgnoreCase($domain, 'newhomesource.com')) {
$model = Util::parseNewhomesourceProperty($q);
$view = view('property._detail', ['model' => $model])->render();
return response()->json(['model' => $model, 'view' => $view]);
} else {
throw new Exception('您輸入的網站URL暫不支持!');
}
}
} else {
throw new Exception('搜索類型錯誤!');
}
}
}