skip to Main Content

How to get current month record in laravel?

Need to get record of current month but query return the wrong result.There is only one record in db.but i get wrong count for the current month $data = UserData::select( DB::raw("count(phone) as total") ) ->whereMonth('creation_date', Carbon::now()->month) ->get(); return view('kpidata', compact('data'));…

VIEW QUESTION

Laravel HasMany relationship not displaying all records

I have two models EcommerceOrders and Medicines class EcommerceOrders extends Model { use HasFactory; protected $table = 'ecommerce_orders'; protected $fillable = [ 'user_id', 'manager_id', 'first_name', 'last_name', 'phone_number', 'email', 'address', 'city', 'zip_code', 'other_info', 'products', 'total_price', 'qr_code', 'status', 'assigned_to', 'save_client_info', ]; class…

VIEW QUESTION

laravel eloquent chunk ->with method

It seems that eloquent uses a single query for "with" regardless of how many ids there are Book::with('author')->get(); This would trigger those two queries: SELECT * FROM books; SELECT * FROM authors WHERE id IN (...); The second query may…

VIEW QUESTION
Back To Top
Search