-
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.
Enable groups to have their own page
- Loading branch information
Showing
22 changed files
with
312 additions
and
106 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
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,30 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class GroupEventsItem extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = ['group_id', 'sort', 'page_id']; | ||
|
||
protected $appends = ['type']; | ||
|
||
public function getTypeAttribute() | ||
{ | ||
return "groupEventsItem"; | ||
} | ||
|
||
public function page() | ||
{ | ||
return $this->belongsTo(Page::class); | ||
} | ||
|
||
public function group() | ||
{ | ||
return $this->belongsTo(Group::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
64 changes: 64 additions & 0 deletions
64
api/database/migrations/2024_02_28_195517_add_group_id_to_pages_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,64 @@ | ||
<?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::table('pages', function (Blueprint $table) { | ||
$table->unsignedBigInteger('group_id')->nullable()->after('id'); | ||
$table->foreign('group_id')->references('id')->on('groups')->onDelete('set null'); | ||
}); | ||
Schema::table('groups', function (Blueprint $table) { | ||
$table->dropColumn('description'); | ||
$table->dropColumn('enable_group_page'); | ||
}); | ||
|
||
Schema::dropIfExists('group_headers'); | ||
|
||
Schema::dropIfExists('group_files'); | ||
|
||
Schema::create('group_events_items', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('group_id')->nullable()->constrained()->onDelete('cascade'); | ||
$table->integer('sort')->nullable(); | ||
$table->unsignedBigInteger('page_id'); | ||
$table->foreign('page_id')->references('id')->on('pages')->onDelete('cascade'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('group_events_items'); | ||
Schema::create('group_headers', function (Blueprint $table) { | ||
$table->foreignId('group_id')->constrained()->onDelete('cascade'); | ||
$table->foreignId('file_id')->constrained()->onDelete('cascade'); | ||
$table->timestamps(); | ||
}); | ||
|
||
Schema::create('group_files', function (Blueprint $table) { | ||
$table->foreignId('group_id')->constrained()->onDelete('cascade'); | ||
$table->foreignId('file_id')->constrained()->onDelete('cascade'); | ||
$table->timestamps(); | ||
}); | ||
|
||
Schema::table('groups', function (Blueprint $table) { | ||
$table->text('description')->nullable(); | ||
$table->boolean('enable_group_page')->default(0); | ||
}); | ||
Schema::table('pages', function (Blueprint $table) { | ||
$table->dropForeign(['group_id']); | ||
$table->dropColumn('group_id'); | ||
}); | ||
} | ||
}; |
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
Oops, something went wrong.