Laravel Popular Post


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 | | 1390 Viewer | Category : Laravel
READ MORE

How to execute artisan commands from route or controller in Laravel ?

Sometimes we require to run php artisan command from route or controller file in out Laravel Application, However we can do it using Artisan facade. Laravel Artisan facade that way we can easily run all artisan command with argument. Artisan facade have two method call() and queue(), queue() through we can simply make process in queue like email sending etc. So let's see simple example with route. In this example we run "php artisan migrate" command using artisan facade. Here i bellow example you can learn how you can run artisan commands from route. <strong>Example:</strong> <pre class="pre.....

By Hardik Savani | February 12, 2017 | | 1339 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 | | 1319 Viewer | Category : Laravel
READ MORE

Laravel tokenmismatchexception in verifycsrftoken.php - Solved

When i had started to learn laravel, i found error - tokenmismatchexception in verifycsrftoken.php when submit form POST method. I was new i can't understand what is the error. but i read docs and search google i found that i need to add laravel csrf_token as hidden parameter. csrf_token() is for security reason, Laravel use Middleware VerifyCsrfToken to check csrf token is valid or not, so you have to just add bellow line in your form: <pre> <input type="hidden" name="_token" value="{{{ csrf_token() }}}" /> </pre>

By Hardik Savani | July 10, 2016 | | 1308 Viewer | Category : Laravel
READ MORE

How to increase throttle lockout time and max Login Attempts in Laravel 5?

you implement throttle in you laravel 5 application and you want to increase lockout time or max Login Attempts then you can do it using laravel method overwrite. In this example i will show you how to increase throttle lockout time and max Login Attempts. you have to just add two method in your AuthController controller file. Let's copy this two method and paste on your AuthController controller file and check. <pre class="prettyprint lang-php"> private function lockoutTime() { return property_exists($this, 'lockoutTime') ? $this->lockoutTime : 8; } <br/> protected function maxLoginAttem.....

By Hardik Savani | June 2, 2016 | | 1295 Viewer | Category : Laravel
READ MORE

How to get file size from URL in Laravel 5?

We sometimes require to get file size from path in laravel, so if you need to get file size from url then no worry and you can get using File facade. File facade provide several function that way we can get size of file or image. In bellow example i just give you path of my images folder inside public folder and one image, that give path as argument of size function: <strong>Example:</strong> <pre class="prettyprint lang-php"> {{ File::size(public_path('images/1461177230.jpg')) }} </pre>

By Hardik Savani | July 18, 2016 | | 1277 Viewer | Category : Laravel
READ MORE

How to get last executed mysql query in laravel ?

If you are working on laravel framwork and you use query builder of laravel 5. but you want to get last executed mysql query from laravel. If you are working on laravel 5 then you have to first enable query log that way it can be store query log. At last getQueryLog() through you can get last executed query. I give you example of how to get last executed mysql query. you can use example as following example. <pre class="language-php"> public function querylog() { DB::enableQueryLog(); $item = Item::find(2); $last_query = DB::getQueryLog(); print_r($last_query); } </pre> Try this......

By Hardik Savani | January 11, 2016 | | 1221 Viewer | Category : Laravel
READ MORE

How to count number of files in folder and remove all files in folder example in Laravel 5 ?

you are working on laravel framwork and you want to count how many image or files in folder and print of front then you can do with laravel "File" class.you can also count in core PHP by using glob() but if you are working on laravel then you have to use 'File' class library and it is easy and more flexible to use. If you also want to remove all the files Or images in specific folder then you can delete by using "File" class function. sometimes we need to delete files in the folder. that way: <pre class="language-php"> use Input; use File; class HomeController extends AdminController { .....

By Hardik Savani | January 13, 2016 | | 1213 Viewer | Category : Laravel
READ MORE

How to get size of directory in MB Laravel 5?

Mostly we require to calculate for uploaded directory size because we can see how much we size allocate in uploaded directory. If you have limited server then you always need to check how much size of data in my folder. You can also get size of directory that way you can also display on your admin panel. Laravel provide File facade. File facade through we can get folder size in kb or mb or gb etc. In bellow example i have <strong class="path">images directory</strong> in public folder. so we can get size for images folder like this way : <strong>Example:</strong> <pre class="prettyprint la.....

By Hardik Savani | July 23, 2016 | | 1200 Viewer | Category : Laravel
READ MORE

How to resolve - No supported encrypter found. The cipher and / or key length are invalid. in Laravel 5

I did get "No supported encrypter found. The cipher and / or key length are invalid" error when i clone my laravel project. But when i run project on browser i was getting this error i did try to solve this error, finally i found bellow error you can generate application key by using bellow command: <strong>Run Command:</strong> <pre class="prettyprint lang-php"> php artisan key:generate </pre>

By Hardik Savani | May 4, 2016 | | 1167 Viewer | Category : Laravel
READ MORE


    Laravel 5 Twitter OAuth using Socialite Package

    Laravel 5 Twitter OAuth using Socialite Package

    Open Post

    PHP - Behance API tutorial with example and demo

    PHP - Behance API tutorial with example and demo

    Open Post

    Dynamic Autocomplete search using Bootstrap Typeahead JS Example

    Dynamic Autocomplete search using Bootstrap Typeahead JS Example

    Open Post

    Jquery - Show hide password in Password textbox using checkbox.

    Jquery - Show hide password in Password textbox using checkbox.

    Open Post

    Laravel 5 - Multiple markers in google map using gmaps.js

    Laravel 5 - Multiple markers in google map using gmaps.js

    Open Post

    How to disable model timestamps in Laravel 5.3?

    How to disable model timestamps in Laravel 5.3?

    Open Post