Shilpa Kalangutkar has Published 53 Articles

How to add a new value to a collection in Laravel?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 12:09:46

11K+ Views

Collection in Laravel is an API wrapper that helps you deal with different operations to be performed on arrays. It makes use of the class Illuminate\Support\Collection to deal with arrays in Laravel. To create a collection from a given array you need to make use of the collect() helper method ... Read More

How to delete a single record in Laravel 5?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 12:08:06

427 Views

There are different ways you can do it. Let us test a few examples that help us delete a single record in Laravel. Assume we have created a table named users table as shown below − mysql> select * from users; +----+---------------+------------------+--------------+------------+------+ | id | name ... Read More

How to check if a user email already exists in Laravel?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 12:05:43

4K+ Views

There are many ways you can test if email exists. One way is using the validator class. To make use of validator you need to include the class as shown below; use Illuminate\Support\Facades\Validator; Example 1 The example shows how to make use of Validator to check if email is ... Read More

How to order the results of related models in Laravel Eloquent?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 12:00:22

331 Views

Laravel Eloquent comes with the orderBy() method that can be used to order the results from the model. We are going to make use of Users table as shown below − Let us create another table user_roles with following data − Example 1 Following examples show how to ... Read More

How to update a query on Laravel Fluent using db::raw?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 09:12:45

6K+ Views

You can make use of db::raw when you want to test or use some arbitrary string inside the fluent query builder. To work with db::raw you have to make use of the DB facade class − use Illuminate\Support\Facades\DB; Here are a few examples that show the use of DB:raw(). ... Read More

How to chunk results from a custom query in Laravel?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 09:06:15

6K+ Views

If your database table has lots of data, chunk() method is the best to use. The chunk() method can be used on the DB facade and also on Eloquent models. The chunk() takes care of fetching a small amount of data at a time and the result is present inside ... Read More

How to check if a cookie is set in Laravel?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 09:00:46

3K+ Views

When you visit a web page it, usually generates text files that contain small pieces of data such as username and password, and stores them on the user’s browser. These are knowns cookies they used to identify user system and can be accessed by the web server or the client ... Read More

How do Laravel Eloquent Model Attributes map to a table?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 08:53:12

2K+ Views

Eloquent is a new object relational mapper (ORM) that helps to interact with databases. With Eloquent each table has a mapping Model that takes care of all the operations on that table. Model in Laravel represents the table in the database. For example, if you have table customers, the model ... Read More

How to check database connections in Laravel?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 08:44:06

18K+ Views

Laravel database configuration is stored inside config/database.php. The list of database configurations is listed inside this file. By default, you need to tell Laravel which database you are going to make use of. The default database used is mysql and we are going to stick to it and check the ... Read More

How to obtain a list of all files in a public folder in Laravel?

Shilpa Kalangutkar

Shilpa Kalangutkar

Updated on 30-Aug-2022 08:34:14

2K+ Views

To get the list of all files from public folder you can make use of File facade. To work with it you need to include following class use Illuminate\Support\Facades\File; Following files are present inside public folder −Example 1 To get all files from public folder

Advertisements