本文整理汇总了PHP中Products::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Products::where方法的具体用法?PHP Products::where怎么用?PHP Products::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products
的用法示例。
在下文中一共展示了Products::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addmodels
public function addmodels($id)
{
if ($this->isAdminRequest()) {
//$id = $_POST['id'];
// print_r($_POST);
$rules = array('models' => 'required');
$validator = Validator::make(Input::all(), $rules);
// process the login
if ($validator->fails()) {
return Redirect::to('admin/products/' . $id . '/models')->withErrors($validator)->with('productcategory', ProductCategory::find($id))->with('models', Products::where('product_category_id', '=', $id)->get())->withInput(Input::all());
} else {
$models = Input::get('models');
$models_arr = explode(",", $models);
foreach ($models_arr as $model) {
$product_model = new Products();
$product_model->model_id = $model;
$product_model->product_category_id = $id;
$product_model->save();
}
// // redirect
Session::flash('message', 'Successfully added models.');
return Redirect::to('admin/products/' . $id . '/models');
}
//$import = importmodels('boo');
//
// $productcategory = ProductCategory::find($id);
// $models = Products::where('product_category_id','=',$id)->get();
// return View::make('admin.products.models')
// ->with('productcategory',$productcategory)
// ->with('models',$models);
// }
}
}
示例2: filter
public static function filter($input, $limit = 24)
{
$products = Products::where(function ($query) use($input) {
if (array_key_exists('name', $input) && strlen($input['name'])) {
$query->where('name', 'LIKE', "%" . $input['name'] . "%");
}
if (array_key_exists('name_code', $input) && strlen($input['name_code'])) {
$query->where(function ($query) use($input) {
$query->where('name', 'LIKE', "%" . $input['name_code'] . "%");
$query->orWhere('product_code', 'LIKE', "%" . trim($input['name_code']) . "%");
});
}
if (array_key_exists('type', $input) && strlen($input['type'])) {
$query->whereTypeId($input['type']);
}
if (array_key_exists('entry_from', $input) && strlen($input['entry_from'])) {
$query->where(DB::raw('DATE(created_at)'), '>=', date('Y-m-d', strtotime($input['entry_from'])));
}
if (array_key_exists('entry_to', $input) && strlen($input['entry_to'])) {
$query->where(DB::raw('DATE(created_at)'), '<=', date('Y-m-d', strtotime($input['entry_to'])));
}
if (array_key_exists('unit', $input) && strlen($input['unit'])) {
$query->whereTypeId($input['unit']);
}
if (array_key_exists('barcode', $input) && strlen($input['barcode'])) {
$query->where('product_code', 'LIKE', "%" . trim($input['barcode']) . "%");
}
})->select('products.*', DB::raw('CONCAT(name, " - Rs. ", cp , " / Rs. " , sp, ":",id) as nameprice'))->orderBy('name', 'asc');
if ($limit == 0) {
return $products->get();
} else {
return $products->paginate($limit);
}
}
示例3: exists
public function exists($id)
{
$exists = Products::where('supplierId', $id)->first();
if ($exists == null) {
return false;
} else {
return true;
}
}
示例4: approve
public function approve($id)
{
$outletsStocksReturns = OutletsStocksReturns::find($id);
//echo $outletsStocksReturns->product_id;exit();
if ($outletsStocksReturns) {
$product = Products::where('id', '=', $outletsStocksReturns->product_id)->first();
$product->quantity = $product->quantity + $outletsStocksReturns->quantity;
$product->save();
$outletsStocks = OutletsStocks::where('product_id', '=', $outletsStocksReturns->product_id)->where('outlet_id', '=', $outletsStocksReturns->outlet_id)->first();
$outletsStocks->quantity = $outletsStocks->quantity - $outletsStocksReturns->quantity;
$outletsStocks->save();
$outletsStocksReturns->status = "Approved";
$outletsStocksReturns->save();
return Redirect::route('stockreturns.index')->with('success', 'Stock Return Completed');
} else {
return Redirect::route('stockreturns.index')->with('error', 'Product not found in Outlets Stocks Returns Table');
}
}
示例5: updateProduct
public static function updateProduct($data, $product_id = null)
{
$update = array();
foreach ($data as $key => $value) {
if ($value != null) {
$update[$key] = $value;
}
}
if (empty($update)) {
$response = array('status' => 400, 'error' => 'bad_request', 'params' => $data, 'message' => 'All parameters are blank/null, Please check your parameters.');
} else {
$affectedRows = Products::where('product_id', $product_id)->update($update);
if ($affectedRows == 1) {
$response = array('status' => 200, 'error' => false, 'update' => $update, 'message' => 'Product has been successfully updated.');
} else {
$response = array('status' => 402, 'error' => 'update_failed', 'update' => $update, 'message' => 'Product update failed.');
}
}
return $response;
}
示例6: postRefund
public function postRefund()
{
$postdata = Input::all();
$panIDPK = Input::get('pan_id_pk');
$currenttime = Commonmodel::dateandtime();
if (!$panIDPK) {
return Response::json(array('status' => "failed", 'message' => 'Please send a PAN ID'));
} else {
$findrefuncid = Panoffiline::find($panIDPK);
if ($findrefuncid) {
$getcurrentuser = Panoffiline::where('pan_id_pk', '=', $panIDPK)->pluck('pan_created_by');
$response = Panoffiline::where('pan_id_pk', $panIDPK)->get();
if ($response) {
foreach ($response as $res) {
$userfinID = $res->pan_created_by;
$panCoupenNo = $res->pan_coupon_no;
$mainBalance = Userfinance::where('ufin_user_id', $userfinID)->pluck('ufin_main_balance');
$panTotBal = $mainBalance + 106;
$balanceDebit = array('ufin_main_balance' => $panTotBal);
if ($panCoupenNo != '0') {
Userfinance::where('ufin_user_id', '=', $userfinID)->update($balanceDebit);
$coupenReset = array('pan_coupon_no' => '');
Panoffiline::where('pan_id_pk', '=', $panIDPK)->update($coupenReset);
$panCoupenUpdate = array('pc_coupon_no' => $panCoupenNo);
$procode = Products::where('prod_short_name', '=', 'PANM')->pluck('prod_code');
$panledger = array('lr_date' => $currenttime, 'lr_trans_type' => 'CR', 'lr_comment' => 'Pan Refund', 'lr_credit_amount' => '106', 'lr_post_balance' => $panTotBal, 'lr_created_by' => $getcurrentuser, 'lr_prod_code' => $procode);
$panlegcreta = new Ledgerreport();
$panlegcreta->create($panledger);
$coupen = new Coupons();
$coupen->create($panCoupenUpdate);
return Response::json(array('status' => "success", 'message' => 'Amount debited successfully'));
} else {
return Response::json(array('status' => "failure", 'message' => 'PAN Card has been already applied for refund'));
}
}
}
} else {
return Response::json(array('status' => "failure", 'message' => 'No User found for this ID'));
}
}
}