Skip to content

Commit f603288

Browse files
Merge pull request #28 from khalidmaquilang/dev
v1.0.0
2 parents 3eb5a8e + ae5bdaa commit f603288

File tree

190 files changed

+16919
-1918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+16919
-1918
lines changed

.blueprint

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ created:
1010
- database/factories/SaleFactory.php
1111
- database/factories/SaleItemFactory.php
1212
- database/factories/SettingFactory.php
13-
- database/migrations/2024_06_03_165224_create_customers_table.php
14-
- database/migrations/2024_06_03_165225_create_suppliers_table.php
15-
- database/migrations/2024_06_03_165226_create_categories_table.php
16-
- database/migrations/2024_06_03_165227_create_sub_categories_table.php
17-
- database/migrations/2024_06_03_165228_create_products_table.php
18-
- database/migrations/2024_06_03_165229_create_payment_types_table.php
19-
- database/migrations/2024_06_03_165230_create_purchase_orders_table.php
20-
- database/migrations/2024_06_03_165231_create_purchase_order_items_table.php
21-
- database/migrations/2024_06_03_165232_create_sales_table.php
22-
- database/migrations/2024_06_03_165233_create_sale_items_table.php
23-
- database/migrations/2024_06_03_165234_create_settings_table.php
13+
- database/migrations/2024_06_03_223116_create_customers_table.php
14+
- database/migrations/2024_06_03_223117_create_suppliers_table.php
15+
- database/migrations/2024_06_03_223118_create_categories_table.php
16+
- database/migrations/2024_06_03_223119_create_sub_categories_table.php
17+
- database/migrations/2024_06_03_223120_create_products_table.php
18+
- database/migrations/2024_06_03_223121_create_payment_types_table.php
19+
- database/migrations/2024_06_03_223122_create_purchase_orders_table.php
20+
- database/migrations/2024_06_03_223123_create_purchase_order_items_table.php
21+
- database/migrations/2024_06_03_223124_create_sales_table.php
22+
- database/migrations/2024_06_03_223125_create_sale_items_table.php
23+
- database/migrations/2024_06_03_223126_create_settings_table.php
2424
- app/Models/Customer.php
2525
- app/Models/Supplier.php
2626
- app/Models/Category.php
@@ -33,14 +33,15 @@ created:
3333
- app/Models/SaleItem.php
3434
- app/Models/Setting.php
3535
models:
36-
Customer: { name: string, email: 'string nullable', phone: 'string nullable', address: text, status: 'enum:active,inactive', gender: 'enum:male,female' }
37-
Supplier: { company_name: string, contact_person: string, email: 'string nullable', phone: 'string nullable', status: 'enum:active,inactive' }
36+
User: { }
37+
Customer: { name: string, email: 'string nullable', phone: 'string nullable', address: text, status: 'enum:active,inactive', gender: 'enum:male,female', relationships: { hasMany: Sale, belongsTo: User } }
38+
Supplier: { company_name: string, contact_person: string, email: 'string nullable', phone: 'string nullable', status: 'enum:active,inactive', relationships: { belongsTo: User } }
3839
Category: { name: string, description: 'text nullable', status: 'enum:active,inactive', relationships: { hasMany: SubCategory } }
3940
SubCategory: { name: string, description: 'text nullable', status: 'enum:active,inactive', relationships: { belongsTo: Category } }
4041
Product: { sku: 'string unique', name: string, purchase_price: decimal, selling_price: decimal, description: 'text nullable', status: 'enum:active,inactive' }
4142
PaymentType: { name: string, description: 'text nullable' }
42-
PurchaseOrder: { purchase_code: 'string unique', order_date: date, expected_delivery_date: 'date nullable', status: 'enum:pending,received,partially received,cancelled', total_amount: decimal, paid_amount: decimal, relationships: { belongsTo: 'Supplier, PaymentType', hasMany: PurchaseOrderItem } }
43+
PurchaseOrder: { purchase_code: 'string unique', order_date: date, expected_delivery_date: 'date nullable', status: 'enum:pending,received,partially_received,cancelled', total_amount: decimal, paid_amount: decimal, relationships: { belongsTo: 'Supplier, PaymentType, User', hasMany: PurchaseOrderItem } }
4344
PurchaseOrderItem: { sku: string, name: string, quantity: integer, unit_cost: decimal, relationships: { belongsTo: 'PurchaseOrder, Product' } }
44-
Sale: { invoice_number: string, sale_date: date, vat: double, total_amount: decimal, paid_amount: decimal, relationships: { belongsTo: 'Customer, PaymentType', hasMany: SaleItem } }
45+
Sale: { invoice_number: string, sale_date: date, vat: double, total_amount: decimal, paid_amount: decimal, relationships: { belongsTo: 'Customer, PaymentType, User', hasMany: SaleItem } }
4546
SaleItem: { sku: string, name: string, quantity: integer, unit_cost: decimal, relationships: { belongsTo: 'Sale, Product' } }
4647
Setting: { company_name: string, phone: string, email: string, address: text, currency: string }

