Php 如何在laravel 5.6中的一个刀片文件中使用不同的形式
我正在使用Laravel5.6,我正在开发自动分类web应用程序。在我的应用程序中,我有3种不同的车辆类别,如汽车、面包车、卡车,我有刀片文件来选择这三种不同的车辆类型。当我选择此项时,我的URL显示如下Php 如何在laravel 5.6中的一个刀片文件中使用不同的形式,php,laravel,forms,laravel-blade,Php,Laravel,Forms,Laravel Blade,我正在使用Laravel5.6,我正在开发自动分类web应用程序。在我的应用程序中,我有3种不同的车辆类别,如汽车、面包车、卡车,我有刀片文件来选择这三种不同的车辆类型。当我选择此项时,我的URL显示如下 http://localhost:8000/post-ad/Truck/8 <- this is category id http://localhost:8000/post-ad/van/7 http://localhost:8000/post-ad/Car/5 http://l
http://localhost:8000/post-ad/Truck/8 <- this is category id
http://localhost:8000/post-ad/van/7
http://localhost:8000/post-ad/Car/5
http://localhost:8000/post-广告/卡车/8
地区
城镇
烙印
模型
厢式货车
<form method="post" action="{{url('form')}}" enctype="multipart/form-data">
{{csrf_field()}}
<input type="hidden" id="cid" name="cid" value="{{ $catagories->id }}" />
<div class="form-group">
<label for="exampleFormControlSelect1">District</label>
<select class="form-control" id="exampleFormControlSelect1" name="district">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Town</label>
<select class="form-control" id="exampleFormControlSelect1" name="town">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Model</label>
<select class="form-control" id="exampleFormControlSelect1" name="model">
</select>
</div>
</form>
{{csrf_field()}}
地区
城镇
烙印
模型
卡车形式
<form method="post" action="{{url('form')}}" enctype="multipart/form-data">
{{csrf_field()}}
<input type="hidden" id="cid" name="cid" value="{{ $catagories->id }}" />
<div class="form-group">
<label for="exampleFormControlSelect1">District</label>
<select class="form-control" id="exampleFormControlSelect1" name="district">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Town</label>
<select class="form-control" id="exampleFormControlSelect1" name="town">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Model</label>
<select class="form-control" id="exampleFormControlSelect1" name="model">
</select>
</div>
</form>
{{csrf_field()}}
地区
城镇
烙印
模型
我需要显示每个表单时,一些用户单击一个刀片文件上的每个车辆链接。如何执行此操作?您可以在路线中添加名称,例如:
Route::group(['prefix' => 'post-ad'], function () {
Route::get('Truck/{id}', 'TruckController@fetch')->name('track');
Route::get('Van/{id}', 'VanController@fetch')->name('van');
Route::get('Car/{id}', 'CarController@fetch')->name('car');
})
将表单放入其他文件,如:
truck-form.blade.php
van-form.blade.php
car-form.blade.php
在你看来:
@if(request()->route()->getName() = 'track')
@include('truck-form')
@elseif(request()->route()->getName() = 'van')
@include('van-form')
@elseif
@include('van-form')
@endif
您可以简单地创建一个表单,并为车辆类型添加html
select
,因为这是一个示例,我有不同表单中的不同数据。如果有其他条件,我应该将其放在哪里?在我的show.blade.php文件中,根据我的问题?这里有一个问题。我正在使用我的路线,因为这辆面包车意味着类别名称,7是类别id。那么,我如何根据您的答案放置我的路线,如route::get('Truck/{id}','TruckController@fetch')->name('track')@班达更新回答,只是带前缀的用户组,我想你需要了解更多关于laravel中路线的信息。好的,我得到了路线,但控制器仍然有一些问题。我已经为车辆创建了控制器,但不知道在这里放取方法。。实际上,我对laravelpublic函数fetch($id){$car=car::where('id',$id)->first(),return view('show',['vehicle'=>$car]);}还不熟悉
@if(request()->route()->getName() = 'track')
@include('truck-form')
@elseif(request()->route()->getName() = 'van')
@include('van-form')
@elseif
@include('van-form')
@endif