create methodで書くと、MassAssignmentExceptionとなる
Route::get('/create', function(){ Post::create(['title'=>'php create method', 'content'=>'Wow I\'m learning a lot']); });
その場合は、modelでfillableに配列としてカラム名を記入する
class Post extends Model { // // protected $table = 'posts'; protected $fillable = [ 'title', 'content' ] }
mysql> select * from posts;
+—-+——————-+——————————————————+———————+———————+———-+
| id | title | content | created_at | updated_at | is_admin |
+—-+——————-+——————————————————+———————+———————+———-+
| 1 | Update tile | Laravel is the best thing that happen to PHP | NULL | NULL | 0 |
| 3 | laravel awesome | Laravel is the best thing that happen to PHP, period | NULL | NULL | 0 |
| 4 | new ORM title 2 | wow eloquent is really cool, look at this content | 2019-12-05 18:23:33 | 2019-12-05 18:33:31 | 0 |
| 5 | php create method | Wow I’m learning a lot | 2019-12-05 18:47:53 | 2019-12-05 18:47:53 | 0 |
+—-+——————-+——————————————————+———————+———————+———-+
curious