Migrations with Relationship in Laravel

How to run and rollback migrations and how to create migration for table and add specific column using command in laravel 8. let’s see bellow steps. User this command for create migration file for database table php artisan make:migration create_products_table After run above command, you can see created new file in database/migrations/2020_11_05_075124_create_products_table.php <?php use Illuminate\Database\Migrations\Migration; … Read more

How to search record in laravel 7

I’m working on the blog project. I needed to create a search query in Laravel so I give you my solution. Searching in Eloquent model Post::whereStatus(‘Active’) ->where(‘title’, ‘LIKE’ , ‘%’. Request(‘q’) . ‘%’) ->orWhere(’email’, ‘LIKE’, ‘%’. Request(‘q’) .’%’) ->get(); In this case all active and search Term record return. and you use another query like … Read more

How to change resource route name in laravel

Resource controller is amazing for CRUD operation in laravel. But sometimes need to overwrite the default functionality let’s see How to overriding resource route names Default resource route is Route::resource(‘vendor’, ‘VendorController’); in case of the route, names are POST         | vendor                 | vendor.store GET|HEAD    … Read more

How to show WordPress post in laravel?

How to Directly access WordPress database in Laravel Modal? or How to create two database connections in Laravel? We need to create Modals BlogPostmeta and BlogPosts these modals access data from wp_posts and wp_postmeta table.  1) BlogPost modal Copy and paste this code <?php namespace App; use Illuminate\Database\Eloquent\Model; class BlogPost extends Model { protected $connection … Read more

How to create custom pagination view in laravel

In this article, I will create a custom pagination view in laravel. First of all, open the command prompt in the main root of the project and execute this command php artisan vendor:publish –tag=laravel-pagination When this command run in command prompt then laravel generate some folders or files “resources/views/vendor/pagination:” bootstrap-4.blade.php default.blade.php semantic-ui.blade.php simple-bootstrap-4.blade.php simple-default.blade.php laravel … Read more

How to create custom helper file in laravel

Laravel provides many excellent helper functions, for example, arrays, file paths, strings, and routes, among other more things. Today I will create own helper file you need to create a file “app/Helper/Helper.php” in your laravel project ; <?php function imageCheck(){ //write something hear } ?> Add File Path In composer.json file If you create a new … Read more

Search Comma Separated value using FIND_IN_SET() in Laravel 4,5,6

Here is a crazy example today, I will tell you how to search comma-separated value ( laravel,php,html,css ) in Laravel Query Builder using MySQL find_in_set() method. we can use MySQL find_in_set() and use whereRaw() function in laravel query builder. $key = “laravel”; $posts = Post::whereRaw(“find_in_set(” . $key . “,tags)”)             … Read more