-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Item extends Model | ||
{ | ||
use HasFactory; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
database/migrations/2021_09_18_031913_create_items_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateItemsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('items', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('name'); | ||
$table->text('description'); | ||
$table->integer('price'); | ||
$table->string('seller'); | ||
$table->string('email'); | ||
$table->text('image_url'); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('items'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class ItemSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
DB::table('items')->insert([ | ||
'name' => 'エアマックス 95', | ||
'description' => '1995年のランニングマックスモデルの最新版。〜', | ||
'price' => 25000, | ||
'seller' => 'Taro', | ||
'email' => '[email protected]', | ||
'image_url' => 'https://〜', | ||
'created_at' => date('Y-m-d H:i:s'), | ||
'updated_at' => date('Y-m-d H:i:s'), | ||
]); | ||
|
||
$param = [ | ||
[ | ||
'name' => 'フットスケープ', | ||
'description' => '横にシューレースがある斬新な〜。', | ||
'price' => 18000, | ||
'seller' => 'Jin', | ||
'email' => '[email protected]', | ||
'image_url' => 'https://〜', | ||
'created_at' => date('Y-m-d H:i:s'), | ||
'updated_at' => date('Y-m-d H:i:s'), | ||
], | ||
[ | ||
'name' => 'ポンプヒューリー', | ||
'description' => 'ポンプを押すと、空気によって〜。', | ||
'price' => 18000, | ||
'seller' => 'Dan', | ||
'email' => '[email protected]', | ||
'image_url' => 'https://〜', | ||
'created_at' => date('Y-m-d H:i:s'), | ||
'updated_at' => date('Y-m-d H:i:s'), | ||
] | ||
]; | ||
|
||
DB::table('items')->insert($param); | ||
} | ||
} |