-
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.
initialize model and re-migrate databases
- Loading branch information
1 parent
96dc01c
commit 9dc7dfb
Showing
9 changed files
with
208 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
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,65 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Donation extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* fillable | ||
* | ||
* @var array | ||
*/ | ||
|
||
protected $fillable = [ | ||
'invoice', | ||
'campaign_id', | ||
'donatur_id', | ||
'amount', | ||
'pray', | ||
'status', | ||
'snap_token' | ||
]; | ||
|
||
/** | ||
* category relation | ||
* @return void | ||
*/ | ||
|
||
public function category() | ||
{ | ||
return $this->belongsTo(Category::class); | ||
} | ||
|
||
/** | ||
* user relation | ||
* @return void | ||
*/ | ||
|
||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
|
||
/** | ||
* Campaign Relation | ||
* @return void | ||
*/ | ||
public function campaign() | ||
{ | ||
return $this->belongsTo(Campaign::class); | ||
} | ||
|
||
/** | ||
* Donatur Relations | ||
*/ | ||
|
||
public function donatur() | ||
{ | ||
return $this->belongsTo(Donatur::class); | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Donatur extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* fillable | ||
* | ||
* @var array | ||
*/ | ||
|
||
protected $fillable = [ | ||
'name', 'email', 'password', 'avatar' | ||
]; | ||
|
||
/** | ||
* hidden | ||
* @var array | ||
*/ | ||
|
||
protected $hidden = [ | ||
'password', 'remember_token', | ||
]; | ||
|
||
/** | ||
* donations relation | ||
*/ | ||
|
||
public function donations() | ||
{ | ||
return $this->hasMany(Donation::class); | ||
} | ||
} |
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
File renamed without changes.
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
37 changes: 37 additions & 0 deletions
37
database/migrations/2021_02_17_013015_create_donaturs_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,37 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateDonatursTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('donaturs', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('email')->unique(); | ||
$table->timestamp('email_verified_at')->nullable(); | ||
$table->string('password'); | ||
$table->string('avatar')->nullable(); | ||
$table->rememberToken(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('donaturs'); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
database/migrations/2021_02_17_021017_create_donations_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 CreateDonationsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('donations', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('invoice'); | ||
$table->unsignedInteger('campaign_id'); | ||
$table->unsignedInteger('donatur_id'); | ||
$table->bigInteger('amount'); | ||
$table->text('pray')->nullable(); | ||
$table->string('snap_token')->nullable(); | ||
$table->enum('status', array('pending', 'success', 'expired', 'failed')); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('donations'); | ||
} | ||
} |
File renamed without changes.