app/Enums/PurchaseOrderEnum.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
use Filament\Support\Contracts\HasColor;
6+
use Filament\Support\Contracts\HasLabel;
7+
8+
enum PurchaseOrderEnum: string implements HasColor, HasLabel
9+
{
10+
case PENDING = 'pending';
11+
case RECEIVED = 'received';
12+
case PARTIALLY_RECEIVED = 'partially_received';
13+
case CANCELLED = 'cancelled';
14+
15+
/**
16+
* @return string
17+
*/
18+
public function getLabel(): string
19+
{
20+
return match ($this) {
21+
self::PENDING => 'Pending',
22+
self::RECEIVED => 'Received',
23+
self::PARTIALLY_RECEIVED => 'Partially Received',
24+
self::CANCELLED => 'Cancelled',
25+
};
26+
}
27+
28+
/**
29+
* @return string
30+
*/
31+
public function getColor(): string
32+
{
33+
return match ($this) {
34+
self::PENDING => 'primary',
35+
self::RECEIVED => 'success',
36+
self::PARTIALLY_RECEIVED => 'warning',
37+
self::CANCELLED => 'danger',
38+
};
39+
}
40+
}

app/Enums/StatusEnum.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
use Filament\Support\Contracts\HasColor;
6+
use Filament\Support\Contracts\HasLabel;
7+
8+
enum StatusEnum: string implements HasColor, HasLabel
9+
{
10+
case ACTIVE = 'active';
11+
case INACTIVE = 'inactive';
12+
13+
/**
14+
* @return string
15+
*/
16+
public function getLabel(): string
17+
{
18+
return match ($this) {
19+
self::ACTIVE => 'Active',
20+
self::INACTIVE => 'Inactive',
21+
};
22+
}
23+
24+
/**
25+
* @return string
26+
*/
27+
public function getColor(): string
28+
{
29+
return match ($this) {
30+
self::ACTIVE => 'success',
31+
self::INACTIVE => 'danger',
32+
};
33+
}
34+
}

app/Enums/StockMovementEnum.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
use Filament\Support\Contracts\HasColor;
6+
use Filament\Support\Contracts\HasLabel;
7+
8+
enum StockMovementEnum: string implements HasColor, HasLabel
9+
{
10+
case PURCHASE = 'purchase';
11+
case SALE = 'sale';
12+
case ADJUSTMENT = 'adjustment';
13+
case RETURN = 'return';
14+
15+
/**
16+
* @return string
17+
*/
18+
public function getLabel(): string
19+
{
20+
return match ($this) {
21+
self::PURCHASE => 'Purchase',
22+
self::SALE => 'Sale',
23+
self::ADJUSTMENT => 'Adjustment',
24+
self::RETURN => 'Return',
25+
};
26+
}
27+
28+
/**
29+
* @return string
30+
*/
31+
public function getColor(): string
32+
{
33+
return match ($this) {
34+
self::PURCHASE => 'info',
35+
self::SALE => 'success',
36+
self::ADJUSTMENT => 'warning',
37+
self::RETURN => 'danger',
38+
};
39+
}
40+
}

