Skip to content

Commit

Permalink
Merge pull request #293 from P3D-Legacy/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbilling authored Dec 10, 2023
2 parents 6d07172 + 5b1270d commit 90b1768
Show file tree
Hide file tree
Showing 173 changed files with 3,575 additions and 3,167 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1']
php-versions: ['8.2']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions app/Helpers/XenForoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public static function sendRequest($endpoint, $data = [], $method = self::METHOD
'XF-Api-Key' => config('services.xenforo.api_key'),
])->$method($url, $data);

if ($response->failed()) {
return ['errors' => []];
}

return json_decode($response, true);
}

Expand Down
12 changes: 6 additions & 6 deletions app/Http/Controllers/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
namespace App\Http\Controllers;

use App\Models\Post;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;

class BlogController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
* @return Application|Factory|View
*/
public function index()
{
$posts = Post::where('published_at', '<=', now())
->where('active', true)
->orderBy('sticky', 'desc')
->orderByDesc('published_at')
->paginate(5);
->paginate(9);

return view('blog.index', ['posts' => $posts]);
}

/**
* Display the specified resource.
*
* @param \App\Models\Post $post
* @return \Illuminate\Http\Response
*/
public function show($param)
public function show($param): Application|Factory|View
{
$post = Post::where('uuid', $param)
->where('active', true)
Expand Down
32 changes: 10 additions & 22 deletions app/Http/Controllers/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,34 @@
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class ServerController extends Controller
{

public function __construct()
{
$this->middleware(['auth', 'verified'])->only(['edit', 'update', 'destroy']);
}

/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
public function index(): View|Factory|Application
{
return view('server.index');
}

/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
public function create(): View|Factory|Application
{
return view('server.create');
}

/**
* Store a newly created resource in storage.
*
* @return Response
* @return void
*/
public function store(Request $request)
{
Expand All @@ -50,21 +44,17 @@ public function store(Request $request)
/**
* Display the specified resource.
*
* @param int $id
* @return Response
* @return void
*/
public function show($id)
public function show(int $id)
{
//return redirect()->route('server.index');
}

/**
* Show the form for editing the specified resource.
*
* @param Server $server
* @return Application|Factory|View
*/
public function edit(Server $server)
public function edit(Server $server): View|Factory|Application
{
abort_if(! $server->user_id == auth()->user()->id, 403);

Expand All @@ -74,21 +64,19 @@ public function edit(Server $server)
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
* @return void
*/
public function update(Request $request, $id)
public function update(Request $request, int $id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
* @return void
*/
public function destroy($id)
public function destroy(int $id)
{
//
}
Expand Down
20 changes: 12 additions & 8 deletions app/Http/Livewire/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

use App\Models\User;
use Auth;
use Illuminate\Notifications\DatabaseNotificationCollection;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\RedirectResponse;
use Livewire\Component;

class Notifications extends Component
{
public DatabaseNotificationCollection $unreadNotifications;
public Collection $unreadNotifications;

public User $user;

Expand All @@ -21,40 +25,40 @@ class Notifications extends Component
'notificationsUpdated' => 'update',
];

public function mount()
public function mount(): void
{
$this->user = Auth::user();
$this->unreadNotifications = $this->user->unreadNotifications->take($this->max);
$this->count = $this->user->unreadNotifications->count();
}

public function update()
public function update(): void
{
$this->unreadNotifications = $this->user->unreadNotifications->take($this->max);
$this->count = $this->user->unreadNotifications->count();
}

public function open($id)
public function open($id): RedirectResponse
{
$notification = $this->user->notifications->find($id);
$this->dismiss($id);

return redirect()->to($notification->data['url']);
}

public function dismiss($id)
public function dismiss($id): void
{
$this->user->notifications->find($id)->markAsRead();
$this->emit('notificationsUpdated');
}

public function dismissAll()
public function dismissAll(): void
{
$this->user->unreadNotifications->markAsRead();
$this->emit('notificationsUpdated');
}

public function render()
public function render(): Factory|View|Application
{
return view('livewire.notifications');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Resource/RatingCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function mount(int|Resource $resource)
}
$this->resource = $resource;
$this->user = auth()->user();
if(!$this->user) {
if (! $this->user) {
$this->closeModal();
}
if ($this->user == $this->resource->user) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Resource/ResourceForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ResourceForm extends ModalComponent
'category' => 'required|exists:categories,id',
];

public function mount(int|Resource $resource = null)
public function mount(int|Resource|null $resource = null)
{
$this->resource = $resource ? Resource::find($resource) : new Resource();
$this->category = $this->resource->categories->first()->id ?? 0;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Resource/UpdateShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function mount(int|ResourceUpdate $update)
public function download()
{
$mediaItem = $this->update->getFirstMedia('resource_update_file');
if (!$mediaItem) {
if (! $mediaItem) {
session()->flash('flash.banner', trans('File not found on server!'));
session()->flash('flash.bannerStyle', 'danger');

Expand Down
11 changes: 10 additions & 1 deletion app/Http/Livewire/Server/ServerEditForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ public function save()
'description' => ['nullable', 'string'],
]);

Server::find($this->server->uuid)->update([
$server = Server::find($this->server->uuid);

if (! $server) {
session()->flash('flash.banner', trans('Server not found.'));
session()->flash('flash.bannerStyle', 'danger');

return redirect()->route('server.index');
}

$server->update([
'name' => $this->name,
'host' => $this->host,
'port' => $this->port,
Expand Down
29 changes: 29 additions & 0 deletions app/Http/Middleware/CustomRestrictedDocsAccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;

class CustomRestrictedDocsAccess
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
if (app()->environment(['local', 'staging'])) {
return $next($request);
}

if (Gate::allows('viewApiDocs')) {
return $next($request);
}

abort(403);
}
}
2 changes: 1 addition & 1 deletion app/Models/BanReason.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class BanReason extends BaseModel
{
use HasFactory;
use SoftDeletes;
use LogsActivity;
use SoftDeletes;

protected $primaryKey = 'id';

Expand Down
2 changes: 1 addition & 1 deletion app/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class Comment extends \AliBayat\LaravelCommentable\Comment
{
use LogsActivity;
use Likeable;
use LogsActivity;

/**
* The attributes that should be logged for the user.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/DiscordAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class DiscordAccount extends BaseModel
{
use HasFactory;
use SoftDeletes;
use LogsActivity;
use SoftDeletes;

public static function boot()
{
Expand Down
2 changes: 1 addition & 1 deletion app/Models/FacebookAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class FacebookAccount extends BaseModel
{
use HasFactory;
use SoftDeletes;
use LogsActivity;
use SoftDeletes;

public static function boot()
{
Expand Down
4 changes: 2 additions & 2 deletions app/Models/ForumAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

class ForumAccount extends BaseModel
{
use HasFactory;
use EncryptableDbAttribute;
use SoftDeletes;
use HasFactory;
use LogsActivity;
use SoftDeletes;

public static function boot()
{
Expand Down
4 changes: 2 additions & 2 deletions app/Models/GJUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
class GJUser extends BaseModel
{
use HasFactory;
use SoftDeletes;
use LogsActivity;
use Liker;
use LogsActivity;
use SoftDeletes;

/**
* The table associated with the model.
Expand Down
4 changes: 2 additions & 2 deletions app/Models/GamejoltAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

class GamejoltAccount extends BaseModel
{
use HasFactory;
use EncryptableDbAttribute;
use SoftDeletes;
use HasFactory;
use LogsActivity;
use SoftDeletes;

protected $primaryKey = 'aid';

Expand Down
2 changes: 1 addition & 1 deletion app/Models/GamejoltAccountBan.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class GamejoltAccountBan extends BaseModel
{
use HasFactory;
use SoftDeletes;
use LogsActivity;
use SoftDeletes;

public static function boot()
{
Expand Down
Loading

0 comments on commit 90b1768

Please sign in to comment.