Query / ORM IN ARAVEL
get the table data in laravel
$status = Status::orderBy('id')->get();
You can set function to get the value from model
suppose you want to get the enable/disable restaturant status
{{App\Status::getStatus($restaurant->status_id)}}
add Function on status Model
public static function getStatus($id)
{
$Status=Status::find($id);
return $Status->name; //enable
}
Get the Order from table by user Where, orderBy,
$order_list = Order::Where('user_id',"=",$id)->orderBy('id','desc')->orderBy('created_date','desc')->get();
Cart::where(['user_id'=>$user_id,'item_id'=>$item_id])->first();
Call Function Of a class in blade file
{{ \App\User::getUserFullname($id) }}
Get One Records using first
$restaurant = Restaurants::where("restaurant_slug", $slug)->first();
DB QUERY
@if(DB::table('cart')->where('user_id', Auth::id())->sum('item_price')>0)
{{$price = DB::table('cart')->where('user_id', Auth::id())->sum('item_price')}}
$restaurants = DB::table('restaurants')
->leftJoin('restaurant_types', 'restaurants.restaurant_type', '=', 'restaurant_types.id')
->select('restaurants.*','restaurant_types.type')
->where('restaurants.review_avg', '>=', '4')
->orderBy('restaurants.review_avg', 'desc')
->take(6)
->get();
Find or fail
$testimonials = Testimonial::findOrFail($id);
Foreach in blade file
@foreach(\App\Categories::where('restaurant_id',$restaurant->id)->orderBy('category_name')->get() as $n=>$cat)
{{$cat->name}}
@endforeach
$find_cart_item->increment('quantity');
{{ \App\OrderMaster::getstatus($order_id)->status}}
{{ \Carbon\Carbon::parse($order_item->created_at)->format('m-d-Y')}}
Order::where('order_id', $order_id)->delete();
$status = Status::orderBy('id')->get();
You can set function to get the value from model
suppose you want to get the enable/disable restaturant status
{{App\Status::getStatus($restaurant->status_id)}}
add Function on status Model
public static function getStatus($id)
{
$Status=Status::find($id);
return $Status->name; //enable
}
Get the Order from table by user Where, orderBy,
$order_list = Order::Where('user_id',"=",$id)->orderBy('id','desc')->orderBy('created_date','desc')->get();
Cart::where(['user_id'=>$user_id,'item_id'=>$item_id])->first();
Call Function Of a class in blade file
{{ \App\User::getUserFullname($id) }}
Get One Records using first
$restaurant = Restaurants::where("restaurant_slug", $slug)->first();
DB QUERY
@if(DB::table('cart')->where('user_id', Auth::id())->sum('item_price')>0)
{{$price = DB::table('cart')->where('user_id', Auth::id())->sum('item_price')}}
$restaurants = DB::table('restaurants')
->leftJoin('restaurant_types', 'restaurants.restaurant_type', '=', 'restaurant_types.id')
->select('restaurants.*','restaurant_types.type')
->where('restaurants.review_avg', '>=', '4')
->orderBy('restaurants.review_avg', 'desc')
->take(6)
->get();
Find or fail
$testimonials = Testimonial::findOrFail($id);
Foreach in blade file
@foreach(\App\Categories::where('restaurant_id',$restaurant->id)->orderBy('category_name')->get() as $n=>$cat)
{{$cat->name}}
@endforeach
$find_cart_item->increment('quantity');
{{ \App\OrderMaster::getstatus($order_id)->status}}
{{ \Carbon\Carbon::parse($order_item->created_at)->format('m-d-Y')}}
Order::where('order_id', $order_id)->delete();
Dear Admin,
ReplyDeleteThis Blog Is Really Nice Blog Thanks For Sharing.
Dear Admin,
I am Ryan Mitchell Oregon. Very informative post! I am thankful to you for providing this unique information.
Ryan Mitchell Portland Oregon — A businessman (Ryan Mitchell Oregon) is a person involved in the business sector — in particular someone undertaking activities
Ryan Mitchell Oregon
Ryan Mitchell Portland Oregon
ryan mitchell rex putnam
Ryan Mitchell Oregon
Ryan Mitchell Portland Oregon
ryan mitchell rex putnam
Ryan Mitchell Oregon
Ryan Mitchell Portland Oregon
ryan mitchell rex putnam
Ryan Mitchell Oregon
Ryan Mitchell Portland Oregon
ryan mitchell rex putnam
Ryan Mitchell Oregon
Ryan Mitchell Portland Oregon
ryan mitchell rex putnam