Skip to content

Commit

Permalink
Merge pull request #256 from Dev-Pulse-Community/teams-implementation
Browse files Browse the repository at this point in the history
Teams integration
  • Loading branch information
curtisdelicata authored Aug 21, 2024
2 parents 4676c72 + 2d8f8c0 commit 508db52
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
74 changes: 74 additions & 0 deletions app/Filament/Admin/Resources/TeamsResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace App\Filament\Admin\Resources;

use App\Filament\Admin\Resources\TeamsResource\Pages;
use App\Filament\Admin\Resources\TeamsResource\RelationManagers;
use App\Models\Team;
use Filament\Forms;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class TeamsResource extends Resource
{
protected static ?string $model = Team::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Administration';
protected static ?string $navigationLabel = 'Teams';

public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')->autocapitalize('words')->required(),
Select::make('user_id')->label('Owner')->options(
\App\Models\User::all()->pluck('name', 'id')
)->required(),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id'),
TextColumn::make('name'),
TextColumn::make('owner.name'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListTeams::route('/'),
'create' => Pages\CreateTeams::route('/create'),
'edit' => Pages\EditTeams::route('/{record}/edit'),
];
}
}
12 changes: 12 additions & 0 deletions app/Filament/Admin/Resources/TeamsResource/Pages/CreateTeams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Filament\Admin\Resources\TeamsResource\Pages;

use App\Filament\Admin\Resources\TeamsResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateTeams extends CreateRecord
{
protected static string $resource = TeamsResource::class;
}
19 changes: 19 additions & 0 deletions app/Filament/Admin/Resources/TeamsResource/Pages/EditTeams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Admin\Resources\TeamsResource\Pages;

use App\Filament\Admin\Resources\TeamsResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditTeams extends EditRecord
{
protected static string $resource = TeamsResource::class;

protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
19 changes: 19 additions & 0 deletions app/Filament/Admin/Resources/TeamsResource/Pages/ListTeams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Admin\Resources\TeamsResource\Pages;

use App\Filament\Admin\Resources\TeamsResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListTeams extends ListRecords
{
protected static string $resource = TeamsResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
5 changes: 5 additions & 0 deletions app/Models/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ protected function casts(): array
'personal_team' => 'boolean',
];
}

public function owner()
{
return $this->belongsTo(User::class, 'user_id');
}
}

0 comments on commit 508db52

Please sign in to comment.