PHP code example of bigperson / auto-base-buy

1. Go to this page and download the library: Download bigperson/auto-base-buy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bigperson / auto-base-buy example snippets


namespace App\Http\Controllers;

use Bigperson\AutoBaseBuy\Models\CarMark;

class Controller
{
    protected function show($id){

        $mark = CarMark::findOrFail($id);
        
    }
}

namespace App;

use Bigperson\AutoBaseBuy\Models\CarModification;

class User extends Model
{
     public function car()
     {
         return $this->belongsTo(CarModification::class, 'id_car_modification');
     }
}

namespace App;

use Bigperson\AutoBaseBuy\Models\CarModification as BaseCarModification;

class CarModification extends BaseCarModification
{
    /**
     * Получить полное название автомобиля, включая марку, модель, годы выпуска, серию
     * @return string
     */
    public function getFullNameAttribute()
    {
        $string = $this->carModel->carMark->name;
        $string .= ' '.$this->carModel->name;
        $string .= ' '.$this->carSerie->name;
        $string .= ' '.$this->carSerie->carGeneration->name;
        $string .= ' ('.$this->carSerie->carGeneration->year_begin.'-'.$this->carSerie->carGeneration->year_end.')';
        $string .= ' '.$this->name;

        return $string;
    }
}

 php artisan vendor:publish --tag=migrations --provider="Bigperson\AutoBaseBuy\AutoBaseBuyServiceProvider"

php artisan migrate

 php artisan vendor:publish --tag=seeds --provider="Bigperson\AutoBaseBuy\AutoBaseBuyServiceProvider"

php artisan db:seed --class=AutoBusyBuySeeder