Skip to content

Commit

Permalink
feat: sample location resource is now available but not in navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
sriramkanakam87 committed Aug 26, 2024
1 parent af543ec commit 104ad85
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 0 deletions.
108 changes: 108 additions & 0 deletions app/Filament/Dashboard/Resources/SampleLocationResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

namespace App\Filament\Dashboard\Resources;

use App\Filament\Dashboard\Resources\SampleLocationResource\Pages;
use App\Filament\Dashboard\Resources\SampleLocationResource\RelationManagers\MoleculesRelationManager;
use App\Filament\Dashboard\Resources\SampleLocationResource\RelationManagers;
use App\Models\SampleLocation;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Tapp\FilamentAuditing\RelationManagers\AuditsRelationManager;

class SampleLocationResource extends Resource
{
protected static ?string $model = SampleLocation::class;

protected static bool $shouldRegisterNavigation = false;
protected static ?string $navigationGroup = 'Data';
protected static ?int $navigationSort = 6;

protected static ?string $navigationIcon = 'heroicon-s-viewfinder-circle';

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('iri')
->maxLength(255),
Forms\Components\Select::make('organism_id')
->relationship('organisms', 'name')
->searchable()
->required(),
Forms\Components\TextInput::make('collection_ids')
->maxLength(255),
Forms\Components\TextInput::make('molecule_count')
->numeric(),
// Forms\Components\TextInput::make('slug')
// ->maxLength(255),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable(),
Tables\Columns\TextColumn::make('iri')
->searchable(),
Tables\Columns\TextColumn::make('organism_id')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('collection_ids')
->searchable(),
Tables\Columns\TextColumn::make('molecule_count')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('slug')
->searchable(),
])
->filters([
//
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
MoleculesRelationManager::class,
AuditsRelationManager::class,
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListSampleLocations::route('/'),
'create' => Pages\CreateSampleLocation::route('/create'),
'view' => Pages\ViewSampleLocation::route('/{record}'),
'edit' => Pages\EditSampleLocation::route('/{record}/edit'),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Filament\Dashboard\Resources\SampleLocationResource\Pages;

use App\Filament\Dashboard\Resources\SampleLocationResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateSampleLocation extends CreateRecord
{
protected static string $resource = SampleLocationResource::class;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Filament\Dashboard\Resources\SampleLocationResource\Pages;

use App\Filament\Dashboard\Resources\SampleLocationResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditSampleLocation extends EditRecord
{
protected static string $resource = SampleLocationResource::class;

protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Dashboard\Resources\SampleLocationResource\Pages;

use App\Filament\Dashboard\Resources\SampleLocationResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListSampleLocations extends ListRecords
{
protected static string $resource = SampleLocationResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Dashboard\Resources\SampleLocationResource\Pages;

use App\Filament\Dashboard\Resources\SampleLocationResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;

class ViewSampleLocation extends ViewRecord
{
protected static string $resource = SampleLocationResource::class;

protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

0 comments on commit 104ad85

Please sign in to comment.