mardi 2 octobre 2018

Laravel - Populate Select Box with other select box based on selected data

My database

make_models
models_id make_id
1 1
4 1
10 1
11 2
17 2
makes
1
2
models
1
4
10
11
17

Controller

$makes=make::all();
$models=models::all();
return view('admin.vehicles.create',compact('makes','models'));

create.blade.php
for makes

<select class="form-control">
   @foreach($makes as $make)
       <option value=""></option>
   @endforeach
</select>

Model

public function makes()
    {
        return $this->belongsToMany('App\Model\Make','make_models')->withTimestamps();
    }

this is like category and subcategory but i cant follow



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire