Post model with title and body in laravel 8
Created at 06-Sep-2021 ,
By samar
Post model with title and body in laravel 8
In this tutorial, we will try to find the solution to "Post model with title and body in laravel 8" through programming.
Here we provide post model with protected $table attribute and protected $fillable attribute with title and body field in laravel-
Post model with title and body
--PATH app\Models\Post.php<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Post extends Model { use HasFactory; protected $table = "posts"; protected $fillable = [ 'title', 'body' ]; }
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
- Retain selected value of select box in Laravel
- Display success message in laravel
- How to create belongstomany relation using custom name on custom pivot table
- Laravel 5.4 save data to database
- How to display user profile after login in laravel
- Retrieve count of nested relationship data in Laravel
- How to create pivot table in laravel using migration
- Laravel save object to database
- Laravel route parameter
- Get products with number of orders in Laravel
- The use statement with non-compound name 'DB' has no effect
- RuntimeException You must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
- How to return error message from controller to view in laravel
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.post_id' in 'where clause
- Laravel delete all rows older than 30 days
- Call to a member function getRelationExistenceQuery() on array in Laravel
- Get id of last inserted record in laravel
- Eager loading dynamically in laravel
- Laravel get count with where condition
- How to check records exist in loaded relationship in Laravel blade view
- The POST method is not supported for this route. Supported methods: PUT.
- How to get all route list
- Php artisan make model, factory, migration and controller in single command
- How to add columns in existing table using migration in laravel
- How to create projects method with belongstomany relationship in user model