Gianmarco Varrone
Form field not updating with reactive()
public function mount($relayNumber, $controlUnit)
{
$this->relayNumber = $relayNumber;
$this->controlUnit = $controlUnit;
$pointOfSale = PointOfSale::find($controlUnit->point_of_sale_id);
$this->shop_opening_time = $pointOfSale->opening_time;
$this->shop_closing_time = $pointOfSale->closing_time;
$relays = $this->controlUnit->relays()->get();
}
protected function getFormSchema() : array
{
return[
TextInput::make("name")->required()->label("Identificatore relay"),
TimePicker::make('turn_on_at')->label("Orario accensione relay")->reactive(),
Checkbox::make("turn_on_opening")
->label("Accendi questo interruttore all'apertura del negozio")
->inline()
->reactive()
->afterStateUpdated(fn ($state, callable $set)=> $set("turn_on_at", $this->shop_opening_time)),
Checkbox::make("turn_on_closing")->label("Accendi questo interruttore alla chiusura del negozio")->inline(),
TimePicker::make('turn_off_at')->label("Orario spegnimento relay"),
Checkbox::make("turn_off_opening")->label("Spegni questo interruttore all'apertura del negozio")->inline(),
Checkbox::make("turn_off_closing")->label("Spegni questo interruttore alla chiusura del negozio")->inline(),
];
}
5 replies
Editing multiple images
And in the after create I'm doing :
protected function afterCreate(): void
{
foreach($this->data['photos'] as $key=>$value){
$data = [
'point_of_sale_id'=>$this->record->id,
'do_cdn_url' => 'https://closbox.ams3.cdn.digitaloceanspaces.com/' . $value,
];
PosImage::create($data);
}
}
10 replies
Editing multiple images
This is the file upload I'm using in the form:
Section::make('Fotografie')
->description("Carica almeno 10 fotografie")
->schema([
Forms\Components\FileUpload::make('photos')
->multiple()
->enableDownload()
->enableOpen()
->enableReordering()
->disk('do_spaces')
->directory("photos/". Carbon::now()->format('Y'). "/".Carbon::now()->format('m'). "/".Carbon::now()->format('d'). "/")
->visibility('public')
->image()
->imageResizeMode('cover')
->imageCropAspectRatio('16:9')
->imageResizeTargetWidth('1920')
->imageResizeTargetHeight('1080'),
])->columns(1)
10 replies
How to get the current record in lifecycle hook after() method on pop up
Following the code I'm trying :
Actions\CreateAction::make()->mutateFormDataUsing(function (array $data) {
if($data["is_recursive"]){
$data["status"] = "ongoing";
}else{
$data["status"] = "created";
}
return $data;
})->after(function(array $data, $record){
dd($record);
RevolutPayment::create();
}),
11 replies