Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel post request search query

public function search(Request $request){
    // Get the search value from the request
    $search = $request['search'];

    // Search in the title and body columns from the posts table
    $posts = Post::query()
        ->where('title', 'LIKE', "%{$search}%")
        ->orWhere('body', 'LIKE', "%{$search}%")
        ->get();

    // Return the search view with the resluts compacted
    return view('search', compact('posts'));
}
Comment

PREVIOUS NEXT
Code Example
Php :: php round up 
Php :: codeigniter 4 redirect with data 
Php :: Class "AppHttpControllersAdminController" not found in laravel 8 
Php :: laravel tree 
Php :: php curl request 
Php :: wordpress php cpt get all taxonomy 
Php :: run xampp application on windows startup 
Php :: php array_map() 
Php :: filename php 
Php :: laravel default string length migration 
Php :: sort json in php 
Php :: php do not refresh page after submit post 
Php :: update php version in laravel 
Php :: join table laravel count 
Php :: print asociative array php 
Php :: php time to date 
Php :: how can we check in the table in comma separated values in laravel 
Php :: apiresource laravel 
Php :: php number format comma and decimal 
Php :: laravel web php request to redirect to another page 
Php :: write test case in react native 
Php :: laravel cache remember 
Php :: wordpress post type template 
Php :: php print array nice format 
Php :: phpmyadmin username password check 
Php :: simplexml_load_string alternative php 
Php :: can we create linked list in php 
Php :: use font awesome in laravel 8 
Php :: php variable in echo 
Php :: laravel migration delete column 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =