本文整理汇总了PHP中Listing::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Listing::where方法的具体用法?PHP Listing::where怎么用?PHP Listing::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Listing
的用法示例。
在下文中一共展示了Listing::where方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param string $location
* @return Response
*/
public function show()
{
$location = Input::get('location');
$type = strtolower(Input::get('type'));
$wildcardLocation = "%" . $location . "%";
if (Input::has('type')) {
$types = array('meeting-room', 'coworking', 'desk');
if (!in_array($type, $types, true)) {
return Redirect::to('/')->with('flash_message_404', "Sorry, we don't have that type of space so we brought you back home!");
}
$listings = Listing::with('thumbnail')->where('isPublic', '=', 1, "and")->where('space_type', '=', $type)->where('city', 'LIKE', $wildcardLocation)->orWhere('state', 'LIKE', $wildcardLocation)->orWhere('suburb', 'LIKE', $wildcardLocation)->orWhere('country', 'LIKE', $wildcardLocation)->orWhere('postcode', 'LIKE', $wildcardLocation)->get();
} else {
$listings = Listing::with('thumbnail')->where('isPublic', '=', 1, "and")->where('space_type', '=', $type)->where('city', 'LIKE', $wildcardLocation)->orWhere('state', 'LIKE', $wildcardLocation)->orWhere('suburb', 'LIKE', $wildcardLocation)->orWhere('country', 'LIKE', $wildcardLocation)->orWhere('postcode', 'LIKE', $wildcardLocation)->get();
}
$colNum = Listing::where('city', 'LIKE', $wildcardLocation)->orWhere('state', 'LIKE', $wildcardLocation)->orWhere('suburb', 'LIKE', $wildcardLocation)->orWhere('country', 'LIKE', $wildcardLocation)->where('isPublic', '=', '1')->count();
switch ($colNum) {
case 1:
$colNum = 12;
break;
case 2:
$colNum = 6;
break;
case 3:
$colNum = 3;
break;
}
$title = ucwords("Search: " . $type . " spaces in " . $location);
return View::make('search.results')->with('listings', $listings)->with('title', $title)->with('colNum', $colNum);
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store($id)
{
$listing = Listing::where('isPublic', '=', 1)->where('id', '=', $id)->first();
if (!$listing) {
throw new \Symfony\Component\Routing\Exception\ResourceNotFoundException();
}
$input = Input::all();
//return print_r($input,true);
$yesterday = \Carbon\Carbon::now('Australia/Sydney');
$yesterday = $yesterday->format('Y-m-d H:i:s');
// return $yesterday;
$rules = array('comments' => array('required', 'min:3'), 'user_phone' => array('required', 'min:9', 'max:30'), 'request_start_datetime' => array('required', 'date', 'dateformat: Y-m-d H:i:s', 'before: ' . $input['request_end_datetime']), 'request_end_datetime' => array('required', 'date', 'dateformat: Y-m-d H:i:s', 'after: ' . $yesterday));
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return Redirect::back()->withInput($input)->withErrors($validator);
}
$comments = $this->sanitizeStringAndParseMarkdown($input['comments']);
$authuser = Auth::user();
$name = $authuser->name;
$bookings = new Booking();
$bookings->user_id = $authuser->id;
$bookings->user_name = $name;
$bookings->listing_id = $id;
$bookings->user_phone = $input['user_phone'];
$bookings->request_start_datetime = $input['request_start_datetime'];
$bookings->request_end_datetime = $input['request_end_datetime'];
$bookings->status = "Booking request submitted. Awaiting Open Source Collaborative Consumption Marketplace review.";
$bookings->user_comments = $comments;
$bookings->space_owner_id = $listing->owner_id;
$address = $listing->address1 . ", " . $listing->suburb . ", " . $listing->city . " " . $listing->country;
$data = $input;
$data['address'] = $address;
$data['title'] = $listing->title;
$data['id'] = $id;
$data['type'] = $listing->space_type;
$data['user_name'] = $name;
$data['status'] = $bookings->status;
/* TODO: Make it email the user and space owner */
Mail::send("booking.mail.newbookingfounders", $data, function ($message) {
$message->to('founders@worldburrow.com')->subject('New booking on Open Source Collaborative Consumption Marketplace');
});
$email = Auth::user()->email;
Mail::send("booking.mail.newbookinguser", $data, function ($message) use($email) {
$message->to($email)->subject('Your new booking on Open Source Collaborative Consumption Marketplace!');
});
$bookings->save();
return Redirect::to('dashboard')->with('flash_message_good', "Your booking has been sent. We'll be in touch soon with confirmation or questions!");
}
示例3: action_deleteExpired
public function action_deleteExpired()
{
$date = date("Y-m-d H:i:s");
$date = date('Y-m-d H:i:s', strtotime('-30 day', strtotime($date)));
var_dump($date);
$listings = Listing::where('date_unavailable', '<', $date)->get();
foreach ($listings as $listing) {
$location = Location::find($listing->location_id);
$account = Account::find($location->account_id);
$email = $account->email;
$subject = 'REMARKET: Tell us what happened with your listing.';
$message = "Your posting titled '" . addslashes($listing->title) . "' was recently deleted from market319.tk. \n\n How did it go?" . "\n\n We were wondering if you would fill out our customer survey" . " at market319.tk/survey \n\n Thanks, \n The REMARKET team";
$header = "from: REMARKET <no-reply@market.tk>";
$sent = mail($email, $subject, $message, $header);
$listing->delete();
}
}
示例4: visibility
/**
* Toggle the isPublic visibility in storage for a specified ID;
*
* @param int $id
* @return Response
*/
public function visibility($id)
{
$listing = Listing::where('id', '=', $id)->first();
/* Check if the user "owns" the space in DB */
if ($listing->owner_id != Auth::user()->id) {
return Redirect::back()->with('flash_message_404', 'You do not have permission to change that listing');
}
$status = $listing->isPublic;
$message = "Visibility for listing: " . $listing->title . " updated!";
if ($status == 1) {
$listing->isPublic = 0;
$listing->save();
return Redirect::back()->with('flash_message_good', $message);
} else {
$listing->isPublic = 1;
$listing->save();
return Redirect::back()->with('flash_message_good', $message);
}
}
示例5: action_sendEmails
public function action_sendEmails()
{
$accounts = Account::where('wishlistEmail', '=', '1')->get();
foreach ($accounts as $account) {
$matches = array();
$tags = $account->wishlistitems()->get();
$listings = array();
$tempListings = array();
foreach ($tags as $tag) {
$tagListings;
$strings = explode(' ', $tag->item);
if (sizeof($strings) == 1) {
$tagListings = Listing::where('title', 'LIKE', "%{$tag->item}%")->or_where("description", 'LIKE', "%{$tag->item}%")->get();
} else {
$string = array_pop($strings);
$query = "\tSELECT *\n\t\t\t\t\t\t\t\tFROM listings\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(title LIKE '%{$string}%'\n\t\t\t\t\t\t\t\t\tOR description LIKE '%{$string}%')";
while (!empty($strings)) {
$string = array_pop($strings);
$query .= " AND (title LIKE '%{$string}%'\n\t\t\t\t\t\t\t\t\tOR description LIKE '%{$string}%')";
}
$tagListings = DB::query($query);
}
foreach ($strings as $string) {
}
foreach ($tagListings as $listing) {
$listing->location = Location::find($listing->location_id);
$listing->category = Categorie::find($listing->category_id);
}
array_push($tempListings, $tagListings);
}
foreach ($tempListings as $key => $tagListings) {
foreach ($tagListings as $listing) {
$listings[$listing->id] = $listing;
}
}
var_dump(sizeof($listings));
if (sizeof($listings) > 0) {
$email = $account->email;
$subject = 'REMARKET: Matches found on your wishlist!';
$message = "There have recently been matches found which match the tags in your wishlist. \n\n" . "Go to market319.tk/ and login to view your wishlist.\n" . "\n\n Happy buying, \n The REMARKET team";
$header = "from: REMARKET <no-reply@market.tk>";
$sent = mail($email, $subject, $message, $header);
}
}
}