Download the PHP package gerardojbaez/vehicle without Composer
On this page you can find all versions of the php package gerardojbaez/vehicle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gerardojbaez/vehicle
More information about gerardojbaez/vehicle
Files in gerardojbaez/vehicle
Package vehicle
Short Description Laravel 5.2 package to work with vehicles data.
License
Informations about the package vehicle
Vehicles Data for Laravel 5.2
This package allows you to work with vehicles makes, models, years and other details in Laravel 5.2.
Where the data come from?
The original list was collected from www.fueleconomy.gov. (They offer XML and CSV files). The list is updated and validated against some industry standards.
Content
- Installation
- Composer
- Service Provider
- Config File, Migrations and Seeders
- Traits and Contracts
- Usage
- The CSV File
- Models
- Controllers
- Routes
- License
Installation
Composer
Pull this package through Composer (file composer.json
)
Run this command inside your terminal.
composer update
Service Provider
Add the package to your application service providers in config/app.php file.
Config File, Migration and Seeders
Publish package config file, migrations and seeders with the command:
php artisan vendor:publish
Then run migrations.
php artisan migrate
Then the vehicle seeder.
php artisan db:seed --class VehicleTablesSeeder
Traits and Contracts
When one of your models has make, model, model year and/or a vehicle you can add the required relations with the traits.
See the following example:
You do not need to use all traits if you do not need them. You can use only
HasMake
trait when only make is used for example.
Usage
The CSV file
All data is stored in a CSV file. This is done so it's easy to manage.
File structure:
Make | Model | Year | cylinders | displacement | drive | transmission | class |
---|---|---|---|---|---|---|---|
Acura | ILX | 2017 | 4 | 2.4 | Front-Wheel Drive | 8-Speed Automated Manual | Compact Cars |
Update the CSV file
Export to the desired location:
php artisan vehicle:export "/path/to/exported/file.csv"
When you have done, run:
php artisan vehicle:generate "/path/to/exported/file.csv"
php artisan db:seed --class VehicleTablesSeeder
The
vehicle:generate
command will generate individual files containing its own data to be used with seeders.Remember to
migrate:refresh
if you have prevously seeded the database!
Models
This package comes with Gerardojbaez\Vehicle\Models\VehicleMake
,
Gerardojbaez\Vehicle\Models\VehicleModel
,
Gerardojbaez\Vehicle\Models\VehicleModelYear
and
Gerardojbaez\Vehicle\Models\Vehicle
models.
For more information please take a look at each model.
Controllers
It's more likely that you will want to retrieve makes, models and years from your frontend (via ajax for example); we have created these basic controllers for you:
Gerardojbaez\Vehicle\Controllers\MakesController
,
Gerardojbaez\Vehicle\Controllers\ModelsController
,
Gerardojbaez\Vehicle\Controllers\ModelYearsController
,
Gerardojbaez\Vehicle\Controllers\VehicleController
. You can use these directly or extends with your own.
Controllers returns a json reponse containing (if any) the requested data.
Routes
This is an example. You can structure these routes as you want.
License
This package is free software distributed under the terms of the MIT license.