vehicle sort

This commit is contained in:
Russ Long 2022-08-07 13:34:06 -04:00
parent 7d4964e268
commit 3c6097a5b2
5 changed files with 133 additions and 34 deletions

View File

@ -33,8 +33,9 @@ class PeoplesChoiceResource extends Resource
->schema([
Select::make('vehicle')
->label('Vehicle')
->options(Vehicles::all()->pluck('owner', 'id')->sortBy('owner'))
->searchable(),
->options(Vehicles::all()->pluck('owner', 'id'))
->searchable()
->orderable('owner'),
TextInput::make('pc_count'),
]);
}

View File

@ -3,41 +3,51 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;
class Vehicles extends Model
class Vehicles extends Model implements Sortable
{
protected $table = 'vehicles';
protected $fillable = [
'year',
'make',
'model',
'type',
'doNotJudge',
'owner'
];
use SortableTrait;
public $sortable = [
'order_column_name' => 'owner',
'sort_when_creating' => true,
];
protected $dates = [
'created_at',
'updated_at'
];
protected $table = 'vehicles';
public function vehicleType()
{
return $this->belongsTo('App\Models\CarShowCategory', 'type', 'id');
}
protected $fillable = [
'year',
'make',
'model',
'type',
'doNotJudge',
'owner'
];
public function vehicleOwner()
{
return $this->belongsTo('App\Models\Bidders', 'owner', 'bidder_assigned_number');
}
protected $dates = [
'created_at',
'updated_at'
];
public function vehicleScores()
{
return $this->hasMany('App\Models\VechicleScores', 'id', 'vehicle');
}
public function vehicleType()
{
return $this->belongsTo('App\Models\CarShowCategory', 'type', 'id');
}
public function CarShowWinner()
{
return $this->belongsTo('App\Models\CarShowWinner', 'id', 'vehicle');
}
public function vehicleOwner()
{
return $this->belongsTo('App\Models\Bidders', 'owner', 'bidder_assigned_number');
}
public function vehicleScores()
{
return $this->hasMany('App\Models\VechicleScores', 'id', 'vehicle');
}
public function CarShowWinner()
{
return $this->belongsTo('App\Models\CarShowWinner', 'id', 'vehicle');
}
}

View File

@ -11,7 +11,8 @@
"filament/filament": "^2.0",
"laravel/framework": "^9.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^3.0"
"laravel/ui": "^3.0",
"spatie/eloquent-sortable": "^4.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.7",

75
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c45f3039cd29758426fcc94f942f94f5",
"content-hash": "746d38f8fb6ae9be134c6ba49f0c1273",
"packages": [
{
"name": "akaunting/laravel-money",
@ -3554,6 +3554,79 @@
],
"time": "2021-02-11T11:37:01+00:00"
},
{
"name": "spatie/eloquent-sortable",
"version": "4.0.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/eloquent-sortable.git",
"reference": "64a3365c0d5a7b4a1837b2f29d01ee4c578c416a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/eloquent-sortable/zipball/64a3365c0d5a7b4a1837b2f29d01ee4c578c416a",
"reference": "64a3365c0d5a7b4a1837b2f29d01ee4c578c416a",
"shasum": ""
},
"require": {
"illuminate/database": "^8.0|^9.0",
"illuminate/support": "^8.0|^9.0",
"php": "^8.0",
"spatie/laravel-package-tools": "^1.9"
},
"require-dev": {
"orchestra/testbench": "^6.0|^7.0",
"phpunit/phpunit": "^9.5"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\EloquentSortable\\EloquentSortableServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\EloquentSortable\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be"
}
],
"description": "Sortable behaviour for eloquent models",
"homepage": "https://github.com/spatie/eloquent-sortable",
"keywords": [
"behaviour",
"eloquent",
"laravel",
"model",
"sort",
"sortable"
],
"support": {
"issues": "https://github.com/spatie/eloquent-sortable/issues",
"source": "https://github.com/spatie/eloquent-sortable/tree/4.0.1"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
},
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2022-01-21T08:32:41+00:00"
},
{
"name": "spatie/laravel-package-tools",
"version": "1.12.1",

View File

@ -0,0 +1,14 @@
<?php
return [
/*
* Which column will be used as the order column.
*/
'order_column_name' => 'order_column',
/*
* Define if the models should sort when creating.
* When true, the package will automatically assign the highest order number to a new mode
*/
'sort_when_creating' => true,
];