Skip to content

Commit

Permalink
Subscriber --newsletter model and migration create
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 16, 2024
1 parent f98fe82 commit 3250405
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/Models/Subscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Subscriber extends Model
{
use HasFactory;

protected $fillable = [
'email',
];
}
18 changes: 18 additions & 0 deletions database/factories/SubscriberFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Database\Factories;

use App\Models\Subscriber;
use Illuminate\Database\Eloquent\Factories\Factory;

class SubscriberFactory extends Factory
{
protected $model = Subscriber::class;

public function definition(): array
{
return [
'email' => $this->faker->unique()->safeEmail,
];
}
}
28 changes: 28 additions & 0 deletions database/migrations/2024_06_16_053149_create_subscribers_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('subscribers', function (Blueprint $table) {
$table->id();
$table->string('email')->unique();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('subscribers');
}
};

0 comments on commit 3250405

Please sign in to comment.