<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class Item extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::create('Item', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->string('body');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::dropIfExists('Item');
}
}
php artisan make:model Item
C:\xampp\htdocs\api\app\Models\Item.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Item extends Model {
use HasFactory;
public $timestamps = false;
protected $table = 'item';
protected $primaryKey = 'id';
protected $fillable = ['title', 'body'];
}
<?php
namespace Database\Seeders;
use App\Models\Item;
use Illuminate\Database\Seeder;
class ItemSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run() {
Item::factory()->count(5)->create();
}
}