Skip to content

Commit

Permalink
設定完了
Browse files Browse the repository at this point in the history
  • Loading branch information
ryotamedx committed Sep 18, 2021
1 parent 68e1150 commit 8321c90
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/Models/Item.php
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;
}
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
|
*/

'timezone' => 'UTC',
'timezone' => 'Asia/Tokyo',

/*
|--------------------------------------------------------------------------
Expand Down
38 changes: 38 additions & 0 deletions database/migrations/2021_09_18_031913_create_items_table.php
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');
}
}
2 changes: 1 addition & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
// \App\Models\User::factory(10)->create();
$this->call(ItemSeeder::class);
}
}
53 changes: 53 additions & 0 deletions database/seeders/ItemSeeder.php
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);
}
}

0 comments on commit 8321c90

Please sign in to comment.