I have this small website car project and I need in my create.blade.php to have unique selections, for example:
...
<div class="column">
<label for="brand">Brand</label></br>
<select class="form-control" id="soflow" name="brand">
<option value="" disabled selected>Select your option</option>
<option value="Volkswagen">Volkswagen</option>
<option value="BMW">BMW</option>
<option value="Audi">Audi</option>
</select>
</div>
</br>
<div class="column">
<label for="model">Model</label></br>
<select class="form-control" id="soflow" name="model">
<option value="" disabled selected>Select your option</option>
<option value="Golf1">Golf 1</option>
<option value="Golf2">Golf 2</option>
<option value="Golf3">Golf 3</option>
</select>
</div>
...
So if user select Volkswagen on another select it shows him Models for Volkswagen: Golf 1, Golf 2, Golf 3... And if user for example select Audi it needs to show him models for Audi on next selection. How can I do this? Is there any if statement or something like that?
EDITED:
My PostsController.php :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Post;
class PostsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$posts = Post::all();
return view('welcome')->with('posts', $posts);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required',
'brand' => 'required',
'model' => 'required',
'safety' => 'required',
'equipment' => 'required',
'condition' => 'required',
'price' => 'required',
'priceoption' => 'required'
]);
$posts = new Post;
$posts->title = $request->input('title');
$posts->brand = $request->input('brand');
$posts->model = $request->input('model');
$posts->safety = $request->input('safety');
$posts->equipment = $request->input('equipment');
$posts->condition = $request->input('condition');
$posts->price = $request->input('price');
$posts->save();
return 123;
}
My Post.php model :
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
protected $table = 'posts';
protected $primaryKey = 'id';
}
I just started my project.
Aucun commentaire:
Enregistrer un commentaire