Laravel- arranging records in ascending and descending order
I have a create method in my controller
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]);
}
This is my photos.blade file
<form name="asc" action="" method="post" class="text-center">
@csrf
<input type="submit" value="Ascending " class="settings-photos-header2 text-center"/> |
</form><form name="dec" action="" 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=""
style="width:100px;height:100px;"><br/><span style="color: #1b1e21"></span>
</form>
</div>
@endforeach
Question- How can i make the asc button sort the images in ascending order and des in descending order, is there a way to connect it to my controller, or is there a way to sort them in ascending and descending order through any other means?
from Laravel Questions and Answers https://laravelquestions.com/php/laravel-arranging-records-in-ascending-and-descending-order/
via Lzo Media
No comments:
Post a Comment