# Views
# Paginate
# Return to same page after Delete
// Controller
public function destroy(Request $request, User $user)
{
$user->delete();
$paginator = User::paginate(columns: ['id']);
$redirectToPage = ($request->page <= $paginator->lastPage())
? $request->page
: $paginator->lastPage();
return redirect()->route('users.index', ['page' => $redirectToPage]);
}
// view
<input type="hidden" name="page" value="{{ $users->currentPage() }}">
# Views
{{ $products->links() }}
{{ $products->links('pagination::bootstrap-4') }}
# @selected
<select class="form-select @error('category_id') is-invalid @enderror" name="category_id" id="category_id">
<option selected disabled>
Select
</option>
@foreach ($categories as $key => $value)
<option value="{{ $key }}" @selected( old('category_id', $budget->category_id) == $key)>
{{ $value }}
</option>
@endforeach
</select>
<label for="category_id">category</label>
# @checked
// Before Laravel 9:
<input type="radio" name="active" value="1" {{ old('active', $user->active) ? 'checked' : '' }}/>
<input type="radio" name="active" value="0" {{ old('active', $user->active) ? '' : 'checked' }}/>
// Laravel 9
<input type="radio" name="active" value="1" @checked(old('active', $user->active))/>
<input type="radio" name="active" value="0" @checked(!old('active', $user->active))/>
# @disabled
@disabled($task->is_completed)
<button type="submit" @disabled($errors->isNotEmpty())>Submit</button>
# Textarea
<textarea class="form-control @error('notes') is-invalid @enderror"
id="notes"
name="notes"
style="height: 100px"
placeholder="Leave a note here"
>{{ old('notes', $budget->notes) }}</textarea>
<label for="notes">Notes</label>
← Routes Directives →