Skip to content
Codewolfy Logo

Codewolfy

  • Privacy Policy
  • Terms of Use
  • Contact Us
  • About Us

Eloquent

  • Home
  • Eloquent
  • Page 2
Check Database Connection in Laravel
  • Database

Check Database Connection in Laravel

In this example, we will check the database connection in Laravel. Before starting to create a new Laravel application start your database services like XAMPP or WAMPP and change database credentials in the .env file. Here, we will check database is connected and get an active database name using DB helper. To check database exists

Learn More about Check Database Connection in Laravel
2 years ago2 months ago
Get SQL Query in Laravel
  • Laravel

Get SQL Query in Laravel

Sometimes retrieving data in Laravel can return incorrect results or unexpected values. To debug or optimize these cases, we often need to get SQL query in Laravel and inspect the exact query executed. Laravel provides multiple ways to convert Eloquent queries into raw SQL queries, making it easier to analyze and troubleshoot database operations. Using

Learn More about Get SQL Query in Laravel
2 years ago2 months ago
Create Custom Method In Laravel Model
  • Laravel

Create Custom Method In Laravel Model

In Laravel, you can create a custom method in Laravel model to handle specific logic like formatting dates or manipulating attributes. This approach keeps your code organized and reusable whenever you access model data. For instance, we will define a custom method in the model to convert date objects using Carbon and apply type casting,

Learn More about Create Custom Method In Laravel Model
2 years ago2 months ago
Delete All Data From Eloquent Model
  • Laravel

Delete All Data From Eloquent Model

In many applications, we often need to clear all records from a database table. For example, tables storing temporary data like session logs, cache records, or daily reports require regular cleanup to maintain performance. In Laravel, we can delete all data from an Eloquent model easily. This removes all rows while keeping the table structure

Learn More about Delete All Data From Eloquent Model
2 years ago2 months ago
Check Collection Is Empty or not in Laravel
  • Laravel

Check Collection Is Empty or not in Laravel

In Laravel, collections are a common way to store and work with data. Sometimes, we need to check collection is empty or not in Laravel before performing operations to avoid errors or unexpected results. The Collection class provides many methods similar to array functions, making it easy to manipulate and access data. There are several

Learn More about Check Collection Is Empty or not in Laravel
2 years ago2 months ago
Convert Collection Into JSON In Laravel
  • Laravel

Convert Collection Into JSON In Laravel

Laravel uses collection classes as a common way to store data. However, when working with APIs, you often need to convert collection into JSON in Laravel to return response data in a format that clients can use. In this tutorial, you will learn how to transform collection data into JSON strings. This can include model

Learn More about Convert Collection Into JSON In Laravel
2 years ago2 months ago
Adding Soft Delete to Every Model and Migration
  • Laravel

Adding Soft Delete to Every Model and Migration

In enterprise-level applications sometimes we need to restore deleted data or need to take a backup of that data. With Larave soft delete, we can easily soft delete and restore deleted data and in addition to methods, we can automatically filter deleted data while querying. In Laravel, the Soft Delete trait handles all the operations

Learn More about Adding Soft Delete to Every Model and Migration
2 years ago2 months ago
Get Array of IDs from Eloquent Collection or Model
  • Laravel

Get Array of IDs from Eloquent Collection or Model

Getting an array of IDs from a database or collection is common in Laravel. Get Array of IDs from Eloquent Collection or Model efficiently using methods like pluck() or modelKeys() instead of manual loops. These methods simplify retrieving only the ID values and make your code cleaner and faster. Let’s assume you are using a

Learn More about Get Array of IDs from Eloquent Collection or Model
2 years ago2 months ago
Resize Images in Laravel with Spatie Media Library
  • Laravel

Resize Images in Laravel with Spatie Media Library

Working with images can be easily done using Laravel. But if you use Laravel Spatie Media Library then you can easily bind images to multiple models and perform image manipulation functions like image conversion. If there is a requirement to convert and save a resized image version while uploading the file, like generating a thumbnail

Learn More about Resize Images in Laravel with Spatie Media Library
2 years ago2 months ago
Retrieve Laravel Model by Multiple IDs
  • Laravel

Retrieve Laravel Model by Multiple IDs

Finding data by ID or IDs is commonly used. Here we search or query the primary key of the model and get data. In this tutorial, we will see some methods to get data by multiple IDs. To get a database record from Laravel Eloquent by ID or Multiple IDs, we can use of Model

Learn More about Retrieve Laravel Model by Multiple IDs
2 years ago2 months ago
  • Previous page
  • 1
  • 2
  • 3
  • Next page

Recent Posts

  • How to Validate API Requests in Node.js Express Using Joi
  • How to Use Winston for Logging in Node.js with Examples
  • Building Reliable Queues in Node.js with Redis and BullMQ
  • Build a Custom API Rate Limiter in Node.js From Scratch
  • Implement Rate Limiting in Node.js with Express-Rate-Limit

Categories

  • AI (4)
  • Angular (4)
  • Apache (1)
  • Apache 2 (2)
  • API (5)
  • Array (3)
  • Barcode (5)
  • Ckeditor (1)
  • Composer (2)
  • CSS (1)
  • CURL (1)
  • Database (4)
  • Django (2)
  • Express (9)
  • Facebook APIs (1)
  • FastAPI (1)
  • Filament (5)
  • Filament 4 (2)
  • Flask (1)
  • Form Validation (5)
  • FTP (1)
  • Git (1)
  • Google (3)
  • Highchart (1)
  • JavaScript (20)
  • jQuery (23)
  • Jquery UI (3)
  • JSON (6)
  • Laravel (126)
  • Library (2)
  • MongoDB (7)
  • MySql (5)
  • NestJS (1)
  • Node JS (28)
  • Payment Gateway (1)
  • PHP (50)
  • Python (22)
  • React JS (2)
  • Redis (1)
  • Software install (11)
  • SQL (1)
  • TypeScript (1)
  • Ubuntu (14)
  • Uncategorized (5)
  • Vue.JS (3)
  • XAMPP (1)
Codewolfy Logo

Codewolfy is online learning platform for beginners and experienced. which covers web development, software development and programming.

Quick Links

  • Privacy Policy
  • Terms of Use
  • Contact Us
  • About Us

  • Laravel (126)
  • PHP (50)
  • Node JS (28)
  • jQuery (23)
  • Python (22)

@ 2025 Codewolfy.