php - Count total entries and make a number list in Laravel -
i'm trying make sort project i'm doing, , want total of entries of database , make select total of entries ordered 1 25 let's say..
my controller looks this:
$users = user::orderby('sort', 'desc')->paginate(10); return view('admin.user.index', compact('users'));
my view looks this:
<select class="form-control" id="sort" name="sort"> @foreach($users $user) <option value="0">0</option> @endforeach </select>
let's have 25 users. want 25 options 1 25 in value, since can't use item id.. because can deleted.
you can try as:
<select class="form-control" id="sort" name="sort"> @foreach($users $key => $user) <option value="{{ $key + 1 }}"> {{ $key + 1 }} </option> @endforeach </select>
Comments
Post a Comment