Send post data from controller to view
Created at 06-Sep-2021 ,
By samar
Send post data from controller to view
In this article, we will see how to solve "Send post data from controller to view".
You can send post data from controller to view using return view() method. Before sending data to view you have to get the data from the post model using Post::all() method.-
Get all post from table using controller and return to view in laravel 8
--PATH app\Http\Controllers\<YourController>.php//Import post model after the namespace in laravel controller use App\Models\Post; //Method inside controller’s class to get all post public function index(){ $posts = Post::all(); return view('home', compact('posts')); }
Related Queries
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to get records in random order in laravel
- How to use or operator in laravel
- Touch parent updated_at in Laravel
- Class 'App\Http\Controllers\User' not found
- How to check if user has created any post or not in laravel
- Pagination in laravel
- How to upload local Laravel project to server ?
- How to return a column with different name in Laravel
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- How to insert dynamic values to additional column with pivot column in pivot table on multiple records
- Update record after find method in lavavel
- How to get last year records count with month wise in Laravel
- Laravel onclick function not working
- The openssl extension is required for SSL/TLS protection but is not available
- Class App\Http\Controllers\Admin\UserController Does Not Exist
- Split an Eloquent Collection by half in Laravel
- Php artisan make model, factory, migration and controller in single command
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- How to include header file in laravel
- Get comma separated email from input array
- How to create projects method with belongstomany relationship in user model
- Define variable and use in Laravel controller method
- How to delete record in Laravel with ajax
- How to get the id of last record from collection object in laravel view
- Laravel change date format