Category : Laravel



Laravel 5 export to pdf using maatwebsite example

In this post i will show you how to export or download pdf file from database table by maatwebsite. maatwebsite packages throught you can easily generate pdf file. so now i show you simple example of items table data, you can donwload in pdf formate. In following few step you can implement export both function in your project. we have to also need to use dompdf package for pdf generater. let's follow step. <strong class="step">Step 1: Installation</strong> Open your composer.json file and add bellow line in required package. <strong>Laravel 5</strong> <pre>"maatwebsite/excel": "~2.1.0"</pre> <.....

By Hardik Savani | March 9, 2016 | | 68417 Viewer | Category : Laravel
READ MORE

How to use where clause with mysql function in Laravel 5?

When you are working on laravel projects and you need to use mysql function in where clause then you can easily use that using DB::raw() and whereRaw(). In this example you can show how to i use mysql function in where clause. In this example i want to compare with year of created_at field but not whole date, that's whay i use mysql function Year(), this function will return only year from timestamp and compare with given value. I add two example of how to use sql function in where cause. let's See both example. <strong class="example">Example 1:</strong> <pre class="prettyprint lang-sql"> $da.....

By Hardik Savani | March 9, 2016 | | 3828 Viewer | Category : Laravel
READ MORE

How to get latitude longitude from mysql in laravel 5?

Whenever you need to get nearest posts from lat and long and if you are working on laravel query builder. then you can get distance easily using DB::raw(), so you can learn from following example how to get nearest value from mysql laravel. <strong>Example:</strong> <pre class="prettyprint lang-php"> $lat = 1; $lon = 1; DB::table("posts") ->select("posts.id" ,DB::raw("6371 * acos(cos(radians(" . $lat . ")) * cos(radians(posts.lat)) * cos(radians(posts.lon) - radians(" . $lon . ")) + sin(radians(" .$lat. ")) * sin(radians(posts.lat))) AS distance")) ->groupBy("posts.id") ->ge.....

By Hardik Savani | March 8, 2016 | | 5853 Viewer | Category : Laravel
READ MORE

How to add mysql trigger from migrations in Laravel 5?

Sometimes you require to add trigger in your mysql database of laravel 5. but you think how to create trigger using laravel migration because laravel not provide special function like insertTrigger and something so it problem to create direclty, But laravel DB::unprepared() through we can create trigger for database. In Following example you can see how to create migration and create trigger code and how to write drop trigger code, so let's do it this way. <strong class="step">Create Migration:</strong> <pre>php artisan make:migration add_trigger</pre> <strong class="step">Migration:</stron.....

By Hardik Savani | March 8, 2016 | | 11596 Viewer | Category : Laravel
READ MORE

How to confige Elasticsearch in our local system

In this tutorials we have learn how to configer a Elastic search in our local system. follow this step and easily configer an Elastic Search. <strong class="step">1) Step 1 — Installing Java :</strong> -Before installing OpenJDK with APT, update the list of available packages for installation on your Ubuntu Droplet by running the command: <pre class="prettyprint lang-php prettyprinted"> <span style="color:#FFFFFF;font-weight:900;">$ sudo apt-get update</span> </pre> -After that, you can install OpenJDK with the command: <pre class="prettyprint lang-php prettyprinted"> <span style="color:#.....

By Hardik Savani | March 7, 2016 | | 7874 Viewer | Category : Laravel
READ MORE

Laravel 5 query builder where exists example

you use sql where exists clause in laravel. whereExists through you can use sql where exists clause in your laravel project. It is very easy to use and you can easily undestand. You can give SELECT statment in where condition. you can see bellow example and you can learn how to use whereExists in your app. <strong>SQL Query</strong> <pre class="prettyprint lang-sql"> SELECT * FROM `items` WHERE EXISTS (SELECT `items_city`.`id` FROM `items_city` WHERE items_city.item_id = items.id) </pre> <strong>Using Laravel Query Builder</strong> <pre class="prettyprint lang-php"> DB::table('it.....

By Hardik Savani | March 7, 2016 | | 9871 Viewer | Category : Laravel
READ MORE

How to resolve laravel 5 blank page on server?

When i was created my laravel 5.2 application and i upload application on live GoDaddy server. But i found blank page. I think First you have to check php version on live server. if you run laravel 5+ application then make sure your PHP version at least <strong class="path">PHP 5.5</strong>. But, again i don't know why it was blank page and i checked permission of storage folder 777. so basically when you found blank page on your shared hosting the first make sure permission on <strong class="path">storage Directory 777 Permission</strong>. But if you can't solve and found again then also ch.....

By Hardik Savani | March 6, 2016 | | 7766 Viewer | Category : Laravel
READ MORE

How to use DB transactions in laravel 5?

First, Let's undestand why we are use transactions in laravel project. But db transactions is very important concept and very usefull because it securely manage. laravel 5 also provide to transactions commit, rollback etc functions. How to use transactions in my project, so I an going to give you one example, I have a three table "items", "items_city" and "items_count" and i need to add new row same time and "items" table is a main table then "items_city" and "items_count" is a child table of "items" table. so bassically why we nee to use transactions because if when i was add new records in d.....

By Hardik Savani | March 6, 2016 | | 5106 Viewer | Category : Laravel
READ MORE

How to create middleware for XSS protection in laravel 5?

XSS(Cross Site Scripting) protection must need in your site because if you do not XSS protection then your site is not secure. XSS filter through you can remove html tag from your input value and it is very important to remove html tag for security. in your laravel 5.2 application you can implement by using middleware concept in your project. so how to create XSS filter middleware in your laravel application by using following step. First fire following command and create middleware: <strong class="step">Create Middleware</strong> <pre>php artisan make:middleware XSS</pre> Now, you can see new.....

By Hardik Savani | March 4, 2016 | | 8962 Viewer | Category : Laravel
READ MORE

Laravel 5 create Custom Validation Rule example.

Custom Validation Rule is very usefull and interesting concept of laravel 5 because custom validation throught we can re-use validation and use it easily by just name as like laravel core validation(required,same,in etc.). So, In this post i am going to show you how to create custom validation rules in laravel 5.2. you can create very simple way and use too. you can create custom validation rules by few following step and you can see preview of example that give for add custom validation rule. In this example you are creating <strong class="path">is_odd_string</strong> custom validation rule. .....

By Hardik Savani | March 3, 2016 | | 81977 Viewer | Category : Laravel
READ MORE

    How to use elasticsearch from scratch in laravel 5?

    How to use elasticsearch from scratch in laravel 5?

    Open Post

    laravel 5.4 New Feature - Add eloquent whereKey method

    laravel 5.4 New Feature - Add eloquent whereKey method

    Open Post

    How to optimize website speed and performance in Laravel 5.5 ?

    How to optimize website speed and performance in Laravel 5.5 ?

    Open Post

    Laravel 5 create word document file using phpoffice/phpword package

    Laravel 5 create word document file using phpoffice/phpword package

    Open Post

    How to retrieve number of twitter followers count without authentication or api ?

    How to retrieve number of twitter followers count without authentication or api ?

    Open Post

    Bootstrap form validation example with demo using validator.js plugin

    Bootstrap form validation example with demo using validator.js plugin

    Open Post