Migrations with Relationship in Laravel


How to run and roll back migrations and how to create migration for table and add a specific column using the command in laravel 8. let’s see below steps. User this command to create a migration file for the database table php artisan make:migration create_products_table After running the above command, you can see create new … Read more

How to search record in laravel 7

search record

I’m working on the blog project. I needed to create a search record 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 route

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?


WordPress: How to Directly access the 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 { … 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

search comma

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