Open yheihei opened 4 years ago
vagrant@tasaka:~$ sudo vim /etc/php/7.0/cli/php.ini
extension=php_pdo.dll
extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
vagrant@tasaka:/var/www/html/laravel_lessons/myblog$ sudo apt-get update
vagrant@tasaka:/var/www/html/laravel_lessons/myblog$ sudo apt-get install php7.0-sqlite3
vagrant@tasaka:/var/www/html/laravel_lessons/myblog$ sudo service apache2 restart
vagrant@tasaka:/var/www/html/laravel_lessons/myblog$ php artisan migrate
Migration table created successfully.
Migrating: 2020_04_12_055124_create_posts_table
Migrated: 2020_04_12_055124_create_posts_table
vagrant@tasaka:/var/www/html/laravel_lessons/myblog$ sqlite3 database/database.sqlite
SQLite version 3.11.0 2016-02-15 17:29:24
Enter ".help" for usage hints.
sqlite> .schema posts
CREATE TABLE "posts" ("id" integer not null primary key autoincrement, "title" varchar not null, "body" text not null, "created_at" datetime null, "updated_at" datetime null);
vagrant@tasaka:/var/www/html/laravel_lessons/myblog$ php artisan tinker
Psy Shell v0.9.12 (PHP 7.0.33-26+ubuntu16.04.1+deb.sury.org+1 — cli) by Justin Hileman
>>> $post = new App\Post();
=> App\Post {#2893}
>>> $post->title = 'title 1';
=> "title 1"
>>> $post->body = 'body 1';
=> "body 1"
>>> $post->save();
=> true
>>> App\Post::all();
=> Illuminate\Database\Eloquent\Collection {#2901
all: [
App\Post {#2902
id: "1",
title: "title 1",
body: "body 1",
created_at: "2020-04-12 07:51:47",
updated_at: "2020-04-12 07:51:47",
},
],
}
>>> App\Post::all()->toArray();
=> [
[
"id" => 1,
"title" => "title 1",
"body" => "body 1",
"created_at" => "2020-04-12 07:51:47",
"updated_at" => "2020-04-12 07:51:47",
],
]
>>> exit
Exit: Goodbye
モデル作成コマンド