In the Eloquent Model you can make use of whereNotNull() method to get the not null values from the database. Example 1 In this example we are checking the field rememer_token if it’s NOT NULL.
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 that returns a collection instance. Later you can use a chain of methods like converting to lowercase, sorting on the collection instance. Example 1
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 | email | password | address | age | +----+---------------+------------------+--------------+------------+------+ | 1 | Siya Khan | siya@gmail.com | hgfdv3vhjd ... Read More
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 registered or not.
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 make use of orderBy to order results.
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(). Example 1
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 the closure for processing. Consider the following users table that has 1000 records in it. We are going to make use of chunk() to retrieve 100 records at a time.Example 1
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 computer (on which they are stored). The information stored in the cookies is specific to a web server. Once you connect to a server a cookie is created labeled with a unique ID and stored in your computer. Once a cookie is exchanged/stored in a client, and if you ... Read More
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 name will be customer, for users it will be user, employees it will be employee. The table name has to be plural and the model name has to be singular. This is a pattern followed, but that does not stop you from using the naming convention of your choice for ... Read More
This tutorial will teach you how to disable JavaScript in the Opera web browser. The latest version as used in this tutorial is Version− 89.0.4447.71. About JavaScript The dynamic programming language JavaScript, also known as ECMAScript, was created to provide control over the components of a web application. Your browser loads something on a website known as the Document Object Model (DOM), and JavaScript may work with the items in the DOM to, for example, make a web application responsive to the user. JavaScript is responsible for the existence of every animated menu system, any web form validation or submission, ... Read More