-
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.
feat: created geolocation and organism resources
- Loading branch information
1 parent
94473ab
commit 294a25c
Showing
8 changed files
with
290 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources; | ||
|
||
use App\Filament\Dashboard\Resources\GeoLocationResource\Pages; | ||
use App\Filament\Dashboard\Resources\GeoLocationResource\RelationManagers; | ||
use App\Models\GeoLocation; | ||
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 Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Components\Fieldset; | ||
|
||
class GeoLocationResource extends Resource | ||
{ | ||
protected static ?string $navigationGroup = 'Data'; | ||
|
||
protected static ?int $navigationSort = 5; | ||
|
||
protected static ?string $model = GeoLocation::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
// Fieldset::make('Molecule') | ||
// ->relationship('molecules', 'identifier') | ||
// ->schema([ | ||
// TextInput::make('identifier'), | ||
// TextInput::make('locations'), | ||
// ]) | ||
// TextInput::make('molecule_id') | ||
// ->label('Molecule') | ||
// ->relationship('molecule') | ||
// ->placeholder('Enter the molecule Identifier') | ||
// ->required(), | ||
// TextInput::make('locations') | ||
// ->label('Locations') | ||
// ->relationship('molecule') | ||
// ->placeholder('soil, water, etc.') | ||
// ->helperText('Enter where in this Geo-Location these molecules can be found') | ||
// ->required(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('created_at') | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
Tables\Columns\TextColumn::make('updated_at') | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
]) | ||
->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\ListGeoLocations::route('/'), | ||
'create' => Pages\CreateGeoLocation::route('/create'), | ||
'edit' => Pages\EditGeoLocation::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/Filament/Dashboard/Resources/GeoLocationResource/Pages/CreateGeoLocation.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,21 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\GeoLocationResource\Pages; | ||
|
||
use App\Filament\Dashboard\Resources\GeoLocationResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
use App\Models\Molecule; | ||
|
||
class CreateGeoLocation extends CreateRecord | ||
{ | ||
protected static string $resource = GeoLocationResource::class; | ||
|
||
protected function beforeCreate(): void | ||
{ | ||
// $molecule = Molecule::where('identifier', $this->data['molecule_id'])->get(); | ||
// $this->data['molecule_id'] = $molecule[0]->id; | ||
// dd($this->data); | ||
// $this->data->molecules()->attach($molecule); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Dashboard/Resources/GeoLocationResource/Pages/EditGeoLocation.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\GeoLocationResource\Pages; | ||
|
||
use App\Filament\Dashboard\Resources\GeoLocationResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditGeoLocation extends EditRecord | ||
{ | ||
protected static string $resource = GeoLocationResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Dashboard/Resources/GeoLocationResource/Pages/ListGeoLocations.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\GeoLocationResource\Pages; | ||
|
||
use App\Filament\Dashboard\Resources\GeoLocationResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListGeoLocations extends ListRecords | ||
{ | ||
protected static string $resource = GeoLocationResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::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,83 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources; | ||
|
||
use App\Filament\Dashboard\Resources\OrganismResource\Pages; | ||
use App\Filament\Dashboard\Resources\OrganismResource\RelationManagers; | ||
use App\Models\Organism; | ||
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; | ||
|
||
class OrganismResource extends Resource | ||
{ | ||
protected static ?string $navigationGroup = 'Data'; | ||
|
||
protected static ?int $navigationSort = 4; | ||
|
||
protected static ?string $model = Organism::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('ontology') | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('ontology') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('created_at') | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
Tables\Columns\TextColumn::make('updated_at') | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
]) | ||
->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\ListOrganisms::route('/'), | ||
'create' => Pages\CreateOrganism::route('/create'), | ||
'edit' => Pages\EditOrganism::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/Filament/Dashboard/Resources/OrganismResource/Pages/CreateOrganism.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,12 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\OrganismResource\Pages; | ||
|
||
use App\Filament\Dashboard\Resources\OrganismResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateOrganism extends CreateRecord | ||
{ | ||
protected static string $resource = OrganismResource::class; | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Dashboard/Resources/OrganismResource/Pages/EditOrganism.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\OrganismResource\Pages; | ||
|
||
use App\Filament\Dashboard\Resources\OrganismResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditOrganism extends EditRecord | ||
{ | ||
protected static string $resource = OrganismResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Dashboard/Resources/OrganismResource/Pages/ListOrganisms.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\OrganismResource\Pages; | ||
|
||
use App\Filament\Dashboard\Resources\OrganismResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListOrganisms extends ListRecords | ||
{ | ||
protected static string $resource = OrganismResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |