-
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.
Merge pull request #12 from Steinbeck-Lab/geo-organism-resources
Geo organism resources
- Loading branch information
Showing
18 changed files
with
630 additions
and
6 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,81 @@ | ||
<?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), | ||
]); | ||
} | ||
|
||
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
62 changes: 62 additions & 0 deletions
62
...ment/Dashboard/Resources/MoleculeResource/RelationManagers/GeoLocationRelationManager.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,62 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\MoleculeResource\RelationManagers; | ||
|
||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\SoftDeletingScope; | ||
use Filament\Tables\Actions\AttachAction; | ||
|
||
class GeoLocationRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'geoLocations'; | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->recordTitleAttribute('name') | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name'), | ||
Tables\Columns\TextColumn::make('locations'), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\AttachAction::make() | ||
->preloadRecordSelect() | ||
->form(fn (AttachAction $action): array => [ | ||
$action->getRecordSelect(), | ||
Forms\Components\TextInput::make('locations') | ||
]), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make() | ||
->form(function ($action) { | ||
return [ | ||
Forms\Components\TextInput::make('locations'), | ||
]; | ||
}), | ||
Tables\Actions\DetachAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DetachBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...lament/Dashboard/Resources/MoleculeResource/RelationManagers/OrganismsRelationManager.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,65 @@ | ||
<?php | ||
|
||
namespace App\Filament\Dashboard\Resources\MoleculeResource\RelationManagers; | ||
|
||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Database\Eloquent\SoftDeletingScope; | ||
use Filament\Tables\Actions\AttachAction; | ||
use Filament\Tables\Actions\EditAction; | ||
use App\Models\Organism; | ||
|
||
class OrganismsRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'organisms'; | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->recordTitleAttribute('name') | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name'), | ||
Tables\Columns\TextColumn::make('organism_parts'), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\AttachAction::make() | ||
->preloadRecordSelect() | ||
->form(fn (AttachAction $action): array => [ | ||
$action->getRecordSelect(), | ||
Forms\Components\TextInput::make('organism_parts') | ||
]), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make() | ||
->form(function ($action) { | ||
return [ | ||
Forms\Components\TextInput::make('organism_parts'), | ||
]; | ||
}), | ||
Tables\Actions\DetachAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
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,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; | ||
} |
Oops, something went wrong.