โดย makup » 30/10/2020 7:47 pm
มีการส่งค่า Form มา showAirflight.blade.php
โค้ด: เลือกทั้งหมด
<thead class="thead-dark">
<form class="" method="get" name="search" action="/searchAirflight/search">
<tr>
<th scope="col">ลำดับ</th>
<th scope="col">
<select name="name" id="name" >
<option value="0" selected="selected">---- เลือกทั้งหมด ----</option>
<?php $number = 1; ?>
@foreach($airport as $airports)
<option value="{{$airports->id}} " {{ ( $airports->id == $flight_1['name']) ? 'selected' : '' }}
>{{$number}}<?php echo ".";?>{{$airports->name}} </option>
<?php $number++; ?>
@endforeach
</select>
<br><br>ชื่อที่ตั้งสนามบิน</th>
<th scope="col">
<select name="name_airline" id="name_airline">
<option value="0" selected="selected">---- เลือกทั้งหมด ----</option>
<?php $number = 1; ?>
@foreach($airline as $airlines)
<option value="{{$airlines->id}}" {{ ( $airlines->id == $flight_1['name_airline']) ? 'selected' : '' }}
>{{$number}}<?php echo ".";?>{{$airlines->name_airline}}</option>
<?php $number++; ?>
@endforeach
</select>
<br><br>ชื่อสายการบิน</th>
<th scope="col">
<select name="path" id="path">
<option value="0" selected="selected">---- เลือกทั้งหมด ----</option>
<?php $number = 1; ?>
@foreach($airport as $airports)
<option value="{{$airports->id}}" {{ ( $airports->id == $flight_1['path']) ? 'selected' : '' }}
>{{$number}}<?php echo ".";?>{{$airports->name}}</option>
<?php $number++; ?>
@endforeach
</select>
<br><br>สนามบินปลายทาง</th>
<th scope="col">วันที่</th>
<th scope="col">เวลาออกเดินทาง</th>
<th scope="col">ราคา</th>
<th scope="col">รุ่นเครื่องบิน</th>
<th scope="col">แก้ไข</th>
<th scope="col">
<button type="submit" name="submit" class="btn btn-primary" name="submit">ค้นหา</button>
<br><br>ลบ</th>
</tr>
</form>
</thead>
และส่งเข้าไปที่ Controller_show_airflight.php วิ่งที่ไป Function search()
- 90.JPG (72.14 KiB) Viewed 1396 times
ตัวอย่าง Code : Controller_show_airflight.php
โค้ด: เลือกทั้งหมด
public function search(Request $request)
{
$name = $request->name;
$name_airline = $request->name_airline;
$path = $request->path;
$flight_1 = $request->all();
$flight = Airflight::where('id_airport' , '=' , "{$name}")
->OrWhere('id_airline' , '=' , "{$name_airline}")
->OrWhere('path' , '=' , "{$path}")
->paginate(5);
return view("showAirflight" )
->with('flight', $flight)
->with('flight_1', $flight_1)
->with('airport',Airport::all())
->with('airline',Airline::all())
->with('flight_path',Airflight::all())
;
}
มีการส่งค่า Form มา showAirflight.blade.php
[code]
<thead class="thead-dark">
<form class="" method="get" name="search" action="/searchAirflight/search">
<tr>
<th scope="col">ลำดับ</th>
<th scope="col">
<select name="name" id="name" >
<option value="0" selected="selected">---- เลือกทั้งหมด ----</option>
<?php $number = 1; ?>
@foreach($airport as $airports)
<option value="{{$airports->id}} " {{ ( $airports->id == $flight_1['name']) ? 'selected' : '' }}
>{{$number}}<?php echo ".";?>{{$airports->name}} </option>
<?php $number++; ?>
@endforeach
</select>
<br><br>ชื่อที่ตั้งสนามบิน</th>
<th scope="col">
<select name="name_airline" id="name_airline">
<option value="0" selected="selected">---- เลือกทั้งหมด ----</option>
<?php $number = 1; ?>
@foreach($airline as $airlines)
<option value="{{$airlines->id}}" {{ ( $airlines->id == $flight_1['name_airline']) ? 'selected' : '' }}
>{{$number}}<?php echo ".";?>{{$airlines->name_airline}}</option>
<?php $number++; ?>
@endforeach
</select>
<br><br>ชื่อสายการบิน</th>
<th scope="col">
<select name="path" id="path">
<option value="0" selected="selected">---- เลือกทั้งหมด ----</option>
<?php $number = 1; ?>
@foreach($airport as $airports)
<option value="{{$airports->id}}" {{ ( $airports->id == $flight_1['path']) ? 'selected' : '' }}
>{{$number}}<?php echo ".";?>{{$airports->name}}</option>
<?php $number++; ?>
@endforeach
</select>
<br><br>สนามบินปลายทาง</th>
<th scope="col">วันที่</th>
<th scope="col">เวลาออกเดินทาง</th>
<th scope="col">ราคา</th>
<th scope="col">รุ่นเครื่องบิน</th>
<th scope="col">แก้ไข</th>
<th scope="col">
<button type="submit" name="submit" class="btn btn-primary" name="submit">ค้นหา</button>
<br><br>ลบ</th>
</tr>
</form>
</thead>
[/code]
และส่งเข้าไปที่ Controller_show_airflight.php วิ่งที่ไป Function search()
[attachment=0]90.JPG[/attachment]
ตัวอย่าง Code : Controller_show_airflight.php
[code]
public function search(Request $request)
{
$name = $request->name;
$name_airline = $request->name_airline;
$path = $request->path;
$flight_1 = $request->all();
$flight = Airflight::where('id_airport' , '=' , "{$name}")
->OrWhere('id_airline' , '=' , "{$name_airline}")
->OrWhere('path' , '=' , "{$path}")
->paginate(5);
return view("showAirflight" )
->with('flight', $flight)
->with('flight_1', $flight_1)
->with('airport',Airport::all())
->with('airline',Airline::all())
->with('flight_path',Airflight::all())
;
}
[/code]