Tag : WHERE Query


Laravel 5 - whereIn and whereNotIn with subquery example using query builder

As you know laravel is very popular php framework in today. So every point will be require for database related and that important. In this post i would like to share with you how to use subquery with whereIn and whereNotIn clause from scratch. We may sometimes require to use select query with where in or where not in clause. we can simply make query using MySQL. But we don't know how to use it on laravel query builder. However, In this example we will learn how to convert mysql query into laravel query builder of wherein with subquery. This example is from scratch, so i will give you first m.....

By Hardik Savani | March 23, 2017 | | 9443 Viewer | Category : Laravel MySql
READ MORE

Laravel 5.3 - whereDate(), whereMonth(), whereDay() and whereYear() examples.

Laravel is a very popular PHP framework. Laravel 5.3 release few days ago and there are several new feature added by Laravel. Laravel 5.3 introduce several new where conditions like whereDate(), whereMonth() etc in Query Builder. Today, i am going to show you how to use it in your Laravel Application. I give you one example table and understand how works this four query builder functions one by one. So, first you can see bellow table with some records. <strong>products table</strong> <img src="/upload/product-table.png" style="width:100%;border:1px solid red"> <strong>whereDate()</strong> .....

By Hardik Savani | September 6, 2016 | | 16385 Viewer | Category : Laravel
READ MORE

How to get current month records in Laravel 5?

In this post, i give you example query of how to fetch current month records from table using Laravel query builder. We sometimes require to get records that created on current month. i.e if current month is august and we need display records of august month on out admin dashboard. In this example you can see how can get you current month records and i used whereRaw() of laravel query builder with MONTH() mysql that way we can get month and compare with current month. I have one created items table that structure as bellow you can see. <strong>items table</strong> <img src="/upload/laravel-.....

By Hardik Savani | August 7, 2016 | | 7007 Viewer | Category : Laravel
READ MORE

Laravel 5 - where condition with two columns example code

Laravel 5 introduce whereColumn() in Query Builder, that way we can compare two column like simple where condition. We sometimes require to check this type of condition. In this example code, i have simple "items" table and i want to get only created_at and updated_at column should equals. So you can also check bellow laravel eloquent as bellow: <strong>Example:</strong> <pre class="prettyprint lang-php"> $data = DB::table("items") ->whereColumn('created_at','updated_at') ->get(); print_r($data); </pre> <strong>Example 2:</strong> <pre class="prettyprint lang-php"> .....

By Hardik Savani | July 29, 2016 | | 2309 Viewer | Category : Laravel
READ MORE

Laravel where clause with date_format() example

In this post, i share with you that how to use date_format() with where condition of Laravel query builder. When i was working on my project, i require to search with get only selected month and year records from created_at(timestamp) column. I was thinking how can i but i know date_format() of mysql. but don't know how to use in laravel where clause. At last i use DB::raw() of Laravel and it's work. If you have also need to search this way then you can do it this way: <strong>Example:</strong> <pre class="prettyprint lang-php"> $data = DB::table("items") ->select("id","title","creat.....

By Hardik Savani | June 22, 2016 | | 2664 Viewer | Category : Laravel
READ MORE

Laravel 5 - like query example using eloquent where clause.

Whenever you require to use select like query in your application then you can easily use. Laravel 5 provide query builder and mysql like condition is very simple to use. So let's see bellow example did convert bellow sql query. <strong>SQL Example:</strong> <pre> SELECT * FROM `users` WHERE `name` LIKE '%hdtopi%'; </pre> <strong>Laravel Query Example:</strong> <pre> $search = 'hdtopi'; $user = User::where('name','LIKE',"%{$search}%") ->get(); print_r($user); </pre>

By Hardik Savani | April 28, 2016 | | 16559 Viewer | Category : Laravel
READ MORE

    Laravel 5 - Custom Helper Facade Class Example from scratch

    Laravel 5 - Custom Helper Facade Class Example from scratch

    Open Post

    Laravel 5 - Create modular structure application example using L5Modular package

    Laravel 5 - Create modular structure application example using L5Modular package

    Open Post

    Ajax Image Upload Example with Validation in PHP Laravel Framework

    Ajax Image Upload Example with Validation in PHP Laravel Framework

    Open Post

    Laravel 5 - Full Text Search Example using Scout and Algolia Packages

    Laravel 5 - Full Text Search Example using Scout and Algolia Packages

    Open Post

    Laravel 5.4 - send email using Markdown Mailables

    Laravel 5.4 - send email using Markdown Mailables

    Open Post

    Laravel 5 mailchimp api integration from scratch with example

    Laravel 5 mailchimp api integration from scratch with example

    Open Post