本文整理汇总了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('搜索类型错误!');
}
}
}