Title.. A picture of the display page, if I want to sort by a condition, for example, according to the order of the reverse ID, then the blade.php
How the conditional update link should be written?
public function index() { $images = Image::paginate(10); return view('images-list',compact('images')); }
//想根据ID倒序,(请问这样的情况需要另外新开一个controller吗)public function idsort() { $images = Image::paginate(10); $idsort = $images->sortByDesc('id'); return view('test',compact('images','idsort')); }
@forelse($images as $image) file)}}" /> {{$image->caption}}
{!! substr($image->description, 0,100) !!}
id.'/edit') }}" class="btn btn-warning pull-left">Edit {!! Form::open(['url'=>'/image/'.$image->id, 'class'=>'pull-left']) !!} {!! Form::hidden('_method', 'DELETE') !!} {!! Form::submit('Delete', ['class' => 'btn btn-danger', 'onclick'=>'return confirm(\'Are you sure?\')']) !!} {!! Form::close() !!}
@empty No images yet, add a new one?
@endforelse
Reply content:
Title.. A picture of the display page, if I want to sort according to a certain criteria, for example, according to the order of the reverse ID, then the blade.php conditional update link should be how to write ?
public function index() { $images = Image::paginate(10); return view('images-list',compact('images')); }
//想根据ID倒序,(请问这样的情况需要另外新开一个controller吗)public function idsort() { $images = Image::paginate(10); $idsort = $images->sortByDesc('id'); return view('test',compact('images','idsort')); }
!--blade.php fragment--> @forelse ($images as $image) File)}} "/> {{$image->caption}} {!! substr ($imag E->description, 0,100)!}
ID. ' /edit ')}} "class=" btn btn-warning pull-left ">edit {!! Form::open ([' url ' = '/image/'. $image->id, ' class ' = ' Pull-left '])! {!! Form::hidden (' _method ', ' DELETE ')! {!! Form::submit (' Delete ', [' class ' = ' btn btn-danger ', ' onclick ' = ' return confirm (\ ' is You sure?\ ') ')! {!! Form::close ()!!}
@empty No Images Yet, add a new one?
@endforelse
Have seen this problem many times, this is not called update, you just need to sort the query.
Eloquent ORM Documentation
$users = User::popular()->women()->orderBy('created_at')->get();