Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Update) Prefer foreach array iterator over variable #3973

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions resources/views/Staff/forum/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,51 +113,51 @@ class="form__label form__label--floating"
</tr>
</thead>
<tbody>
@foreach ($groups as $group)
@foreach ($groups as $i => $group)
<tr>
<th x-bind="rowHeader">
{{ $group->name }}
<input
type="hidden"
name="permissions[{{ $loop->index }}][group_id]"
name="permissions[{{ $i }}][group_id]"
value="{{ $group->id }}"
/>
</th>
<td>
<input
type="hidden"
name="permissions[{{ $loop->index }}][read_topic]"
name="permissions[{{ $i }}][read_topic]"
value="0"
/>
<input
type="checkbox"
name="permissions[{{ $loop->index }}][read_topic]"
name="permissions[{{ $i }}][read_topic]"
value="1"
checked
/>
</td>
<td>
<input
type="hidden"
name="permissions[{{ $loop->index }}][start_topic]"
name="permissions[{{ $i }}][start_topic]"
value="0"
/>
<input
type="checkbox"
name="permissions[{{ $loop->index }}][start_topic]"
name="permissions[{{ $i }}][start_topic]"
value="1"
checked
/>
</td>
<td>
<input
type="hidden"
name="permissions[{{ $loop->index }}][reply_topic]"
name="permissions[{{ $i }}][reply_topic]"
value="0"
/>
<input
type="checkbox"
name="permissions[{{ $loop->index }}][reply_topic]"
name="permissions[{{ $i }}][reply_topic]"
value="1"
checked
/>
Expand Down
18 changes: 9 additions & 9 deletions resources/views/Staff/forum/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class="form__text"
class="form__textarea"
required
>
{{ $forum->description }}</textarea
{{ $forum->description }}</textarea
>
<label class="form__label form__label--floating" for="description">
Description
Expand Down Expand Up @@ -153,51 +153,51 @@ class="form__label form__label--floating"
</tr>
</thead>
<tbody x-ref="tbody">
@foreach ($groups as $group)
@foreach ($groups as $i => $group)
<tr>
<th x-bind="rowHeader">
{{ $group->name }}
<input
type="hidden"
name="permissions[{{ $loop->index }}][group_id]"
name="permissions[{{ $i }}][group_id]"
value="{{ $group->id }}"
/>
</th>
<td>
<input
type="hidden"
name="permissions[{{ $loop->index }}][read_topic]"
name="permissions[{{ $i }}][read_topic]"
value="0"
/>
<input
type="checkbox"
name="permissions[{{ $loop->index }}][read_topic]"
name="permissions[{{ $i }}][read_topic]"
value="1"
@checked($forum->permissions->where('group_id', '=', $group->id)->first()?->read_topic)
/>
</td>
<td>
<input
type="hidden"
name="permissions[{{ $loop->index }}][start_topic]"
name="permissions[{{ $i }}][start_topic]"
value="0"
/>
<input
type="checkbox"
name="permissions[{{ $loop->index }}][start_topic]"
name="permissions[{{ $i }}][start_topic]"
value="1"
@checked($forum->permissions->where('group_id', '=', $group->id)->first()?->start_topic)
/>
</td>
<td>
<input
type="hidden"
name="permissions[{{ $loop->index }}][reply_topic]"
name="permissions[{{ $i }}][reply_topic]"
value="0"
/>
<input
type="checkbox"
name="permissions[{{ $loop->index }}][reply_topic]"
name="permissions[{{ $i }}][reply_topic]"
value="1"
@checked($forum->permissions->where('group_id', '=', $group->id)->first()?->reply_topic)
/>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/Staff/poll/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
<h2 class="panel__heading">{{ __('poll.results') }}: {{ $poll->title }}</h2>
<div class="panel__body">
@php($total = $poll->options->sum('votes'))
@foreach ($poll->options as $option)
@foreach ($poll->options as $i => $option)
<p class="form__group">
<label class="form__label" for="option{{ $loop->iteration }}">
<label class="form__label" for="option{{ $i + 1 }}">
{{ $option->name }}
({{ \number_format($total === 0 ? 0 : (100 * $option->votes) / $total, 2) }}%)
</label>
<meter
id="option{{ $loop->iteration }}"
id="option{{ $i + 1 }}"
class="form__meter"
min="0"
max="{{ $total }}"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/Staff/seedbox/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<tbody>
@forelse ($seedboxes as $seedbox)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $seedbox->id }}</td>
<td>
<x-user_tag :anon="false" :user="$seedbox->user" />
</td>
Expand Down
7 changes: 2 additions & 5 deletions resources/views/livewire/laravel-log-viewer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,8 @@ class="form__button form__button--text"
wire:model.live="logs"
style="height: 320px; padding: 8px; border-radius: 4px; width: 100%"
>
@foreach ($files as $file)
<option
value="{{ $loop->index }}"
style="padding: 6px; border-radius: 4px; cursor: pointer"
>
@foreach ($files as $i => $file)
<option value="{{ $i }}" style="padding: 6px; border-radius: 4px; cursor: pointer">
{{ $file->getFilename() }}
</option>
@endforeach
Expand Down
12 changes: 6 additions & 6 deletions resources/views/livewire/random-media.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
</header>
<div class="panel__body" style="padding: 0">
<div class="random__media">
@foreach ($movies as $key => $movie)
@foreach ($movies as $i => $movie)
<a
target="_blank"
href="{{ route('torrents.similar', ['category_id' => 1, 'tmdb' => $movie->id]) }}"
class="@if ($loop->iteration == 1) media @elseif ($loop->iteration == 2)media1 @else media2 @endif"
class="@if ($i === 0) media @elseif ($i === 1)media1 @else media2 @endif"
style="
background-image: url('{{ \tmdb_image('back_small', $movie->backdrop) }}');
background-repeat: no-repeat;
Expand All @@ -34,11 +34,11 @@ class="@if ($loop->iteration == 1) media @elseif ($loop->iteration == 2)media1 @
</a>
@endforeach

@foreach ($tvs as $key => $tv)
@foreach ($tvs as $i => $tv)
<a
target="_blank"
href="{{ route('torrents.similar', ['category_id' => 2, 'tmdb' => $tv->id]) }}"
class="@if ($loop->iteration == 1) media3 @elseif ($loop->iteration == 2) media4 @else media5 @endif"
class="@if ($i === 0) media3 @elseif ($i === 1) media4 @else media5 @endif"
style="
background-image: url('{{ \tmdb_image('back_small', $tv->backdrop) }}');
background-repeat: no-repeat;
Expand All @@ -53,11 +53,11 @@ class="@if ($loop->iteration == 1) media3 @elseif ($loop->iteration == 2) media4
</a>
@endforeach

@foreach ($movies2 as $key => $movie)
@foreach ($movies2 as $i => $movie)
<a
target="_blank"
href="{{ route('torrents.similar', ['category_id' => 1, 'tmdb' => $movie->id]) }}"
class="@if ($loop->iteration == 1) media6 @elseif ($loop->iteration == 2) media7 @else media8 @endif"
class="@if ($i === 0) media6 @elseif ($i === 1) media7 @else media8 @endif"
style="
background-image: url('{{ \tmdb_image('back_small', $movie->backdrop) }}');
background-repeat: no-repeat;
Expand Down
Loading
Loading