Skip to content

Commit

Permalink
updated seeder files, added custom fields to items, added storage dri…
Browse files Browse the repository at this point in the history
…vers
  • Loading branch information
Flatroy committed Jun 21, 2024
1 parent 22914bb commit 39dbf6d
Show file tree
Hide file tree
Showing 12 changed files with 585 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,18 @@ VITE_APP_NAME="${APP_NAME}"

# enable on Cloudflare if needed
LARAVEL_CLOUDFLARE_ENABLED=false

# we will use for backups in future
FTP_HOST=
FTP_USERNAME=
FTP_PASSWORD=

# we need it for storage
CLOUDFLARE_R2_ACCESS_KEY_ID=
CLOUDFLARE_R2_SECRET_ACCESS_KEY=
CLOUDFLARE_R2_BUCKET=
CLOUDFLARE_R2_ENDPOINT=
CLOUDFLARE_R2_URL=

# could be r2, s3 etc
FILAMENT_FILESYSTEM_DISK=public
62 changes: 58 additions & 4 deletions app/Filament/Resources/ItemResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use App\Filament\Imports\ItemImporter;
use App\Filament\Resources\ItemResource\Pages;
use App\Models\Item;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
Expand All @@ -30,7 +32,7 @@
use Filament\Tables\Columns\TextInputColumn;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingScope;

Expand Down Expand Up @@ -100,7 +102,6 @@ public static function form(Form $form): Form
Textarea::make('notes')->columnSpanFull()->rows(3)->autosize(),

\LaraZeus\Quantity\Components\Quantity::make('quantity')
// ->heading('Quantity')
->default(1)
->stacked()
->label('Quantity')
Expand All @@ -124,6 +125,59 @@ public static function form(Form $form): Form
->collapsible()->collapsed()->persistCollapsed()
->hiddenOn(['create']),

Section::make('Custom Fields')
->schema([
Builder::make('fields')
->blocks([
Builder\Block::make('text_field')
->schema([
TextInput::make('name'),
TextInput::make('value'),

])
->columns(2),
Builder\Block::make('paragraph_field')
->schema([
TextInput::make('name'),

Textarea::make('value')
->label('Value'),
]),
Builder\Block::make('image_field')
->schema([
FileUpload::make('value')
->label('Image')
->openable()
->previewable()
->reorderable()
->appendFiles()
->imageEditor()
->directory('image-attachments')
->visibility('private')
->image(),
TextInput::make('name')
->label('Note'),
]),
Builder\Block::make('file_field')
->schema([
FileUpload::make('value')
->label('File(s)')
->reorderable()
->directory('file_attachments')
->visibility('private')
->downloadable()
->appendFiles(),
TextInput::make('name')
->label('Note'),
]),
]),

])
->collapsible()
->collapsed()
->persistCollapsed()
->hiddenOn(['create']),

Section::make('Purchase Details')
->schema([

Expand Down Expand Up @@ -271,15 +325,15 @@ public static function getPages(): array
];
}

public static function getEloquentQuery(): Builder
public static function getEloquentQuery(): EloquentBuilder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}

public static function getGlobalSearchEloquentQuery(): Builder
public static function getGlobalSearchEloquentQuery(): EloquentBuilder
{
return parent::getGlobalSearchEloquentQuery()->with(['location']);
}
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Item extends Model
'sold_notes',
'location_id',
'team_id',
'fields',
];

protected static function boot()
Expand Down Expand Up @@ -72,6 +73,7 @@ protected function casts(): array
'insured' => 'boolean',
'archived' => 'boolean',
'quantity' => 'integer',
'fields' => 'array',
];
}

Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"laravel/octane": "^2.4",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.9",
"league/flysystem-aws-s3-v3": "^3.0",
"league/flysystem-ftp": "^3.0",
"livewire/livewire": "^3.0",
"monicahq/laravel-cloudflare": "^3.7",
"spatie/laravel-ignition": "^2.8"
Expand Down
Loading

0 comments on commit 39dbf6d

Please sign in to comment.