วันอังคารที่ 31 ตุลาคม พ.ศ. 2566

Filament infolist view On Resource

 use Filament\Infolists\Infolist;

use Filament\Infolists\Components;

use Filament\Infolists\Components\TextEntry;


    public static function infolist(Infolist $infolist): Infolist
    {
        return $infolist
            ->schema([
              Components\Section::make()
               ->schema([
                Components\TextEntry::make('contrct_no')
               ])

            ]);
    }

Filament Modal slideOver left

 

 ->actions([
              Tables\Actions\ViewAction::make()->slideOver(),

select field first_name and last name show data concat field

 

Select::make('people_id')             
  ->searchable()
  ->getSearchResultsUsing(fn (string $search): array =>
    Peoples::select(DB::raw('CONCAT(first_name ," ", last_name) AS name'), 'id')
   ->where('first_name', 'like', "%{$search}%")->limit(50)->pluck('name', 'id')
->toArray())
  ->getOptionLabelUsing(fn ($value): ?string => Peoples::find($value)->FullName ),

วันศุกร์ที่ 13 ตุลาคม พ.ศ. 2566

Filament Image upload

 php artisan storage:link

 INFO  The [public/storage] link has been connected to [storage/app/public].


          Forms\Components\FileUpload::make('images')
                ->image()
                ->preserveFilenames()
                ->directory('customer-image')
                ->storeFileNamesIn('customers-image')
                ->imageEditor()    
                ->label('รูป') ,
                   ])
               

วันพฤหัสบดีที่ 12 ตุลาคม พ.ศ. 2566

Group Action View Edit Delete Table with :::

 

       
        ->actions([
        Tables\Actions\ActionGroup::make([
                    Tables\Actions\ViewAction::make(),    
                    Tables\Actions\EditAction::make(),
                    Tables\Actions\DeleteBulkAction::make(),
                ])
            ])

วันอังคารที่ 10 ตุลาคม พ.ศ. 2566

Filament error duplicate on edit record

 using ignoreRecord: true


    TextInput::make('name')->required()->unique(ignoreRecord: true)->label('ชื่อห้อง'),

   

วันเสาร์ที่ 7 ตุลาคม พ.ศ. 2566

collapse navigation bar left filament

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
            ->id('admin')
            ->path('admin')
            ->login()
            ->colors([
                'primary' => Color::Amber,
            ])
          ->sidebarCollapsibleOnDesktop() 

         

เพิ่ม Dropdown Navigation Dashboard Filament

 

protected static ?string $navigationGroup = 'ข้อมูลหลัก';   
protected static ?string $modelLabel = 'ข้อมูลจังหวัด ';
   
    protected static ?int $navigationSort = 3;

เปลี่ยน Dashboard ภาษาไทย

 

   
protected static ?string $modelLabel = 'ข้อมูลห้องเช่า ';

Filament fix unique() for editing

 

public static function form(Form $form): Form

    {     
  return $form
            ->schema([
                Card::make()
                ->schema([
     TextInput::make('room_no')->required()->unique(ignoreRecord: true)->label('รหัส'),
    TextInput::make('name')->required()->unique(ignoreRecord: true)->label('ชื่อห้อง'),
      TextInput::make('electric_no')->label('เลขมาตรไฟฟ้า'),
      TextInput::make('water_no')->label('เลขมาตรน้ำ'),
      TextInput::make('electric_unit')->label('หน่วยไฟฟ้าล่าสุด'),
      TextInput::make('water_unit')->label('หน่วยน้ำประปาล่าสุด'),
      TextInput::make('price')->numeric()->label('ราคาห้อง'),
      TextInput::make('price_tax')->numeric()->label('ราคาห้อง ส่งภาษี'),
                        ])->columns(2),
                   
            ]);
    }