raobilal4822's avatar

raobilal4822 started a new conversation+100 XP

2mos ago

raobilal4822's avatar

raobilal4822 started a new conversation+100 XP

2mos ago

i want to edit the view of cluster's navigation. i want to change the bg of navigation of cluster.

raobilal4822's avatar

raobilal4822 started a new conversation+100 XP

3mos ago

 Section::make('How your Property Looks like')
->schema([
    Select::make('meta.contains_unit')
        ->label('')
        ->options([
            PropertyContainsUnitEnum::SingleRentable->value => 'Single Unit',
            PropertyContainsUnitEnum::MultipleRentable->value => 'Multiple Units',
        ])
        // ->default(PropertyContainsUnitEnum::MultipleRentable->value)
        ->required()
        ->reactive()
        ->columns(2)
        // ->formatStateUsing(fn (string $state): string => dump(ucfirst($state)))
        // ->descriptions([
        //     PropertyContainsUnitEnum::SingleRentable->value => 'Property with one rentable unit',
        //     PropertyContainsUnitEnum::MultipleRentable->value => 'Property with multiple rentable units',
        // ])
        ->live(),

TextInput::make('meta.number_of_units') ->label('Number of Units') ->numeric() ->minValue(2) ->required() ->default(2) ->visible(fn (Get $get) => $get('meta.contains_unit') === PropertyContainsUnitEnum::MultipleRentable->value) ->helperText('Minimum two units required for multiple unit property') ->live()

i have antoher section and i have a repeater in that section i want to get repateer default value on base of meta.numbersof unit how to get this

raobilal4822's avatar

raobilal4822 started a new conversation+100 XP

3mos ago

Select::make('meta.contains_unit') ->label('') ->options([ PropertyContainsUnitEnum::SingleRentable->value => 'Single Unit', PropertyContainsUnitEnum::MultipleRentable->value => 'Multiple Units', ]) ->default( PropertyContainsUnitEnum::MultipleRentable->value) ->required() ->reactive() ->columns(2) ->formatStateUsing(fn (string $state): string => dump(ucfirst($state))) // ->descriptions([ // PropertyContainsUnitEnum::SingleRentable->value => 'Property with one rentable unit', // PropertyContainsUnitEnum::MultipleRentable->value => 'Property with multiple rentable units', // ]) ->live(),

raobilal4822's avatar

raobilal4822 started a new conversation+100 XP

3mos ago

                Grid::make()
                    ->schema([
                        Actions::make([
                            Action::make('configureDeposit')
                                ->label(fn (Get $get) => $get('deposit_direct_to_owner')
                                    ? 'Edit Owner'
                                    : 'Deposit Direct to Owner')
                                ->color('gray')
                                ->icon(fn (Get $get) => $get('deposit_direct_to_owner') ? 'heroicon-m-check-circle' : 'heroicon-m-plus-circle')
                                ->visible(fn (Get $get) => $get('listing_id'))
                                ->modalHeading('Edit Owner')
                                ->modalButton('Update Owner')
                                ->form(function (Get $get, $livewire) {
                                    $listingId = $get('listing_id') ;
                                    if (!$listingId && isset($livewire->record)) {
                                        $listingId = $livewire->record->listing_id ?? null;
                                    }
                                    if (!$listingId) {
                                        return [];
                                    }

                                    $unit = Listing::with('property.owner')->find($listingId);
                                    if (!$unit || !$unit->property || !$unit->property->owner) {
                                        return [];
                                    }

                                    $owner = $unit->property->owner;
                                    return ListingResource::userForm(true);

                                })
                                ->fillForm(function (Get $get, $livewire) {

                                    $listingId = $get('listing_id');
                                    if (!$listingId && isset($livewire->record)) {
                                        $listingId = $livewire->record->listing_id ?? null;
                                    }
                                    if (!$listingId) {
                                        return [];
                                    }

                                    $unit = Listing::with('property.owner')->find($listingId);
                                    if (!$unit || !$unit->property || !$unit->property->owner) {
                                        return [];
                                    }

                                    $owner = $unit->property->owner;

                                    return [
                                        'name' => $owner->name,
                                        'meta' => [
                                            'title' => $owner->meta['title'] ?? null,
                                            'last_name' => $owner->meta['last_name'] ?? null,
                                            'date_of_birth' => $owner->meta['date_of_birth'] ?? null,
                                            'email_notifications' => $owner->meta['email_notifications'] ?? false,
                                            'sms_notifications' => $owner->meta['sms_notifications'] ?? false,
                                            'company_name' => $owner->meta['company_name'] ?? null,
                                            'account_type' => $owner->meta['account_type'] ?? null,
                                            'passport_or_driving_license_number' => $owner->meta['passport_or_driving_license_number'] ?? null,
                                            'add_bank_details' => $owner->meta['add_bank_details'] ?? true,
                                            'account_name' => $owner->bank->account_name ?? null,
                                            'bank_name' => $owner->bank->bank_name ?? null,
                                            'sort_code' => $owner->bank->sort_code ?? null,
                                            'branch_name' => $owner->bank->branch_name ?? null,
                                            'account_number' => $owner->bank->account_number ?? null,
                                            'cc_email_addresses' => $owner->meta['cc_email_addresses'] ?? null,
                                            'notes' => $owner->meta['notes'] ?? null,
                                            'vat_number' => $owner->meta['vat_number'] ?? null,
                                            'website' => $owner->meta['website'] ?? null,
                                        ],
                                        'email' => $owner->email,
                                        'phone_work' => $owner->phone_work,
                                        'mobile' => $owner->mobile,
                                        'address' => $owner->address ?? [],
                                    ];
                                })
                                ->action(function (array $data, Get $get, Set $set, $livewire) {
                                    dd($data);
                                    $listingId = $get('listing_id');
                                    if (!$listingId && isset($livewire->record)) {
                                        $listingId = $livewire->record->listing_id ?? null;
                                    }
                                    if (!$listingId) {
                                        Notification::make()
                                            ->title('Error')
                                            ->body('Unable to find property owner.')
                                            ->danger()
                                            ->send();
                                        return;
                                    }
                                    $unit = Listing::with('property.owner')->find($listingId);
                                    if (!$unit || !$unit->property || !$unit->property->owner) {
                                        Notification::make()
                                            ->title('Error')
                                            ->body('Property owner not found.')
                                            ->danger()
                                            ->send();
                                        return;
                                    }

                                    $owner = $unit->property->owner;

                                    // Update owner details
                                    $updateData = [
                                        'name' => $data['name'],
                                        'email' => $data['email'],
                                        'phone_work' => $data['phone_work'] ?? null,
                                        'mobile' => $data['mobile'] ?? null,
                                        'meta' => array_merge($owner->meta ?? [], [
                                            'title' => $data['meta']['title'] ?? null,
                                            'last_name' => $data['meta']['last_name'] ?? null,
                                            'date_of_birth' => $data['meta']['date_of_birth'] ?? null,
                                            'email_notifications' => $data['meta']['email_notifications'] ?? false,
                                            'sms_notifications' => $data['meta']['sms_notifications'] ?? false,
                                            'company_name' => $data['meta']['company_name'] ?? null,
                                            'account_type' => $data['meta']['account_type'] ?? null,
                                            'passport_or_driving_license_number' => $data['meta']['passport_or_driving_license_number'] ?? null,
                                            'add_bank_details' => $data['meta']['add_bank_details'] ?? false,
                                            'account_name' => $data['meta']['account_name'] ?? null,
                                            'bank_name' => $data['meta']['bank_name'] ?? null,
                                            'sort_code' => $data['meta']['sort_code'] ?? null,
                                            'branch_name' => $data['meta']['branch_name'] ?? null,
                                            'account_number' => $data['meta']['account_number'] ?? null,
                                            'cc_email_addresses' => $data['meta']['cc_email_addresses'] ?? null,
                                            'notes' => $data['meta']['notes'] ?? null,
                                            'vat_number' => $data['meta']['vat_number'] ?? null,
                                            'website' => $data['meta']['website'] ?? null,
                                        ]),
                                        'address' => $data['address'] ?? [],
                                    ];

                                    $owner->update($updateData);

                                    // Update password if provided
                                    if (!empty($data['password'])) {
                                        $owner->update([
                                            'password' => Hash::make($data['password']),
                                        ]);
                                    }

                                    // Enable the toggle if it wasn't already enabled
                                    $set('deposit_direct_to_owner', true);

                                    Notification::make()
                                        ->title('Success')
                                        ->body('Owner details updated successfully.')
                                        ->success()
                                        ->send();
                                })
                        ])->verticalAlignment('center'),
                    ])
                    ->columns(2)

                        ])
                    ->columns(1),

              i am in a form and have a button that open a pop modal with form when i submit that pop modal form then this error is showing that pop up model is submiitng data into parent form. but i am just updating that pop up modal sepratly in action of that action button
raobilal4822's avatar

raobilal4822 started a new conversation+100 XP

3mos ago

i want to use suffix action with toggle but it is showing error

                    ``` Toggle::make('deposit_direct_to_owner')
                        ->label('Deposit to Be Registered')
                        ->required()
                        ->suffixAction(
                            Action::make('copyCostToPrice')
                                ->icon('heroicon-m-clipboard')
                                ->requiresConfirmation()
                                ->form([
                                    Select::make('authorId')
                                        ->label('Author')
                                        ->options(User::query()->pluck('name', 'id'))
                                        ->required(),
                                ])
                                ->action(function (Set $set, $state) {
                                    $set('price', $state);
                                })
                        ),

raobilal4822's avatar

raobilal4822 wrote a reply+100 XP

4mos ago

facing the same type of issue. i have a project in laravel livewire. when i change the language then the static data is changed but the data that is coming from the database is not converting into other language.

raobilal4822's avatar

raobilal4822 wrote a reply+100 XP

4mos ago

I think do it yourself. it will helpful for you for long term

raobilal4822's avatar

raobilal4822 wrote a reply+100 XP

4mos ago

i think just create only two table one is for user and 2nd is for form with a field fields(jsonb) and store field title type and etc in that jsonb field named fields.

raobilal4822's avatar

raobilal4822 started a new conversation+100 XP

4mos ago

I am using a relation with a section like this