-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
33722ae
commit c7ef23a
Showing
7 changed files
with
166 additions
and
0 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,23 @@ | ||
<?php | ||
|
||
namespace App\Models\Donor; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Donor extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $table = 'donors'; | ||
|
||
protected $fillable = [ | ||
'status_id', | ||
'name', | ||
'email', | ||
'full_address', | ||
'job_title', | ||
'social_type', | ||
'social_url' | ||
]; | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Models\Donor; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Status extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $table = 'donation_statuses'; | ||
|
||
protected $fillable = [ | ||
'name' | ||
]; | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace Database\Factories\Donor; | ||
|
||
use App\Models\Donor\Donor; | ||
use App\Models\Donor\Status; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class DonorFactory extends Factory | ||
{ | ||
protected $model = Donor::class; | ||
|
||
public function definition(): array | ||
{ | ||
return [ | ||
'status_id' => Status::factory(), | ||
'name' => $this->faker->name(), | ||
'email' => $this->faker->unique()->email(), | ||
'full_address' => $this->faker->address(), | ||
'job_title' => 'Developer', | ||
'social_type' => $this->faker->randomElement(['twitter', 'github', 'instagram']), | ||
'social_url' => $this->faker->url() | ||
]; | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace Database\Factories\Donor; | ||
|
||
use App\Models\Donor\Status; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class StatusFactory extends Factory | ||
{ | ||
protected $model = Status::class; | ||
public function definition(): array | ||
{ | ||
return [ | ||
'name' => $this->faker->name() | ||
]; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
database/migrations/2023_05_31_180336_create_donation_statuses_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,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('donation_statuses', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('donation_statuses'); | ||
} | ||
}; |
34 changes: 34 additions & 0 deletions
34
database/migrations/2023_05_31_190034_create_donors_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,34 @@ | ||
<?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('donors', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('status_id')->constrained('donation_statuses'); | ||
$table->string('name'); | ||
$table->string('email'); | ||
$table->string('full_address')->comment('City, State / Country'); | ||
$table->string('job_title'); | ||
$table->string('social_type')->nullable(); | ||
$table->string('social_url')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('donors'); | ||
} | ||
}; |
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,22 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use App\Models\Donor\Status; | ||
use Illuminate\Database\Console\Seeds\WithoutModelEvents; | ||
use Illuminate\Database\Seeder; | ||
|
||
class DonorStatusSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
$donationStatuses = ['Pending', 'Accepted', 'Rejected']; | ||
|
||
foreach($donationStatuses as $donationStatus) { | ||
Status::query()->create(['name' => $donationStatus]); | ||
} | ||
} | ||
} |