Shows how to create a simple stock management application with item export/import and transaction logging for stock changes.
We have a simple resource to manage categories where the create and edit form opens in a modal. For category, we only have one field, name
. Here is the code for CategoryResource
:
class CategoryResource extends Resource{ protected static ?string $model = Category::class; protected static string | \BackedEnum | null $navigationIcon = Heroicon::OutlinedRectangleStack; public static function form(Schema $schema): Schema { return CategoryForm::configure($schema); } public static function table(Table $table): Table { return CategoriesTable::configure($table); } public static function getPages(): array { return [ 'index' => ManageCategories::route('/'), ]; }}
Transactions resource manages transactions for an item. We can only create a new transaction.
The form of transaction is reused in the relation manager for ItemResource
. We don't need a select input in the relation manager, so the hiddenOn()
method is used where the Relation Manager class is passed as a parameter.
The amount
text input has a column span of full only in the Relation Manager. Here is the code for the form in the TransactionResource
: