-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add course event relation (#720)
* feat: add course event relation * fix: redirect on illegal registration * fix: use 'with' for eloquent parent/childeren models
- Loading branch information
1 parent
2c4d768
commit d4bd213
Showing
12 changed files
with
354 additions
and
18 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
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,37 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\Pivot; | ||
use OwenIt\Auditing\Contracts\Auditable; | ||
|
||
class CourseEvent extends Pivot implements Auditable | ||
{ | ||
use HasFactory; | ||
use \OwenIt\Auditing\Auditable; | ||
|
||
/** | ||
* The attributes that aren't mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $guarded = []; | ||
|
||
/** | ||
* Get course for the course_event. | ||
*/ | ||
public function course(): BelongsTo | ||
{ | ||
return $this->belongsTo(Course::class); | ||
} | ||
|
||
/** | ||
* Get event for the course_event. | ||
*/ | ||
public function event(): BelongsTo | ||
{ | ||
return $this->belongsTo(Event::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
29 changes: 29 additions & 0 deletions
29
database/migrations/2024_09_15_084701_create_course_event_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,29 @@ | ||
<?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('course_event', function (Blueprint $table) { | ||
$table->id(); | ||
$table->timestamps(); | ||
$table->foreignId('course_id')->constrained()->onUpdate('cascade')->onDelete('cascade'); | ||
$table->foreignId('event_id')->constrained()->onUpdate('cascade')->onDelete('cascade'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('course_event'); | ||
} | ||
}; |
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
Oops, something went wrong.