app/Filament/Pages/Settings.php

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
namespace App\Filament\Pages;
4+
5+
use App\Http\Middleware\OnboardingMiddleware;
6+
use App\Models\Currency;
7+
use App\Models\Setting;
8+
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
9+
use Filament\Forms\Components\Actions\Action;
10+
use Filament\Forms\Components\FileUpload;
11+
use Filament\Forms\Components\Select;
12+
use Filament\Forms\Components\Textarea;
13+
use Filament\Forms\Components\TextInput;
14+
use Filament\Forms\Concerns\InteractsWithForms;
15+
use Filament\Forms\Contracts\HasForms;
16+
use Filament\Forms\Form;
17+
use Filament\Notifications\Notification;
18+
use Filament\Pages\Page;
19+
use Filament\Support\Exceptions\Halt;
20+
21+
class Settings extends Page implements HasForms
22+
{
23+
use HasPageShield, InteractsWithForms;
24+
25+
public ?array $data = [];
26+
27+
protected static string $view = 'filament.pages.settings';
28+
29+
protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth';
30+
31+
protected static ?string $navigationGroup = 'Admin Menu';
32+
33+
protected static ?int $navigationSort = 4;
34+
35+
protected static string|array $withoutRouteMiddleware = [OnboardingMiddleware::class];
36+
37+
public function mount(): void
38+
{
39+
$setting = Setting::first();
40+
if (empty($setting)) {
41+
return;
42+
}
43+
44+
$this->form->fill($setting->attributesToArray());
45+
}
46+
47+
public function form(Form $form): Form
48+
{
49+
return $form
50+
->schema([
51+
TextInput::make('company_name')
52+
->required(),
53+
TextInput::make('phone')
54+
->tel()
55+
->required(),
56+
TextInput::make('email')
57+
->email()
58+
->required(),
59+
Textarea::make('address')
60+
->required(),
61+
FileUpload::make('company_logo')
62+
->image()
63+
->maxSize(2048),
64+
Select::make('currency')
65+
->options(Currency::getCurrencyList())
66+
->required(),
67+
68+
])
69+
->statePath('data');
70+
}
71+
72+
protected function getFormActions(): array
73+
{
74+
return [
75+
Action::make('save')
76+
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
77+
->submit('save'),
78+
];
79+
}
80+
81+
public function save(): void
82+
{
83+
try {
84+
$data = $this->form->getState();
85+
86+
$setting = Setting::first();
87+
if (empty($setting)) {
88+
Setting::create($data);
89+
} else {
90+
$setting->update($data);
91+
}
92+
} catch (Halt $exception) {
93+
return;
94+
}
95+
96+
Notification::make()
97+
->success()
98+
->title(__('filament-panels::resources/pages/edit-record.notifications.saved.title'))
99+
->send();
100+
}
101+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
namespace App\Filament\Resources;
4+
5+
use App\Filament\Resources\CategoryResource\Pages;
6+
use App\Models\Category;
7+
use Filament\Forms;
8+
use Filament\Forms\Form;
9+
use Filament\Resources\Resource;
10+
use Filament\Tables;
11+
use Filament\Tables\Table;
12+
13+
class CategoryResource extends Resource
14+
{
15+
protected static ?string $model = Category::class;
16+
17+
protected static ?string $navigationIcon = 'heroicon-o-squares-2x2';
18+
19+
protected static ?string $navigationGroup = 'Admin Menu';
20+
21+
protected static ?int $navigationSort = 1;
22+
23+
public static function form(Form $form): Form
24+
{
25+
return $form
26+
->schema([
27+
Forms\Components\Select::make('category_id')
28+
->relationship('category', 'name', ignoreRecord: true)
29+
->nullable(),
30+
Forms\Components\TextInput::make('name')
31+
->required()
32+
->maxLength(255),
33+
Forms\Components\Textarea::make('description')
34+
->columnSpanFull(),
35+
]);
36+
}
37+
38+
public static function table(Table $table): Table
39+
{
40+
return $table
41+
->columns([
42+
Tables\Columns\TextColumn::make('category.name')
43+
->label('Parent Category')
44+
->sortable(),
45+
Tables\Columns\TextColumn::make('name')
46+
->searchable(),
47+
Tables\Columns\TextColumn::make('created_at')
48+
->dateTime()
49+
->sortable()
50+
->toggleable(isToggledHiddenByDefault: true),
51+
Tables\Columns\TextColumn::make('updated_at')
52+
->dateTime()
53+
->sortable()
54+
->toggleable(isToggledHiddenByDefault: true),
55+
])
56+
->filters([
57+
//
58+
])
59+
->actions([
60+
Tables\Actions\EditAction::make(),
61+
])
62+
->bulkActions([
63+
Tables\Actions\BulkActionGroup::make([
64+
Tables\Actions\DeleteBulkAction::make(),
65+
]),
66+
]);
67+
}
68+
69+
public static function getRelations(): array
70+
{
71+
return [
72+
//
73+
];
74+
}
75+
76+
public static function getPages(): array
77+
{
78+
return [
79+
'index' => Pages\ListCategories::route('/'),
80+
'create' => Pages\CreateCategory::route('/create'),
81+
'edit' => Pages\EditCategory::route('/{record}/edit'),
82+
];
83+
}
84+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\CategoryResource\Pages;
4+
5+
use App\Filament\Resources\CategoryResource;
6+
use Filament\Resources\Pages\CreateRecord;
7+
8+
class CreateCategory extends CreateRecord
9+
{
10+
protected static string $resource = CategoryResource::class;
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\CategoryResource\Pages;
4+
5+
use App\Filament\Resources\CategoryResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\EditRecord;
8+
9+
class EditCategory extends EditRecord
10+
{
11+
protected static string $resource = CategoryResource::class;
12+
13+
protected function getHeaderActions(): array
14+
{
15+
return [
16+
Actions\DeleteAction::make(),
17+
];
18+
}
19+
}

0 commit comments

Comments
 (0)