本文整理汇总了PHP中app\Category::whereRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::whereRaw方法的具体用法?PHP Category::whereRaw怎么用?PHP Category::whereRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::whereRaw方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if (!Input::has('typeId')) {
return redirect()->route('dashboard.category.index', ['typeId' => 1]);
}
$typeId = Input::get('typeId');
$assign['categorys'] = $this->Category->whereRaw('parent_id = 0 and type_id = ' . $typeId)->orderByRaw('weight asc, id asc')->get();
return view('dashboard.category.index', $assign);
}
示例2: index
public function index(Request $request)
{
$search = \Request::get('search');
//<-- we use global request to get the param of URI
if ($search) {
$allCategory = Category::whereRaw('category_name = ?', [$search])->orderBy('id', 'asc')->paginate(5);
} else {
$allCategory = Category::orderBy('id', 'asc')->paginate(5);
}
return view('Category.index', ['Categories' => $allCategory]);
}
示例3: affiche
public function affiche($id)
{
$title = "voiture";
$options = $idCategries = array();
$customers = array();
$customer = Customer::all();
foreach ($customer as $c) {
$customers[$c->id] = $c->name . ' ' . $c->last_name;
}
if (isset($id) && !empty($id)) {
$car = Car::findOrFail($id);
$options = current($car->optioncars()->lists('option_id'));
if (!empty($options)) {
$ids = implode(",", $options);
//option ID's
$prices = OptionCar::whereRaw('option_id in (' . $ids . ' ) and car_id=' . $id . ' order by option_id')->get();
foreach ($prices as $price) {
$prices_car[$price->option_id]['price'] = $price->option_price;
$prices_car[$price->option_id]['id'] = $price->id;
}
$optionsList = Option::whereRaw('id in (' . $ids . ' ) order by id')->get();
foreach ($optionsList as $option) {
$el = $option->category_id;
if (!in_array($el, $idCategries)) {
//if not exist in array
array_push($idCategries, $el);
}
}
$idCategries = implode(",", $idCategries);
$categories = Category::whereRaw('id in (' . $idCategries . ')')->get();
foreach ($categories as $cat) {
foreach ($optionsList as $option) {
if ($option['category_id'] == $cat['id']) {
$listcategories[$cat->id]['name'] = $cat->name_category;
$listcategories[$cat->id]['options'][$option->id]['name'] = $option->name;
$listcategories[$cat->id]['options'][$option->id]['description'] = $option->description;
$listcategories[$cat->id]['options'][$option->id]['price'] = $prices_car[$option->id]['price'];
$listcategories[$cat->id]['options'][$option->id]['id'] = $prices_car[$option->id]['id'];
}
}
}
return view('Cars/car-details', ['categories' => $listcategories, 'title' => $title, 'car' => $car, 'customers' => $customers]);
} else {
return view('Cars/car-details', ['categories' => null, 'car' => $car, 'title' => $title]);
}
}
}
示例4: getSlug
public function getSlug($title, $allow_overlap = true)
{
$slug = str_slug($title);
$slugCount = count(Category::whereRaw("slug REGEXP '^{$slug}(-[0-9]*)?\$'")->get());
if ($allow_overlap == false) {
return $slugCount > 0 ? false : $slug;
} else {
return $slugCount > 0 ? "{$slug}-{$slugCount}" : $slug;
}
}
示例5: getCategoriesFront
public function getCategoriesFront($id_car)
{
//$car=Car::where('id',$id_car)->get();
$idCategries = array();
$car = Car::findOrFail($id_car);
$options = current($car->optioncars()->lists('option_id'));
if (!empty($options)) {
$ids = implode(",", $options);
//option ID's
$prices = OptionCar::whereRaw('option_id in (' . $ids . ' ) and car_id=' . $id_car . ' order by option_id')->get();
foreach ($prices as $price) {
$prices_car[$price->option_id]['price'] = $price->option_price;
$prices_car[$price->option_id]['id'] = $price->id;
}
$optionsList = Option::whereRaw('id in (' . $ids . ' ) order by id')->get();
foreach ($optionsList as $option) {
$el = $option->category_id;
if (!in_array($el, $idCategries)) {
//if not exist in array
array_push($idCategries, $el);
}
}
$idCategries = implode(",", $idCategries);
$categories = Category::whereRaw('id in (' . $idCategries . ')')->get();
foreach ($categories as $cat) {
foreach ($optionsList as $option) {
if ($option['category_id'] == $cat['id']) {
$listcategories[$cat->id]['name'] = $cat->name_category;
$listcategories[$cat->id]['icone'] = $cat->icon;
$listcategories[$cat->id]['options'][$option->id]['name'] = $option->name;
$listcategories[$cat->id]['options'][$option->id]['description'] = $option->description;
$listcategories[$cat->id]['options'][$option->id]['price'] = $prices_car[$option->id]['price'];
$listcategories[$cat->id]['options'][$option->id]['id'] = $prices_car[$option->id]['id'];
}
}
}
return $listcategories;
}
}