Skip to content

Commit

Permalink
Add new files, update existing files, and seed
Browse files Browse the repository at this point in the history
data
  • Loading branch information
flemming-pr committed Nov 6, 2023
1 parent 1ff969f commit 46cadba
Show file tree
Hide file tree
Showing 44 changed files with 879 additions and 468 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ RUN apk add --no-cache \
bash \
gnupg \
libzip-dev \
nodejs~=18 \
npm~=9 \
unzip \
zip \
icu-dev \
Expand All @@ -23,6 +21,14 @@ RUN apk add --no-cache \
libjpeg-turbo-dev \
tzdata

# Install Composer manually
COPY --from=composer/composer:latest-bin /composer /usr/bin/composer

# Install Node and NPM manually
COPY --from=node:20-alpine /usr/local/bin /usr/local/bin
COPY --from=node:20-alpine /usr/local/lib/node_modules /usr/local/lib/node_modules


# Install PHP extensions
RUN docker-php-ext-configure gd --enable-gd --with-jpeg
RUN docker-php-ext-install pdo_mysql bcmath intl exif gd
Expand All @@ -31,8 +37,6 @@ COPY docker/php.ini /usr/local/etc/php/php.ini

ENV TZ=Europe/Berlin

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

COPY ./ /var/www/html

RUN composer install --optimize-autoloader --no-interaction --no-dev
Expand Down
1 change: 0 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\Log;

class Kernel extends ConsoleKernel
{
Expand Down
8 changes: 7 additions & 1 deletion app/Filament/Resources/ItemResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

use App\Filament\Resources\ItemResource\Pages;
use App\Models\Item;
use App\Models\StorageLocation;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Forms\Components\CheckboxList;

class ItemResource extends Resource
{
Expand All @@ -36,6 +38,10 @@ public static function form(Form $form): Form
->columns(2)
->gridDirection('row')
->relationship('tags', titleAttribute: 'title'),
Select::make('storage_location_id')
->label('Storage Location')
->options(StorageLocation::all()->pluck('name', 'id'))
->searchable(['name', 'id']),
FileUpload::make('image')
->image()
->maxFiles(1)
Expand Down
75 changes: 75 additions & 0 deletions app/Filament/Resources/StorageLocationResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\StorageLocationResource\Pages;
use App\Models\StorageLocation;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;

class StorageLocationResource extends Resource
{
protected static ?string $model = StorageLocation::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(),
Forms\Components\Textarea::make('description')
->columnSpanFull(),
Forms\Components\Textarea::make('looseInventory')
->columnSpanFull(),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
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('name')
->searchable(),
])
->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\ListStorageLocations::route('/'),
'create' => Pages\CreateStorageLocation::route('/create'),
'edit' => Pages\EditStorageLocation::route('/{record}/edit'),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Filament\Resources\StorageLocationResource\Pages;

use App\Filament\Resources\StorageLocationResource;
use Filament\Resources\Pages\CreateRecord;

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

namespace App\Filament\Resources\StorageLocationResource\Pages;

use App\Filament\Resources\StorageLocationResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditStorageLocation extends EditRecord
{
protected static string $resource = StorageLocationResource::class;

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

namespace App\Filament\Resources\StorageLocationResource\Pages;

use App\Filament\Resources\StorageLocationResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListStorageLocations extends ListRecords
{
protected static string $resource = StorageLocationResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
9 changes: 3 additions & 6 deletions app/Filament/Resources/TagResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
namespace App\Filament\Resources;

use App\Filament\Resources\TagResource\Pages;
use App\Filament\Resources\TagResource\RelationManagers;
use App\Models\Tag;
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 TagResource extends Resource
{
Expand Down Expand Up @@ -58,20 +55,20 @@ public static function table(Table $table): Table
Tables\Actions\CreateAction::make(),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListTags::route('/'),
'create' => Pages\CreateTag::route('/create'),
'edit' => Pages\EditTag::route('/{record}/edit'),
];
}
}
}
1 change: 0 additions & 1 deletion app/Filament/Resources/TagResource/Pages/CreateTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Filament\Resources\TagResource\Pages;

use App\Filament\Resources\TagResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateTag extends CreateRecord
Expand Down
30 changes: 30 additions & 0 deletions app/Http/Controllers/StorageLocationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers;

use App\Models\StorageLocation;
use Illuminate\View\View;

class StorageLocationController extends Controller
{
public function index(): View
{
return view('templates.storageLocation.index',
['storageLocations' => StorageLocation::all()]
);
}

public function show(StorageLocation $storageLocation): View
{
return view('templates.storageLocation.show',
['storageLocation' => $storageLocation]
);
}

public function print(StorageLocation $storageLocation): View
{
return view('templates.storageLocation.print',
['storageLocation' => $storageLocation]
);
}
}
2 changes: 0 additions & 2 deletions app/Http/Controllers/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TagController extends Controller
{
//
Expand Down
15 changes: 12 additions & 3 deletions app/Models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

namespace App\Models;

use App\Traits\AutoLoginLinkTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Item extends Model
{
use AutoLoginLinkTrait;
use HasFactory;

protected $fillable = [
Expand All @@ -19,6 +22,7 @@ class Item extends Model
'included',
'manual_link',
'require_training',
'storage_location_id',
];

protected $casts = [
Expand All @@ -30,13 +34,18 @@ public function transactions(): HasMany
return $this->hasMany(Transaction::class);
}

public function storageLocation(): BelongsTo
{
return $this->belongsTo(StorageLocation::class);
}

public function tags(): BelongsToMany
{
return $this->belongsToMany(Tag::class, 'item_tag', 'item_id', 'tag_id');
}

public function getAutoLoginLink(): string
protected function getRouteName(): string
{
return str_replace('://', '://'.config('app.autoLoginCredentials').'@', route('item.show', $this->id));
return 'item.show';
}
}
30 changes: 30 additions & 0 deletions app/Models/StorageLocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Models;

use App\Traits\AutoLoginLinkTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class StorageLocation extends Model
{
use AutoLoginLinkTrait;
use HasFactory;

protected $fillable = [
'name',
'description',
'looseInventory',
];

public function items(): HasMany
{
return $this->hasMany(Item::class);
}

protected function getRouteName(): string
{
return 'storageLocation.show';
}
}
15 changes: 15 additions & 0 deletions app/Traits/AutoLoginLinkTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace App\Traits;

trait AutoLoginLinkTrait
{
public function getAutoLoginLink(): string
{
return str_replace('://', '://'.config('app.autoLoginCredentials').'@', route($this->getRouteName(), $this->id));
}

abstract protected function getRouteName(): string;
}
Loading

0 comments on commit 46cadba

Please sign in to comment.