Skip to content
Open
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
1 change: 1 addition & 0 deletions app/Console/Commands/AddUsernameField.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class AddUsernameField extends Command
{
protected $signature = 'users:fix-username';

protected $description = 'Fix users with missing username field';

public function handle()
Expand Down
6 changes: 4 additions & 2 deletions app/Console/Commands/ReadElephpants.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class ReadElephpants extends Command
{
protected $signature = 'elephpants:read';

protected $description = 'Read elePHPants in the JSON file';

public function handle(): void
Expand All @@ -21,12 +22,12 @@ public function handle(): void
foreach ($elephpants as $elephpant) {
Elephpant::query()
->updateOrCreate(
['id' => (int)$elephpant->id],
['id' => (int) $elephpant->id],
[
'name' => $elephpant->name,
'description' => $elephpant->description,
'sponsor' => $elephpant->sponsor,
'year' => (int)$elephpant->year,
'year' => (int) $elephpant->year,
'image' => $this->processImage($elephpant),
]
);
Expand All @@ -45,6 +46,7 @@ private function processImage(object $elephpant): ?string
File::makeDirectory(dirname($filePath), 0755, true, true);
$image->save($filePath);
$this->output->write('.', false);

return $imageName;
}

Expand Down
1 change: 0 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
2 changes: 1 addition & 1 deletion app/Elephpant.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;

class Elephpant extends Model
Expand Down
4 changes: 0 additions & 4 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class Handler extends ExceptionHandler

/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*/
public function report(Throwable $exception): void
{
Expand All @@ -41,7 +38,6 @@ public function report(Throwable $exception): void
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Throwable $exception)
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function __construct()
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
Expand All @@ -53,14 +52,13 @@ protected function validator(array $data)
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'country_code' => ['required', 'string', 'size:3'],
'twitter' => ['nullable', 'string', 'unique:users'],
'x_handle' => ['nullable', 'string', 'unique:users'],
]);
}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
Expand All @@ -70,7 +68,7 @@ protected function create(array $data)
'email' => $data['email'],
'password' => Hash::make($data['password']),
'country_code' => $data['country_code'],
'twitter' => $data['twitter'] ?? null,
'x_handle' => $data['x_handle'] ?? null,
]);
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/HerdController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Http\Controllers;

use App\Queries\TradingUsersQuery;
use App\Queries\ElephpantsQuery;
use App\Queries\TradingUsersQuery;
use App\User;
use Illuminate\Support\Facades\Auth;

Expand Down Expand Up @@ -43,10 +43,10 @@ private function prepareTradePossibilities($elephpants, $userElephpants)
}
}
}

return $tradePossibilites;
}


public function show(string $username, TradingUsersQuery $query)
{
$user = User::whereUsername($username)->firstOrFail();
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/StatisticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Controllers;

use App\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;

Expand Down
1 change: 0 additions & 1 deletion app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class RedirectIfAuthenticated
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace App\Http\Middleware;

use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string
* @var array<int, string>|string|null
*/
protected $proxies;

Expand All @@ -19,5 +19,10 @@ class TrustProxies extends Middleware
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}
3 changes: 2 additions & 1 deletion app/Http/Requests/ProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ public function rules()
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users')->ignore($this->user()->id)],
'password' => ['nullable', 'string', 'min:8', 'confirmed'],
'country_code' => ['required', 'string', 'size:3'],
'twitter' => ['nullable', 'string', Rule::unique('users')->ignore($this->user()->id)],
'x_handle' => ['nullable', 'string', Rule::unique('users')->ignore($this->user()->id)],
'username' => ['required', 'string', Rule::unique('users')->ignore($this->user()->id)],
'mastodon' => ['nullable', 'string', Rule::unique('users')->ignore($this->user()->id)],
'bluesky' => ['nullable', 'string', Rule::unique('users')->ignore($this->user()->id)],
];
}
}
2 changes: 2 additions & 0 deletions app/Mail/UserMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class UserMessage extends Mailable implements ShouldQueue
use Queueable, SerializesModels;

public $sender;

public $receiver;

public $message;

public function __construct(User $sender, User $receiver, string $message)
Expand Down
1 change: 0 additions & 1 deletion app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;

class AuthServiceProvider extends ServiceProvider
{
Expand Down
10 changes: 5 additions & 5 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function map()
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}

/**
Expand All @@ -66,8 +66,8 @@ protected function mapWebRoutes()
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}
12 changes: 6 additions & 6 deletions app/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class ViewServiceProvider extends ServiceProvider
public function boot()
{
View::composer(['auth.register', 'profile.edit'], function ($view) {
$countries = (new CountriesQuery())->fetchAll()->mapWithKeys(function ($country) {
$countries = (new CountriesQuery)->fetchAll()->mapWithKeys(function ($country) {
return [
$country['cca3'] => [
$country['cca3'] => collect([
'name' => $country['name']['common'],
'flag' => $country['flag']['flag-icon'],
]
]),
];
});

Expand All @@ -26,14 +26,14 @@ public function boot()

View::composer(['ranking.index', 'trade._user', 'herd.show', 'trade.index'], function ($view) {
$usersQuery = (new UsersCountryQuery)->fetchAll();
$countries = (new CountriesQuery())->fetchAll()->filter(function ($country) use ($usersQuery) {
$countries = (new CountriesQuery)->fetchAll()->filter(function ($country) use ($usersQuery) {
return in_array($country['cca3'], $usersQuery->unique('country_code')->pluck('country_code')->toArray());
})->mapWithKeys(function ($country) {
return [
$country['cca3'] => [
$country['cca3'] => collect([
'name' => $country['name']['common'],
'flag' => $country['flag']['flag-icon'],
]
]),
];
});
$view->with('countries', $countries);
Expand Down
2 changes: 1 addition & 1 deletion app/Queries/CountriesQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function flags(): Collection

private function collection(): Collection
{
return (new Countries())->all()
return (new Countries)->all()
->sortBy('name.common');
}
}
Loading