Ejemplo n.º 1
0
 public function compose(View $view)
 {
     $makeForm = Request::only('make_id', 'makeyear_id', 'model_id');
     $makes = Make::orderBy('name', 'ASC')->lists('name', 'id')->toArray();
     $makeYears = $models = array();
     if ($makeForm['make_id'] != null) {
         $makeYears = MakeYear::where('make_id', $makeForm['make_id'])->orderBy('year', 'DESC')->lists('year', 'id')->toArray();
         if ($makeForm['makeyear_id'] != null) {
             $models = Model::where('makeyear_id', $makeForm['makeyear_id'])->orderBy('name', 'ASC')->lists('name', 'id')->toArray();
         }
     }
     $view->with(compact('makeForm', 'makes', 'makeYears', 'models'));
 }
Ejemplo n.º 2
0
<?php

use Cars\Models\MakeYear;
use Cars\Models\Model;
Route::get('dropdowns', function () {
    return view('components/dropdowns');
});
Route::get('makeyears/{make_id}', function ($make_id) {
    $years = MakeYear::where('make_id', $make_id)->select('id as value', 'year as text')->orderBy('year', 'DESC')->get()->toArray();
    array_unshift($years, ['value' => '', 'text' => 'Select value']);
    return $years;
});
Route::get('models/{makeyear_id}', function ($makeyear_id) {
    $models = Model::where('makeyear_id', $makeyear_id)->select('id as value', 'name as text')->orderBy('name', 'ASC')->get()->toArray();
    array_unshift($models, ['value' => '', 'text' => 'Select value']);
    return $models;
});