本文整理汇总了PHP中Product::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::where方法的具体用法?PHP Product::where怎么用?PHP Product::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: productsBySubCatagory
public function productsBySubCatagory($id)
{
$query = Product::where('subcatagory_id', '=', $id)->paginate(12);
$catagory = Catagory::all();
$subcatagory = Subcatagory::all();
return View::make('Products.ProductsByCatagory', ['catagories' => $catagory, 'products' => $query, 'subcatagories' => $subcatagory]);
}
示例2: index
/**
* Display all comments by productId.
*
* @return Response
*/
public function index($productId)
{
$product = Product::where('id', $productId)->first();
$reviews = Review::where('productId', $productId)->get();
$product["reviews"] = $reviews;
return $product;
}
示例3: postUpdateCard
public function postUpdateCard()
{
// Add Curl library
require_once app_path() . "/libraries/Curl/Curl.php";
// Get Product
$product = Product::where('code', Input::get('code'))->first();
// Get Expiry month and year
$expiry = explode(' / ', Input::get('ccExpire'));
// Put all values in session
Session::flash('ccNum', Input::get('ccNum'));
Session::flash('ccExpire', Input::get('ccExpire'));
Session::flash('ccCVC', Input::get('ccCVC'));
$data = array('email' => Input::get('email'), 'code' => Input::get('code'), 'number' => Input::get('ccNum'), 'exp_month' => !empty($expiry[0]) ? $expiry[0] : NULL, 'exp_year' => !empty($expiry[1]) ? $expiry[1] : NULL, 'cvc' => Input::get('ccCVC'));
$data['key'] = DKHelpers::GenerateHash($data, $product->api_key);
$url = url() . "/api/v1/update-card";
// Post data to IPN
$curl = new Curl();
$response = $curl->simple_post($url, $data, array(CURLOPT_BUFFERSIZE => 10));
$response = json_decode($response);
if (empty($response->error)) {
$success = "Your card (**** **** **** {$response->last4}) has been updated successfully.";
return Redirect::back()->with('success', $success);
} else {
return Redirect::back()->with('error', $response->error);
}
}
示例4: getIndex
/**
* Display Home Page
* @return mixed
*/
public function getIndex()
{
// Session::flush();
$data['sales'] = Product::where('price_sale', '<>', 0)->get();
$data['bestsaller'] = Product::where('price_bestsaller', '<>', 0)->get();
return View::make('index', $data);
}
示例5: postGenerateLicense
/**
* Generate license
*/
public function postGenerateLicense()
{
$rules = array('transaction_id' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('admin/utilities/generate-license')->withErrors($validator)->withInput();
} else {
$transaction_id = Input::get('transaction_id');
if ($transaction = Transaction::where('id', '=', $transaction_id)->first()) {
if ($license = License::where('transaction_id', '=', $transaction_id)->first()) {
Session::flash('alert_error', '<strong>Ooops!</strong> License for given transaction already exists.');
return Redirect::to('admin/licenses?q=' . $license->license_key . '¶m=key');
}
$plan = Plan::where('id', '=', $transaction->plan_id)->first();
if ($plan->has_license) {
$product = Product::where('id', '=', $plan->product_id)->first();
$license_key = License::generate($product->code);
// Save license
$license = new License();
$license->license_key = $license_key;
$license->transaction_id = $transaction_id;
$license->allowed_usage = $plan->license_allowed_usage;
$license->save();
Session::flash('alert_message', '<strong>Well done!</strong> You successfully have generated license key.');
return Redirect::to('admin/licenses?q=' . $license_key . '¶m=key');
} else {
Session::flash('alert_error', '<strong>Ooops!</strong> This plan does not allow to generate a license key.');
return Redirect::to('admin/utilities/generate-license');
}
} else {
Session::flash('alert_error', '<strong>Ooops!</strong> Transaction was not found.');
return Redirect::to('admin/utilities/generate-license');
}
}
}
示例6: search
public function search()
{
$query_supplier = '%' . Input::get('supplier') . '%';
$query_metal = '%' . Input::get('metal') . '%';
$query_city = '%' . Input::get('city') . '%';
$query_grade_a = '%' . Input::get('grade_a') . '%';
$query_grade_b = '%' . Input::get('grade_b') . '%';
$query_thickness = '%' . Input::get('thickness') . '%';
$query_shape = '%' . Input::get('shape') . '%';
if (Input::has('volume_from')) {
$query_volume_from = Input::get('volume_from');
} else {
$query_volume_from = 0;
}
if (Input::has('volume_to')) {
$query_volume_to = Input::get('volume_to');
} else {
$query_volume_to = Product::max('volume');
}
if (Input::has('date_from')) {
$query_date_from = date('Y-m-d H:i:s', strtotime(Input::get('date_from')));
} else {
$query_date_from = date('Y-m-d H:i:s', strtotime("1-1-1970"));
}
if (Input::has('date_to')) {
$query_date_to = date('Y-m-d H:i:s', strtotime(Input::get('date_to') . " 23:59"));
} else {
$query_date_to = date('Y-m-d H:i:s', strtotime("now"));
}
$products = Product::where('supplier', 'LIKE', $query_supplier)->where('metal', 'LIKE', $query_metal)->where('city', 'LIKE', $query_city)->where('grade_a', 'LIKE', $query_grade_a)->where('grade_b', 'LIKE', $query_grade_b)->where('thickness', 'LIKE', $query_thickness)->where('shape', 'LIKE', $query_shape)->whereBetween('created_at', array($query_date_from, $query_date_to))->whereBetween('volume', array($query_volume_from, $query_volume_to))->paginate(5);
$suppliers = Product::lists('supplier', 'supplier');
$metals = Product::lists('metal', 'metal');
return View::make('products.list')->with('products', $products)->with('suppliers', $suppliers)->with('metals', $metals)->withInput(Input::flash());
}
示例7: updateProductsAction
public function updateProductsAction()
{
$user = Auth::user();
$config = Config::get('providers.' . $user->provider);
$client = new \Guzzle\Http\Client();
$headers = $config['headers'];
array_walk($headers, function (&$value, $key) use($user) {
$value = str_replace('{token}', $user->access_token, $value);
});
$request = $client->get(str_replace('{blog_id}', $user->blog_id, $config['mediaUri']));
$request->setHeaders($headers);
$request->getHeaders()->toArray();
$response = $request->send();
$images = $response->json()['media'];
$products = [];
foreach ($images as $image) {
if (!($product = Product::where('image_id', '=', $image['id'])->first())) {
$product = new Product();
$product->image_id = $image['id'];
$product->image = $image['link'];
$user->products()->save($product);
$products[] = $product;
}
}
return Redirect::route('products');
}
示例8: getSearch
public static function getSearch($input = array())
{
$result = Product::where(function ($query) use($input) {
if (!empty($input['category_id'])) {
$query = $query->where('category_id', $input['category_id']);
}
if (!empty($input['type_id'])) {
$query = $query->where('type_id', $input['type_id']);
}
if (!empty($input['price_id'])) {
$query = $query->where('price_id', $input['price_id']);
}
if (!empty($input['time_id'])) {
$inputDate = getTime($input['time_id']);
$query = $query->where('start_time', '>=', $inputDate);
}
if (!empty($input['city_id'])) {
$query = $query->where('city_id', $input['city_id']);
}
if (!empty($input['city'])) {
$query = $query->where('city', $input['city']);
}
if (!empty($input['name'])) {
$query = $query->where('name', 'like', '%' . $input['name'] . '%');
}
//lat long
$query = $query->where('status', ACTIVE);
})->select(listFieldProduct())->get();
foreach ($result as $key => $value) {
$value->avatar = url(PRODUCT_UPLOAD . '/' . $value->user_id . '/' . Product::find($value->id)->avatar);
$value->block = Common::checkBlackList(Input::get('user_id'), $value->user_id);
}
return $result;
}
示例9: search
function search()
{
$viewMode = $this->uri->segment(2, "") == "" ? "ma-tran" : $this->uri->segment(2);
$orderBy = $this->uri->segment(3, "") == "" ? "moi-nhat" : $this->uri->segment(3);
$page = $this->uri->segment(4, "") == "" ? "trang-1" : $this->uri->segment(4);
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$searchKey = $this->input->post('searchKey');
$this->session->set_userdata('searchKey', $searchKey);
}
$searchKey = $this->session->userdata('searchkey');
$limit = $viewMode == "ma-tran" ? 15 : 10;
$offset = ($this->getPageNumber($page) - 1) * $limit;
$product = new Product();
if (trim($searchKey) != "") {
$product->like('name', $searchKey);
}
$product->where('active', 1);
$product->order_by($this->getOrderBy($orderBy), $this->getOrderDirection($orderBy));
$product->get_paged_iterated();
$dis['product'] = $product;
$dis['pageUrl'] = "tim-kiem";
$config['base_url'] = site_url($url . "/" . $viewMode . "/" . $orderBy . "/trang-");
$config['total_rows'] = $product->paged->total_rows;
$config['per_page'] = $limit;
$config['use_page_numbers'] = TRUE;
$config['uri_segment'] = 4;
$config['num_links'] = 3;
$config['full_tag_open'] = '<span class="pagin">';
$config['full_tag_close'] = "</span>";
$config['first_link'] = FALSE;
$config['first_tag_open'] = '';
$config['first_tag_close'] = '';
$config['last_link'] = FALSE;
$config['last_tag_open'] = '';
$config['last_tag_close'] = '';
$config['next_link'] = '<img src="' . base_url() . 'images/pagination_next.png" />';
$config['next_tag_open'] = '';
$config['next_tag_close'] = '';
$config['prev_link'] = '<img src="' . base_url() . 'images/pagination_pre.png" /';
$config['prev_tag_open'] = '';
$config['prev_tag_close'] = '';
$config['num_tag_open'] = '';
$config['num_tag_close'] = '';
$config['cur_tag_open'] = '<span class="active">';
$config['cur_tag_close'] = '</span>';
$this->pagination->initialize($config);
if ($viewMode == 'ma-tran') {
$dis['view'] = 'product/product_grid';
} else {
$dis['view'] = 'product/product_list';
}
$productSaleOff = new product();
$productSaleOff->where('active', 1);
$productSaleOff->where('isSale', 1);
$productSaleOff->order_by('id', 'desc');
$productSaleOff->get_iterated(15);
$dis['productSaleOff'] = $productSaleOff;
$dis['base_url'] = base_url();
$this->viewfront($dis);
}
示例10: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$products = Product::where('id', '>', 0)->paginate(2);
//this pagination . get 2 rows from database at once
return View::make('product.index')->with('products', $products);
//go to product/index.blade.php with two rows of database
}
示例11: getProducts
public function getProducts($id)
{
$category = Category::find($id);
$network = Network::where('category_id', '=', $id)->get();
$product = Product::where('category_id', '=', $id)->paginate(9);
$phone = Product::where('category_id', '=', $id)->get();
return View::make('products.index')->with('category', $category)->with('network', $network)->with('product', $product)->with('phone', $phone);
}
示例12: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$product = Product::where('id', $id)->first();
if ($product->user_id == Session::get('current_user')) {
return Redirect::to('product/' . $product->id . '/edit')->with('product', $product);
} else {
return View::make('frontend/products/show')->with('product', $product);
}
}
示例13: searchField
public static function searchField($field, $value, $products_d = null)
{
if ($products_d) {
return $products_d->where($field, 'LIKE', "%{$value}%");
} else {
$products_d = Product::where($field, 'LIKE', "%{$value}%");
return $products_d;
}
}
示例14: detailFavorite
public function detailFavorite($userFavoriteId)
{
$input = Input::all();
$sessionId = Common::checkSessionLogin($input);
$listProducts = Product::where('user_id', $userFavoriteId)->get();
foreach ($listProducts as $key => $value) {
$value->avatar = url(PRODUCT_UPLOAD . '/' . $value->user_id . '/' . Product::find($value->id)->avatar);
}
return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId, $listProducts);
}
示例15: getAllProducts
public static function getAllProducts()
{
if (Session::has('merchant')) {
$merchant = Session::get('merchant');
$product_list = Product::where('merchant_id', $merchant['merchant_id'])->get();
} else {
$product_list = Product::All();
}
return $product_list;
}