Skip to content

Commit

Permalink
changed qty field. fixed livewire safari bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Flatroy committed Jun 21, 2024
1 parent da80a7b commit 22914bb
Show file tree
Hide file tree
Showing 8 changed files with 416 additions and 220 deletions.
4 changes: 1 addition & 3 deletions app/Actions/Jetstream/DeleteUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class DeleteUser implements DeletesUsers
/**
* Create a new action instance.
*/
public function __construct(protected DeletesTeams $deletesTeams)
{
}
public function __construct(protected DeletesTeams $deletesTeams) {}

/**
* Delete the given user.
Expand Down
89 changes: 48 additions & 41 deletions app/Filament/Resources/ItemResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Filament\Tables\Actions\RestoreBulkAction;
use Filament\Tables\Columns\CheckboxColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\TextInputColumn;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -83,8 +84,9 @@ public static function form(Form $form): Form
->required(),

Textarea::make('description')
->label('Item description')->columnSpanFull()->rows(5
)->autosize(),
->label('Item description')
->columnSpanFull()
->rows(5)->autosize(),

// todo: add tags https://filamentphp.com/plugins/filament-spatie-tags

Expand All @@ -95,10 +97,13 @@ public static function form(Form $form): Form

TextInput::make('import_ref'),

TextInput::make('notes'),
Textarea::make('notes')->columnSpanFull()->rows(3)->autosize(),

TextInput::make('quantity')
\LaraZeus\Quantity\Components\Quantity::make('quantity')
// ->heading('Quantity')
->default(1)
->stacked()
->label('Quantity')
->required()
->integer(),

Expand Down Expand Up @@ -175,62 +180,64 @@ public static function table(Table $table): Table
{
return $table
->columns([
// TextColumn::make('ulid'),
TextColumn::make('ulid')->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('name')
->searchable()
->sortable(),

// TextColumn::make('description')->searchable(),
TextColumn::make('description')->searchable()->toggleable(isToggledHiddenByDefault: true),

// TextColumn::make('import_ref')->searchable(),
TextColumn::make('import_ref')->searchable()->toggleable(isToggledHiddenByDefault: true),

// TextColumn::make('notes')->searchable(),
TextColumn::make('notes')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('quantity')->searchable(),
TextInputColumn::make('quantity')->searchable()->rules(['integer'])->toggleable()->extraAttributes(['class' => 'w-32'])->type('number')->alignCenter(),

CheckboxColumn::make('insured'),
CheckboxColumn::make('insured')->toggleable(),

CheckboxColumn::make('archived'),
CheckboxColumn::make('archived')->toggleable(),

TextColumn::make('asset_id')
->label('Asset ID')
->searchable()
->copyable()
->copyMessage('Asset ID copied')
->copyMessageDuration(1500),
//
// TextColumn::make('serial_number')->searchable(),
//
// TextColumn::make('model_number')->searchable(),
//
// TextColumn::make('manufacturer')->searchable(),
//
// TextColumn::make('lifetime_warranty'),
//
// TextColumn::make('warranty_expires')
// ->date(),
//
// TextColumn::make('warranty_details'),
//
// TextColumn::make('purchase_time')
// ->date(),
//
// TextColumn::make('purchase_from')->searchable(),
//
// TextColumn::make('purchase_price')->searchable(),
//
// TextColumn::make('sold_time')
// ->date(),
//
// TextColumn::make('sold_to')->searchable(),
//
// TextColumn::make('sold_price')->searchable(),
->copyMessageDuration(1500)
->toggleable(),
//
// TextColumn::make('sold_notes')->searchable(),
TextColumn::make('serial_number')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('model_number')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('manufacturer')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('lifetime_warranty')->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('warranty_expires')
->date()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('warranty_details')->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('purchase_time')
->date()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('purchase_from')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('purchase_price')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('sold_time')
->date()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('sold_to')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('sold_price')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('sold_notes')->searchable()->toggleable(isToggledHiddenByDefault: true),

TextColumn::make('location.name')
->searchable()
->sortable(),
->sortable()->toggleable(),
])
->filters([
TrashedFilter::make(),
Expand Down
21 changes: 10 additions & 11 deletions app/Filament/Widgets/RecentlyAdded.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Filament\Resources\ItemResource;
use App\Models\Item;
use Filament\Tables;
use Filament\Tables\Columns\TextInputColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;

Expand All @@ -22,17 +23,15 @@ public function table(Table $table): Table
->defaultSort('created_at', 'desc')
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()->sortable(),
Tables\Columns\TextColumn::make('quantity')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('location.name')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('purchase_price')
->searchable()
->sortable(),
Tables\Columns\CheckboxColumn::make('insured'),
->searchable()->sortable()->toggleable(),

TextInputColumn::make('quantity')->searchable()->rules(['integer'])->toggleable()->extraAttributes(['class' => 'w-32'])->type('number')->alignCenter(),

Tables\Columns\TextColumn::make('location.name')->searchable()->sortable()->toggleable(),

Tables\Columns\TextColumn::make('purchase_price')->searchable()->sortable()->toggleable(),

Tables\Columns\CheckboxColumn::make('insured')->toggleable(),
])
->actions([
Tables\Actions\Action::make('open')
Expand Down
63 changes: 62 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

namespace App\Providers;

use App\Models\User;
use Filament\Support\Assets\Js;
use Filament\Support\Facades\FilamentAsset;
use Illuminate\Database\Connection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -19,6 +28,58 @@ public function register(): void
*/
public function boot(): void
{
//
// needed to solve issue https://github.com/livewire/livewire/discussions/5923 - in future should be fixed by Livewire
FilamentAsset::register([
Js::make('custom-script', __DIR__.'/../../resources/js/custom.filament.js'),
]);

// As these are concerned with application correctness,
// leave them enabled all the time.
Model::preventAccessingMissingAttributes(! $this->app->isProduction());
Model::preventSilentlyDiscardingAttributes(! $this->app->isProduction());

Model::preventLazyLoading(! $this->app->isProduction());

Model::shouldBeStrict(! $this->app->isProduction());

Gate::define('viewPulse', function (User $user) {
return true; // $user->hasRole('super-admin') || app()->isLocal();
});

if ($this->app->isProduction()) {
Model::handleLazyLoadingViolationUsing(function (
$model,
$relation
) {
$class = get_class($model);

info(
"Attempted to lazy load [{$relation}] on model [{$class}]."
);
});
}
/*if ($this->app->isProduction()) {
$this->app['request']->server->set('HTTPS', true);
\URL::forceScheme('https');
}*/

if ($this->app->isLocal() && ! $this->app->runningInConsole()) {
DB::listen(function (QueryExecuted $event) {
if ($event->time > 250) {
throw new QueryException(
'db',
$event->sql,
$event->bindings,
new \Exception('Individual database query exceeded '.$event->time.'ms.')
);
}
});

DB::whenQueryingForLongerThan(2000, function (Connection $connection) {
\Log::warning("Database queries exceeded 2 seconds on {$connection->getName()}");
});

}

}
}
28 changes: 24 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
{
"name": "laravel/laravel",
"name": "flatroy/stupid-inventory-laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"description": "Simple stupid inventory and organization system built for the Home User.",
"keywords": [
"laravel",
"inventory",
"inventory-management",
"filament",
"livewire",
"jetstream-laravel"
],
"license": "MIT",
"homepage": "https://github.com/Flatroy/stupid-inventory-laravel",
"support": {
"issues": "https://github.com/Flatroy/stupid-inventory-laravel/issues",
"source": "https://github.com/Flatroy/stupid-inventory-laravel"
},
"authors": [
{
"name": "George Daneke",
"email": "[email protected]",
"role": "Owner"
}
],
"require": {
"php": "^8.2",
"filament/filament": "^3.2",
"lara-zeus/quantity": "^1.0",
"laravel/framework": "^11.9",
"laravel/jetstream": "^5.1",
"laravel/octane": "^2.4",
Expand Down Expand Up @@ -55,7 +75,7 @@
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"pint": "./vendor/bin/pint --dirty"
"pint": "./vendor/bin/pint"
},
"extra": {
"laravel": {
Expand Down
Loading

0 comments on commit 22914bb

Please sign in to comment.