【发布时间】:2018-05-19 15:27:29
【问题描述】:
我的控制器中有一个创建方法
public function create()
{
$image = PropertyUser::where('user_id', '=', Auth::user()->id)->get();
foreach($image as $property)
{
$id = $property->property_id;
}
$image_main = Image::where('property_id', $id)->get();
return view('settings.photos', ['image_array' => $image_main]);
}
这是我的刀片视图
<form name="asc" action="{{route("settings.photos")}}" method="post" class="text-center">
@csrf
<input type="submit" value="Ascending " class="settings-photos-header2 text-center"/> |
</form><form name="dec" action="{{route("settings.photos")}}" method="post" class="text-center">
@csrf
<input type="submit" value= " Descending" class="settings-photos-header2 text-center"/>
</form>
<h2 class="settings-photos-header2 text-center">Photo Gallery</h2>
@foreach ($image_array as $images)
<div class="image-warp"><img src="{{$images->filename}}"
style="width:100px;height:100px;"><br/><span style="color: #1b1e21">{{$images->description}}</span>
</form>
</div>
@endforeach
问题-
我怎样才能让 asc 按钮按升序和 des 降序对图像进行排序,有没有办法将它连接到我的控制器,或者有没有办法通过<a href> 链接按升序和降序对它们进行排序?
【问题讨论】:
-
升序降序是什么意思?我什至没有看到表单的输入字段。
-
不一定是表单,可以是链接,只要按钮/链接按特定顺序对图像进行排序