From e484c0df9823c9de25c276d05d8d651cfed1c582 Mon Sep 17 00:00:00 2001 From: Russ Long Date: Sun, 4 Sep 2022 13:57:38 -0400 Subject: [PATCH] resource setup --- app/Filament/Resources/BiddersResource.php | 6 +++++- app/Filament/Resources/CheckoutResource.php | 11 ++++++++++- app/Filament/Resources/ItemsResource.php | 14 +++++++++++++- .../VehicleOwnerRelationManager.php | 13 ++++++++++++- .../VehicleTypeRelationManager.php | 12 +++++++++--- app/Models/Bidders.php | 3 +++ app/Models/Checkout.php | 7 +++++-- app/Models/Items.php | 3 +++ app/Models/PaymentMethods.php | 3 +++ app/Models/WinningBids.php | 3 +++ 10 files changed, 66 insertions(+), 9 deletions(-) diff --git a/app/Filament/Resources/BiddersResource.php b/app/Filament/Resources/BiddersResource.php index ab89b3c..dfbf30a 100644 --- a/app/Filament/Resources/BiddersResource.php +++ b/app/Filament/Resources/BiddersResource.php @@ -19,6 +19,8 @@ class BiddersResource extends Resource { protected static ?string $model = Bidders::class; + protected static ?string $recordTitleAttribute = 'idbidders'; + protected static ?string $navigationIcon = 'heroicon-o-collection'; protected static ?string $navigationGroup = 'Silent Auction'; @@ -67,7 +69,9 @@ class BiddersResource extends Resource public static function getRelations(): array { return [ - // + RelationManagers\VehiclesRelationManager::class, + RelationManagers\CheckoutRelationManager::class, + RelationManagers\WinningBidsRelationManager::class, ]; } diff --git a/app/Filament/Resources/CheckoutResource.php b/app/Filament/Resources/CheckoutResource.php index 9653133..6b2dd50 100644 --- a/app/Filament/Resources/CheckoutResource.php +++ b/app/Filament/Resources/CheckoutResource.php @@ -37,7 +37,16 @@ class CheckoutResource extends Resource { return $table ->columns([ - // + TextColumn::make('bidders.bidder_assigned_number') + ->label('Bidder Number') + ->sortable(), + TextColumn::make('winnertotal') + ->label('Total Amount') + ->money('usd', 'true') + ->sortable(), + TextColumn::make('paymentMethod.pm_name') + ->label('Payment Method') + ->sortable(), ]) ->filters([ // diff --git a/app/Filament/Resources/ItemsResource.php b/app/Filament/Resources/ItemsResource.php index 51b1e39..b6ff027 100644 --- a/app/Filament/Resources/ItemsResource.php +++ b/app/Filament/Resources/ItemsResource.php @@ -37,7 +37,19 @@ class ItemsResource extends Resource { return $table ->columns([ - // + TextColumn::make('item_assigned_num') + ->label('Item Number') + ->sortable(), + TextColumn::make('item_desc') + ->label('Description'), + TextColumn::make('item_min_bid') + ->label('Minimum Bid') + ->money('usd', 'true') + ->sortable(), + TextColumn::make('item_est_value') + ->label('Estimated Value') + ->money('usd', 'true') + ->sortable(), ]) ->filters([ // diff --git a/app/Filament/Resources/VehiclesResource/RelationManagers/VehicleOwnerRelationManager.php b/app/Filament/Resources/VehiclesResource/RelationManagers/VehicleOwnerRelationManager.php index 0679234..8e72f36 100644 --- a/app/Filament/Resources/VehiclesResource/RelationManagers/VehicleOwnerRelationManager.php +++ b/app/Filament/Resources/VehiclesResource/RelationManagers/VehicleOwnerRelationManager.php @@ -22,7 +22,18 @@ class VehicleOwnerRelationManager extends RelationManager ->schema([ Forms\Components\Select::make('bidder_assigned_number') ->label('Number') - ->required(), + ->required() + ->createOptionForm([ + Forms\Components\TextInput::make('bidder_fname')->label('First Name'), + Forms\Components\TextInput::make('bidder_lname')->label('Last Name'), + Forms\Components\TextInput::make('bidder_addr')->label('Address'), + Forms\Components\TextInput::make('bidder_city')->label('City'), + Forms\Components\TextInput::make('bidder_state')->label('State'), + Forms\Components\TextInput::make('bidder_zip')->label('Zip'), + Forms\Components\TextInput::make('bidder_phone')->label('Phone Number'), + Forms\Components\TextInput::make('bidder_email')->label('Email'), + Forms\Components\TextInput::make('bidder_assigned_number')->label('Assigned Number'), + ]), ]); } diff --git a/app/Filament/Resources/VehiclesResource/RelationManagers/VehicleTypeRelationManager.php b/app/Filament/Resources/VehiclesResource/RelationManagers/VehicleTypeRelationManager.php index e35fdfc..248b748 100644 --- a/app/Filament/Resources/VehiclesResource/RelationManagers/VehicleTypeRelationManager.php +++ b/app/Filament/Resources/VehiclesResource/RelationManagers/VehicleTypeRelationManager.php @@ -9,20 +9,26 @@ use Filament\Resources\Table; use Filament\Tables; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; +use App\Models\CarShowCategory; class VehicleTypeRelationManager extends RelationManager { protected static string $relationship = 'vehicleType'; - protected static ?string $recordTitleAttribute = 'type'; + protected static ?string $recordTitleAttribute = 'id'; public static function form(Form $form): Form { return $form ->schema([ - Forms\Components\TextInput::make('category_name') + Forms\Components\Select::make('category_name') ->required() - ->maxLength(255), + ->searchable() + ->options(CarShowCategory::vehtype()->pluck('category_name', 'id')) + ->createOptionForm([ + Forms\Components\TextInput::make('category_name'), + Forms\Components\Toggle::make('vehicle_type')->inline(false), + ]), ]); } diff --git a/app/Models/Bidders.php b/app/Models/Bidders.php index ff3b87d..136ba88 100644 --- a/app/Models/Bidders.php +++ b/app/Models/Bidders.php @@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\Model; class Bidders extends Model { protected $table = 'bidders'; + + protected $primaryKey = 'idbidders'; + protected $fillable = [ 'bidder_fname', 'bidder_lname', diff --git a/app/Models/Checkout.php b/app/Models/Checkout.php index f30308f..38bbfbf 100644 --- a/app/Models/Checkout.php +++ b/app/Models/Checkout.php @@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\Model; class Checkout extends Model { protected $table = 'checkout'; + + protected $primaryKey = 'checkout_id'; + protected $fillable = [ 'bidder_num', 'winnertotal', @@ -25,11 +28,11 @@ class Checkout extends Model public function bidders() { - return $this->belongsTo(Bidders::class, 'idbidders'); + return $this->belongsTo(Bidders::class, 'bidder_num'); } public function paymentMethod() { - return $this->hasMany(PaymentMethods::class, 'payment_method', 'pm_id'); + return $this->hasMany(PaymentMethods::class, 'pm_id', 'payment_method'); } } diff --git a/app/Models/Items.php b/app/Models/Items.php index 677ab21..38d1d86 100644 --- a/app/Models/Items.php +++ b/app/Models/Items.php @@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\Model; class Items extends Model { protected $table = 'items'; + + protected $primaryKey = 'iditems'; + protected $fillable = [ 'item_desc', 'item_min_bid', diff --git a/app/Models/PaymentMethods.php b/app/Models/PaymentMethods.php index 735919a..3729622 100644 --- a/app/Models/PaymentMethods.php +++ b/app/Models/PaymentMethods.php @@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\Model; class PaymentMethods extends Model { protected $table = 'payment_methods'; + + protected $primaryKey = 'pm_id'; + protected $fillable = [ 'pm_name', 'created_at', diff --git a/app/Models/WinningBids.php b/app/Models/WinningBids.php index e532bf8..c08acd5 100644 --- a/app/Models/WinningBids.php +++ b/app/Models/WinningBids.php @@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\Model; class WinningBids extends Model { protected $table = 'winning_bids'; + + protected $primaryKey = 'idwinning_bids'; + protected $fillable = [ 'winning_bidder_num', 'winning_cost',