Latest Laravel Post


How to get last inserted id in laravel 5?

Its very common need to get last insert id in programming field, if you are working on laravel framework and you want to fetch last created id, i mean max id, then you do easily.laravel provide method to get last inserted id. If you are working with DB::table() then you have to use insertGetId() for insert data into database. this function always return inserted record id(primary key).it is very simple way to get id, in following example you can see and undestand more: <strong>Example:</strong> <pre class="language-php"> public function getLastInsertedIdDB() { $id = DB::table('items')->inser.....

By Hardik Savani | February 6, 2016 | | 5978 Viewer | Category : Laravel
READ MORE

How to increment or decrement a column value in laravel?

Whenever you need to increment or decrement value of column in database, then you do not need to first fetch that record and then update, so that way we will make long code and very hard code, so basically you can increment and decrement by using increment() and decrement() statment of laravel query builder. If you want to increment or decrement opration using update() method of laravel query builder then you also do that, in following example i am showing you how to increment and decrement value of column in table by using increment(), decrement() and update(). <pre class="language-php"> na.....

By Hardik Savani | February 2, 2016 | | 2800 Viewer | Category : Laravel
READ MORE

How to add text on image in laravel 5?

if you are use laravel and you want to add text on image or resize, crop image then we can do with "intervention/image" pakacke. you have to just follow few step and you can add text on image. <strong>Step 1 : </strong>you have to add package on your laravel project by using composer like : <pre>composer require intervention/image</pre> <strong>Step 2 :</strong> then you have to add provider path and alias path in config/app.php file like : In $provides : <pre>'Intervention\Image\ImageServiceProvider'</pre> In $aliases : <pre>'Image' => 'Intervention\Image\Facades\Image'</pre> <strong>.....

By Hardik Savani | January 30, 2016 | | 2649 Viewer | Category : Laravel
READ MORE

How to get days difference between two dates in laravel?

Whenever you need to get difference between two dates in date in laravel 5 then you can get easily using Carbon. Laravel by default provide Carbon class. Carbon class throught you can calculate difference between two dates in days. In Following example you can see, we have a two dates, first $to variable and second one $from variable. Carbon class diffInDays function using you can get difference between two dates. I hope you will find your solution. <strong>Example:</strong> <pre class="language-php"> $to = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', '2015-5-5 3:30:34'); $from = \Carbon\.....

By Hardik Savani | January 29, 2016 | | 2227 Viewer | Category : Laravel
READ MORE

HTML/FORM not found in Laravel 5?

If you want to use Form or Html class and when you will see error like ‘HTML’ class not found OR ‘Form’ class not found. don’t worry about that because Laravel 5 change the package. you should download the HTML and FORM class helper from given instruction above. Add given bellow text to your composer.json file. <pre>"require": { "laravel/framework": "5.0.*", "laravelcollective/html": "~5.0" },</pre> <strong>OR</strong> <pre>composer require laravelcollective/html</pre> after fire composer update command After Update composer, open config/app.php and add this line to the ‘providers.....

By Hardik Savani | January 27, 2016 | | 3906 Viewer | Category : Laravel
READ MORE

PHP Laravel – How to solve “You need to specify a file path to store the seed laravel ” ?

when you install laravel and get the records from database then occur “You need to specify a file path to store the seed laravel” error. that error happened because your php can not loading openssl extension. so, If you are using windows then you should enable openssl extension in following path : <pre> Path : C:\wamp\bin\apache\Apache2.4.4\bin </pre> Find: <pre> ;extension=php_openssl.dll INTO extension=php_openssl.dll </pre> Try this..........

By Hardik Savani | January 25, 2016 | | 555 Viewer | Category : Laravel
READ MORE

Order by using multiple columns and manually array field in Laravel?

If you want to sort multiple columns in Laravel by using orderBy(). Whenever you need to give multiple column in your query then you can use twice time orderBy() and give them. you can give multiple columns in laravel by following example : <strong>Users Table :</strong> <table class="table table-bordered pagin-table"><tbody><tr><th>id</th><th>site_id</th><th>sub_site_id</th><th>name</th><th>email</th></tr><tr><td>1</td><td>4</td><td>7</td><td>john</td><td>john@gmail.com</td></tr><tr><td>2</td><td>3</td><td>4</td><td>ram</td><td>ram@gmail.com</td></tr><tr><td>3</td><td>4</td><td>2</td><td>ade.....

By Hardik Savani | January 25, 2016 | | 4641 Viewer | Category : Laravel
READ MORE

How to add Delete cascade to existing column in Laravel 5, without remove column?

Whenever you are making table using migration with foreign key. like i give you example as under and you forgot to set delete cascade on table then how can you add delete cascade in existing table. so let's see your migration : <pre class="language-php"> public function up() { Schema::create('locations', function (Blueprint $table) { $table->increments('id'); $table->integer('id_option')->unsigned(); $table->foreign('id_option')->references('id')->on('options'); $table->decimal('lng',11,8); $table->string('streetAddress1'); $table->decimal('lat',11,8); .....

By Hardik Savani | January 24, 2016 | | 1714 Viewer | Category : Laravel
READ MORE

How to set gmail configration for mail in Laravel?

If you are working with laravel and you need to setup gmail configration for send email. if you want to set configration of gmail then first go to mail.php file, you are work on laravel 4 and laravel 5 its not issue, because you can set comman setting for both version of laravel framwork. <strong>Mail.php</strong> <pre class="language-php"> 'driver' => smtp, 'host' => smtp.gmail.com, 'port' => 587, 'from' => ['address' => 'test@gmail.com', 'name' => 'Test'], 'encryption' => tls, 'username' => test@gmail.com, 'password' => test123, 'sendmail' => '/usr/sbin/sendm.....

By Hardik Savani | January 22, 2016 | | 1972 Viewer | Category : Laravel
READ MORE

How to create and check custom header with middleware for REST API in Laravel 5 ?

In Laravel 5 REST API project sometime we need to create create our own custom header for security. like : 'X-hardik':'123456'. this was example, that means in your current project your every request with pass your own custom header like i give you example.this custom header can improve your security. we can also check your header is right or wrong.example : <strong>Your Jquery or AngularJS Request</strong> <pre class="language-javascript"> $.ajax({ type: 'POST', dataType: 'json', url: 'http://test.hd/api/login', headers: { 'X-hardik': '123456'}.....

By Hardik Savani | January 20, 2016 | | 2414 Viewer | Category : Laravel
READ MORE

    Bootstrap progress bar animate example using bootstrap-progressbar.js

    Bootstrap progress bar animate example using bootstrap-progressbar.js

    Open Post

    Response download with file in Laravel 5.3 example

    Response download with file in Laravel 5.3 example

    Open Post

    AngularJS - simple image upload with preview example in PHP

    AngularJS - simple image upload with preview example in PHP

    Open Post

    Simple Add remove input fields dynamically using jquery with Bootstrap

    Simple Add remove input fields dynamically using jquery with Bootstrap

    Open Post

    Laravel guzzle http client POST request example

    Laravel guzzle http client POST request example

    Open Post

    Bootstrap - Show/Hide(toggle) Password input field using bootstrap-show-password.js Plugin

    Bootstrap - Show/Hide(toggle) Password input field using bootstrap-show-password.js Plugin

    Open Post