-
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
Showing
9 changed files
with
242 additions
and
60 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
46 changes: 46 additions & 0 deletions
46
app/Filament/Resources/AppResource/RelationManagers/GroupsRelationManager.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,46 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\AppResource\RelationManagers; | ||
|
||
use Filament\Forms; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
|
||
class GroupsRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'groups'; | ||
|
||
protected static ?string $recordTitleAttribute = 'name'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name'), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\AttachAction::make(), | ||
]) | ||
->actions([ | ||
Tables\Actions\DetachAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\DetachBulkAction::make(), | ||
]); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\App; | ||
use Auth; | ||
use Illuminate\Contracts\Database\Query\Builder; | ||
use Inertia\Inertia; | ||
|
||
class DashboardController extends Controller | ||
{ | ||
public function __invoke() | ||
{ | ||
$apps = App::where(function (Builder $q) { | ||
|
||
$q->where('public', '=', true)->orWhereHas('groups', function (Builder $q) { | ||
$q->whereIn('id', Auth::user()->groups->pluck('id')); | ||
}); | ||
})->where(function (Builder $q) { | ||
$q->where(function (Builder $q) { | ||
$q->whereDate('starts_at', '<=', now())->orWhereNull('starts_at'); | ||
})->where(function (Builder $q) { | ||
$q->whereDate('ends_at', '>=', now())->orWhereNull('ends_at'); | ||
}); | ||
})->get(); | ||
|
||
return Inertia::render('Dashboard', [ | ||
'apps' => $apps, | ||
]); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
database/migrations/2023_02_12_103409_create_app_group_pivot_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,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class CreateAppGroupPivotTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('app_group', function (Blueprint $table) { | ||
$table->unsignedBigInteger('app_id')->index(); | ||
$table->foreign('app_id')->references('id')->on('apps')->onDelete('cascade'); | ||
$table->unsignedBigInteger('group_id')->index(); | ||
$table->foreign('group_id')->references('id')->on('groups')->onDelete('cascade'); | ||
$table->primary(['app_id', 'group_id']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('app_group'); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
database/migrations/2023_02_12_114846_add_fields_to_apps_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,39 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration { | ||
public function up() | ||
{ | ||
Schema::table('apps', function (Blueprint $table) { | ||
$table->timestamp("starts_at")->nullable()->after('client_id'); | ||
$table->timestamp("ends_at")->nullable()->after('starts_at'); | ||
$table->boolean('public')->default(false)->after('ends_at'); | ||
$table->boolean('featured')->default(false)->after('ends_at'); | ||
$table->integer('priority')->unsigned()->default(1000)->after('public'); | ||
$table->string('name')->nullable()->after('client_id'); | ||
$table->string('description')->nullable()->after('name'); | ||
$table->string('icon')->nullable()->after('description'); | ||
$table->string('url')->nullable()->after('icon'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::table('apps', function (Blueprint $table) { | ||
$table->dropColumn([ | ||
"starts_at", | ||
"ends_at", | ||
"public", | ||
"featured", | ||
"priority", | ||
"name", | ||
"description", | ||
"icon", | ||
"url", | ||
]); | ||
}); | ||
} | ||
}; |
Oops, something went wrong.