Orders are once again writeable
This commit is contained in:
parent
b9346c4466
commit
b74197d9a6
@ -9,6 +9,8 @@
|
|||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
|
use App\Models\ProductService;
|
||||||
|
use App\Models\ServiceFile;
|
||||||
use Filament\Forms\Components\DatePicker;
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Forms\Components\Grid;
|
use Filament\Forms\Components\Grid;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
@ -25,6 +27,7 @@
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Guava\FilamentClusters\Forms\Cluster;
|
use Guava\FilamentClusters\Forms\Cluster;
|
||||||
use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater;
|
use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class OrderResource extends Resource
|
class OrderResource extends Resource
|
||||||
{
|
{
|
||||||
@ -137,18 +140,18 @@ public static function form(Form $form): Form
|
|||||||
->columnSpan(2),
|
->columnSpan(2),
|
||||||
TextInput::make('placement')
|
TextInput::make('placement')
|
||||||
->columnSpan(3),
|
->columnSpan(3),
|
||||||
TextInput::make('service_file_name')
|
TextInput::make('serviceFileName')
|
||||||
->columnSpan(3)
|
->columnSpan(3)
|
||||||
->label('Logo Name'),
|
->label('Logo Name'),
|
||||||
TextInput::make('service_file_setup_number')
|
TextInput::make('serviceFileSetupNumber')
|
||||||
->label('Setup')
|
->label('Setup')
|
||||||
->columnSpan(1),
|
->columnSpan(1),
|
||||||
|
|
||||||
Cluster::make([
|
Cluster::make([
|
||||||
TextInput::make('service_file_width')
|
TextInput::make('serviceFileWidth')
|
||||||
->prefix('w')
|
->prefix('w')
|
||||||
->placeholder('Width'),
|
->placeholder('Width'),
|
||||||
TextInput::make('service_file_height')
|
TextInput::make('serviceFileHeight')
|
||||||
->prefix('h')
|
->prefix('h')
|
||||||
->placeholder('Height'),
|
->placeholder('Height'),
|
||||||
])
|
])
|
||||||
@ -170,7 +173,7 @@ public static function form(Form $form): Form
|
|||||||
|
|
||||||
Grid::make(9)
|
Grid::make(9)
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('service_file_code')
|
TextInput::make('serviceFileCode')
|
||||||
->label('Code')
|
->label('Code')
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
->placeholder('A1234'),
|
->placeholder('A1234'),
|
||||||
@ -183,7 +186,51 @@ public static function form(Form $form): Form
|
|||||||
->reorderable()
|
->reorderable()
|
||||||
->cloneable()
|
->cloneable()
|
||||||
->columns(4)
|
->columns(4)
|
||||||
->columnSpan(2),
|
->columnSpan(2)
|
||||||
|
->mutateRelationshipDataBeforeSaveUsing(function (array $data, ProductService $record): array {
|
||||||
|
dd('yep');
|
||||||
|
|
||||||
|
Log::debug($record->toJson());
|
||||||
|
|
||||||
|
if ($record->serviceFile !== null) {
|
||||||
|
$record->serviceFile->update([
|
||||||
|
'name' => $data['serviceFileName'],
|
||||||
|
'width' => $data['serviceFileWidth'],
|
||||||
|
'height' => $data['serviceFileHeight'],
|
||||||
|
'code' => $data['serviceFileCode'],
|
||||||
|
'setup_number' => $data['serviceFileSetupNumber'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
})
|
||||||
|
->mutateRelationshipDataBeforeFillUsing(function (array $data): array {
|
||||||
|
/** @var ProductService $productService */
|
||||||
|
$productService = ProductService::findOrFail($data['id']);
|
||||||
|
|
||||||
|
$serviceFile = ServiceFile::findOrFail($productService->service_file_id);
|
||||||
|
|
||||||
|
if ($serviceFile !== null) {
|
||||||
|
$data['serviceFileName'] = $serviceFile->name;
|
||||||
|
$data['serviceFileWidth'] = $serviceFile->width;
|
||||||
|
$data['serviceFileHeight'] = $serviceFile->height;
|
||||||
|
$data['serviceFileCode'] = $serviceFile->code;
|
||||||
|
$data['serviceFileSetupNumber'] = $serviceFile->setup_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}),
|
||||||
|
// ->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
|
||||||
|
// $serviceFile = ServiceFile::create([
|
||||||
|
// 'name' => $data['serviceFileName'],
|
||||||
|
// 'width' => $data['serviceFileWidth'],
|
||||||
|
// 'height' => $data['serviceFileHeight'],
|
||||||
|
// 'code' => $data['serviceFileCode'],
|
||||||
|
// 'setup_number' => $data['serviceFileSetupNumber'],
|
||||||
|
// ]);
|
||||||
|
//
|
||||||
|
// return $data;
|
||||||
|
// }),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,49 +18,16 @@ class ProductService extends Model
|
|||||||
'service_file_id',
|
'service_file_id',
|
||||||
'service_type',
|
'service_type',
|
||||||
'placement',
|
'placement',
|
||||||
|
'width',
|
||||||
|
'height',
|
||||||
|
'code',
|
||||||
|
'setup_amount',
|
||||||
|
'logo_name',
|
||||||
'amount',
|
'amount',
|
||||||
'amount_price',
|
'amount_price',
|
||||||
'notes',
|
'notes',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $appends = [
|
|
||||||
'service_file_name',
|
|
||||||
'service_file_setup_number',
|
|
||||||
'service_file_width',
|
|
||||||
'service_file_height',
|
|
||||||
'service_file_code',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function getServiceFileNameAttribute(): string
|
|
||||||
{
|
|
||||||
return $this->serviceFile->name ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceFileSetupNumberAttribute(): string
|
|
||||||
{
|
|
||||||
return $this->serviceFile->setup_number ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceFileWidthAttribute(): string
|
|
||||||
{
|
|
||||||
return $this->serviceFile->width ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceFileHeightAttribute(): string
|
|
||||||
{
|
|
||||||
return $this->serviceFile->height ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServiceFileCodeAttribute(): string
|
|
||||||
{
|
|
||||||
return $this->serviceFile->code ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setServiceFileName(string $name): void
|
|
||||||
{
|
|
||||||
$this->serviceFile->name = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<Order, self>
|
* @return BelongsTo<Order, self>
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +18,14 @@ public function definition(): array
|
|||||||
'sku' => $this->faker->randomElement([$this->faker->randomNumber(4, true), null]),
|
'sku' => $this->faker->randomElement([$this->faker->randomNumber(4, true), null]),
|
||||||
'product_name' => $this->faker->randomElement(['shirts', 'hats', 'jackets', 'pants', 'tote bags', 'backpacks']),
|
'product_name' => $this->faker->randomElement(['shirts', 'hats', 'jackets', 'pants', 'tote bags', 'backpacks']),
|
||||||
'color' => $this->faker->randomElement(['black', 'white', 'navy', 'red', 'gold', 'charcoal']),
|
'color' => $this->faker->randomElement(['black', 'white', 'navy', 'red', 'gold', 'charcoal']),
|
||||||
|
'xs' => $this->faker->numberBetween(0, 10),
|
||||||
|
's' => $this->faker->numberBetween(0, 10),
|
||||||
|
'm' => $this->faker->numberBetween(0, 10),
|
||||||
|
'l' => $this->faker->numberBetween(0, 10),
|
||||||
|
'xl' => $this->faker->numberBetween(0, 10),
|
||||||
|
'2xl' => $this->faker->numberBetween(0, 10),
|
||||||
|
'3xl' => $this->faker->numberBetween(0, 10),
|
||||||
|
'osfa' => $this->faker->numberBetween(0, 10),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ public function definition(): array
|
|||||||
'service_type' => $this->faker->randomElement(['emb', 'scp', 'dtg', 'vinyl']),
|
'service_type' => $this->faker->randomElement(['emb', 'scp', 'dtg', 'vinyl']),
|
||||||
'placement' => $this->faker->randomElement(['l/c', 'c/f', 'f/b', 'r/c']),
|
'placement' => $this->faker->randomElement(['l/c', 'c/f', 'f/b', 'r/c']),
|
||||||
'amount' => $this->faker->randomNumber(1),
|
'amount' => $this->faker->randomNumber(1),
|
||||||
|
'code' => $this->faker->randomElement(['A', 'B']).$this->faker->randomNumber(4, true),
|
||||||
|
'logo_name' => $this->faker->word(),
|
||||||
|
'width' => round($this->faker->randomFloat(2, 0, 10), 1),
|
||||||
|
'height' => round($this->faker->randomFloat(2, 0, 10), 1),
|
||||||
'amount_price' => 0,
|
'amount_price' => 0,
|
||||||
'notes' => $this->faker->randomElement(['1) 1149 2) grey 3) white', '1) white', '1) black 2) white']),
|
'notes' => $this->faker->randomElement(['1) 1149 2) grey 3) white', '1) white', '1) black 2) white']),
|
||||||
];
|
];
|
||||||
|
@ -14,6 +14,16 @@ public function up(): void
|
|||||||
$table->string('sku')->nullable();
|
$table->string('sku')->nullable();
|
||||||
$table->string('product_name');
|
$table->string('product_name');
|
||||||
$table->string('color')->nullable();
|
$table->string('color')->nullable();
|
||||||
|
|
||||||
|
$table->string('xs')->nullable();
|
||||||
|
$table->string('s')->nullable();
|
||||||
|
$table->string('m')->nullable();
|
||||||
|
$table->string('l')->nullable();
|
||||||
|
$table->string('xl')->nullable();
|
||||||
|
$table->string('2xl')->nullable();
|
||||||
|
$table->string('3xl')->nullable();
|
||||||
|
$table->string('osfa')->nullable();
|
||||||
|
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
@ -14,6 +14,11 @@ public function up(): void
|
|||||||
$table->foreignId('service_file_id')->nullable();
|
$table->foreignId('service_file_id')->nullable();
|
||||||
$table->string('service_type');
|
$table->string('service_type');
|
||||||
$table->string('placement');
|
$table->string('placement');
|
||||||
|
$table->string('logo_name');
|
||||||
|
$table->string('width');
|
||||||
|
$table->string('height');
|
||||||
|
$table->string('setup_amount')->nullable();
|
||||||
|
$table->string('code');
|
||||||
$table->string('amount')->nullable();
|
$table->string('amount')->nullable();
|
||||||
$table->string('amount_price')->nullable();
|
$table->string('amount_price')->nullable();
|
||||||
$table->string('notes')->nullable();
|
$table->string('notes')->nullable();
|
||||||
|
@ -22,8 +22,7 @@ public function run(): void
|
|||||||
->has(Contact::factory(rand(1, 5)))
|
->has(Contact::factory(rand(1, 5)))
|
||||||
->has(ShippingEntry::factory(rand(1, 3)))
|
->has(ShippingEntry::factory(rand(1, 3)))
|
||||||
->has(Order::factory(rand(5, 10))
|
->has(Order::factory(rand(5, 10))
|
||||||
->has(OrderProduct::factory(rand(1, 3))
|
->has(OrderProduct::factory(rand(1, 3)))
|
||||||
->has(productSize::factory(rand(1, 3))))
|
|
||||||
->has(ProductService::factory(rand(1, 5), [
|
->has(ProductService::factory(rand(1, 5), [
|
||||||
'service_file_id' => ServiceFile::factory(),
|
'service_file_id' => ServiceFile::factory(),
|
||||||
]))
|
]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user