
Post model with title and body in laravel 8
Here we provide post model with protected $table attribute and protected $fillable attribute with title and body field in laravel
Answers 1
-
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' ]; }
0
Random Code Snippet Queries: Laravel
- Store logged in user details in session and display in view in laravel
- Laravel route parameter
- Pass value from controller to model in laravel
- Session Doesn't Work on Redirect
- Ajax GET request in laravel
- How to access the nth object from Laravel collection object ?
- How to restore multiple records after soft-deletes in Laravel
- How to set column as primary key in Laravel model
- How to return a column with different name in Laravel
- How to display order by null last in laravel
- Delete file from amazon s3 bucket using Laravel
- Laravel csrf token mismatch for ajax POST Request
- Create project table with model and migration
- How to use or operator in laravel
- How to create project_user pivot table in laravel
- Target class [admin] does not exist.
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
- How to create laravel project using composer
- How to Get records between two dates in Laravel
- Send id with route Laravel
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'user_id'
- Call to undefined method App\Models\User::follow()
- How to change default timestamp fields name in Laravel
- Ignore Records where a field has NULL value in Laravel