<?php

namespace App\Filament\Resources;

use App\Filament\Resources\InvestResource\Pages;
use App\Filament\Resources\InvestResource\RelationManagers;
use App\Models\Invest;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class InvestResource extends Resource
{
    protected static ?string $model = Invest::class;

    protected static ?string $navigationIcon = 'heroicon-o-collection';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('user_id')
                    ->required(),
                Forms\Components\Toggle::make('status')
                    ->required(),
                Forms\Components\TextInput::make('returns')
                    ->required(),
                Forms\Components\TextInput::make('capital')
                    ->required(),
                Forms\Components\TextInput::make('end_date')
                    ->required()
                    ->maxLength(255),
                Forms\Components\TextInput::make('days_paid')
                    ->required()
                    ->maxLength(255),
                Forms\Components\TextInput::make('date')
                    ->required()
                    ->maxLength(255),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('user_id'),
                Tables\Columns\IconColumn::make('status')
                    ->boolean(),
                Tables\Columns\TextColumn::make('returns'),
                Tables\Columns\TextColumn::make('capital'),
                Tables\Columns\TextColumn::make('end_date'),
                Tables\Columns\TextColumn::make('days_paid'),
                Tables\Columns\TextColumn::make('date'),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime(),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime(),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ]);
    }
    
    public static function getRelations(): array
    {
        return [
            //
        ];
    }
    
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListInvests::route('/'),
            'create' => Pages\CreateInvest::route('/create'),
            'edit' => Pages\EditInvest::route('/{record}/edit'),
        ];
    }    
}
