Category : Laravel


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

GROUP_CONCAT with different SEPARATOR in laravel Example

Whenever, you need to use GROUP_CONCAT with differente separator(I mean default separator is ',', But you want to change '@','#','&' etc as you want). then you have to use use SEPARATOR keyword in GROUP_CONCAT(). If you are working on laravel then you have to also use DB::raw() for write GROUP_CONCAT() inside the this function. So, Basically how to change seprator in group_concat(), In following example i change ',' separator into '@'.you can use the following example how to use in laravel 4 and 5. <strong>Example:</strong> <pre class="language-php"> $items = DB::table('items') -.....

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

Laravel after login, redirect back to previous url ?

If you are working on laravel and you want to do like: How to redirect back to previous url, After login. after login user you can redirect his previous page as he was before. you can do this, i would like to give you two example. first example is using intended() and second one is using session but i don't know more but i think intended() is not working proper in laravel 5 but you can try in laravel 4. but i am sure i gave you example with session that work well in both. So, you can try any one and get your solution, 1. using intended() and 2. session. <strong>Example 1:</strong> <pre class.....

By Hardik Savani | January 15, 2016 | | 7859 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 | | 1700 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 | | 1431 Viewer | Category : Laravel
READ MORE

Mysql procedure with pagination in laravel 5?

You are working on laravel with mysql database. you had created mysql procedure for get data and you want to call procedure with pagination in laravel 5 then you can not directly make pagination as laravel document.If you are using directly MySQL stored Procedure in your controller, model or repository and you want to give pagination like this way : <pre class="language-php"> $data = DB::select(DB::raw('CALL hardik("hari")'))->paginate(5); </pre> This way you found error in your Laravel 5 website. we can't give directly this way pagination because your procedure will get all the data fr.....

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

How to set URL without http of Other site in Laravel?

you are working on laravel php framework and you want to give any other site URL. we can easily give url using a tag like href="https://www.facebook.com" but if you are work on laravel then it can't redirect on given URL because laravel always redirect on current site, but we have solution of this problem. How to set URL without http or https of Other site in Laravel Website?, i describe as under. For example if you want to give facebook url then you can give this way : <pre class="code language-html"> <a href="//facebook.com" target="_blank">FB</a> </pre> Try this.....

By Hardik Savani | January 10, 2016 | | 914 Viewer | Category : Laravel
READ MORE

How to add ckeditor with image upload in Laravel ?

if you want to use ckeditor in laravel and you also want to add file uploading as well. if you are use simply in php then it is very simple. but if you are set laravel then you fetch many problem like i also fetch lots of problem. Now, i will give you few step to set ckeditor with file uploading and you will easily apply this. this is a very simple to browse your image, file etc upload. use ckeditor in php, use ckeditor in laravel 4, use ckeditor in laravel 5, how to add ckeditor in laravel, laravel ckeditor image upload, laravel ckeditor example, laravel ckeditor sample, ckeditor laravel 4,.....

By Hardik Savani | January 8, 2016 | | 13085 Viewer | Category : Laravel
READ MORE

How to add pagination with union in Laravel 4 and Laravel 5 ?

You are using union and you want to give pagination, but you can't give. i also fetch that problem if you use union with pagination. you have to create pagination manually using Paginator Class. if you are using Laravel 4 then you can use Paginator Class library and if you use Laravel 5 then you have to give help of \Illuminate\Pagination\LengthAwarePaginator Class function. you have to many times need give a manually pagination like if you are using having, union etc. now i am giving you example of Laravel 4 and Laravel 5 both you can do this way. <strong>Laravel 5</strong> <pre class="langu.....

By Hardik Savani | January 6, 2016 | | 6798 Viewer | Category : Laravel
READ MORE

How to create a text file for JSON and file download in Laravel 5?

If you want create your own text file, html file, css file, php file, json file etc in Laravel. then we do not need to use any PHP library or Class because Laravel Framwork Provide its own "File" Facade. File Class through you can create your own html file, txt file, php file etc as you want. File Facade Class also provide several function like you can create file, remove file, update file etc. now i am giving you example of how to create json file in Laravel. you also want to download file that you created now, i mean you want to give download file, then you can also give download that file .....

By Hardik Savani | January 6, 2016 | | 14092 Viewer | Category : Laravel
READ MORE

    Laravel 5.3 - import export csv and excel file into database

    Laravel 5.3 - import export csv and excel file into database

    Open Post

    How to create blade view file using command line in Laravel?

    How to create blade view file using command line in Laravel?

    Open Post

    Laravel 5 - create quick backend admin panel tutorial

    Laravel 5 - create quick backend admin panel tutorial

    Open Post

    Laravel 5 mailchimp api integration from scratch with example

    Laravel 5 mailchimp api integration from scratch with example

    Open Post

    PHP - How to implement Google new reCAPTCHA Code Example with Demo?

    PHP - How to implement Google new reCAPTCHA Code Example with Demo?

    Open Post

    Laravel 5 - Image Upload and Resize Example using Intervention Image Package

    Laravel 5 - Image Upload and Resize Example using Intervention Image Package

    Open Post