Skip to content

Commit

Permalink
refactor: fix PHP styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt authored and github-actions[bot] committed Oct 25, 2024
1 parent 8164ee8 commit 5f8ded8
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 38 deletions.
10 changes: 4 additions & 6 deletions app/Console/Commands/RemoveExpiredStrikes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Facades\Settings;
use App\Models\Mail\ModMail;
use App\Services\UserService;
use Illuminate\Console\Command;

class RemoveExpiredStrikes extends Command
{
class RemoveExpiredStrikes extends Command {
/**
* The name and signature of the console command.
*
Expand All @@ -26,8 +25,7 @@ class RemoveExpiredStrikes extends Command
/**
* Execute the console command.
*/
public function handle()
{
public function handle() {
//
$mails = ModMail::where('has_expired', 0)->where('issue_strike', 1)->where('strike_expiry', '<', now())->get();
foreach ($mails as $mail) {
Expand All @@ -39,7 +37,7 @@ public function handle()
$service = new UserService;
$service->unban($mail->user);

$this->info('Unbanned user ' . $mail->recipient->username . ' due to expired strike.');
$this->info('Unbanned user '.$mail->recipient->username.' due to expired strike.');
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Admin/ModMailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use App\Models\Mail\ModMail;
use App\Models\User\User;
use App\Services\MailService;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class ModMailController extends Controller {
/**
Expand Down Expand Up @@ -50,7 +50,7 @@ public function getMail($id) {
*/
public function getCreateMail() {
return view('admin.mail.create_mail', [
'mail' => new ModMail,
'mail' => new ModMail,
'users' => ['Select User'] + User::orderBy('id')->pluck('name', 'id')->toArray(),
]);
}
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Comments/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
use App\Facades\Settings;
use App\Models\Comment\Comment;
use App\Models\Gallery\GallerySubmission;
use App\Models\Mail\ModMail;
use App\Models\News;
use App\Models\Report\Report;
use App\Models\Sales\Sales;
use App\Models\SitePage;
use App\Models\Mail\ModMail;
use App\Models\Mail\UserMail;
use App\Models\User\User;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class Controller extends BaseController {
/**
* Creates a new controller instance.
*/
public function __construct() {}
public function __construct() {
}
}
13 changes: 6 additions & 7 deletions app/Http/Controllers/Users/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Illuminate\Http\Request;

class MailController extends Controller {

/**
* Shows the mail index.
*
Expand All @@ -24,8 +23,8 @@ public function getIndex() {

return view('home.mail.index', [
'modMail' => ModMail::where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->get(),
'inbox' => UserMail::where('recipient_id', Auth::user()->id)->orderBy('created_at', 'desc')->get(),
'outbox' => UserMail::where('sender_id', Auth::user()->id)->orderBy('created_at', 'desc')->get(),
'inbox' => UserMail::where('recipient_id', Auth::user()->id)->orderBy('created_at', 'desc')->get(),
'outbox' => UserMail::where('sender_id', Auth::user()->id)->orderBy('created_at', 'desc')->get(),
]);
}

Expand Down Expand Up @@ -86,6 +85,7 @@ public function getCreateUserMail() {
if (!config('lorekeeper.mod_mail.allow_user_mail')) {
abort(404);
}

return view('home.mail.create_user_mail', [
'mail' => new UserMail,
'users' => User::orderBy('id')->where('id', '!=', Auth::user()->id)->pluck('name', 'id')->toArray(),
Expand All @@ -94,10 +94,9 @@ public function getCreateUserMail() {

/**
* Sends mail from one user to another.
*
* @param Request $request
* @param MailService $service
*
*
* @param mixed|null $mail_id
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postCreateUserMail(Request $request, MailService $service, $mail_id = null) {
Expand Down
16 changes: 8 additions & 8 deletions app/Models/Mail/ModMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use App\Models\Model;
use App\Models\User\User;
use Illuminate\Support\Facades\Auth;
use App\Traits\Commentable;
use Illuminate\Support\Facades\Auth;

class ModMail extends Model {
use Commentable;
Expand All @@ -26,13 +26,6 @@ class ModMail extends Model {
*/
protected $table = 'mod_mails';

/**
* Whether the model contains timestamps to be saved and updated.
*
* @var string
*/
public $timestamps = true;

/**
* The attributes that should be cast to native types.
*
Expand All @@ -42,6 +35,13 @@ class ModMail extends Model {
'strike_expiry' => 'datetime',
];

/**
* Whether the model contains timestamps to be saved and updated.
*
* @var string
*/
public $timestamps = true;

/**
* Validation rules for creation.
*
Expand Down
5 changes: 2 additions & 3 deletions app/Models/Mail/UserMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Models\User\User;

class UserMail extends Model {

/**
* The attributes that are mass assignable.
*
Expand Down Expand Up @@ -65,14 +64,14 @@ public function recipient() {
* Get the parent message.
*/
public function parent() {
return $this->belongsTo(UserMail::class, 'parent_id');
return $this->belongsTo(self::class, 'parent_id');
}

/**
* Get the child messages.
*/
public function children() {
return $this->hasMany(UserMail::class, 'parent_id', 'id');
return $this->hasMany(self::class, 'parent_id', 'id');
}

/**********************************************************************************************
Expand Down
1 change: 0 additions & 1 deletion app/Services/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public function createUserMail($data, $sender) {
DB::beginTransaction();

try {

if (!config('lorekeeper.mod_mail.allow_user_mail')) {
throw new \Exception('User mail is disabled.');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Services/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public function unban($user, $staff = null) {
try {
if (!$staff) {
$staff = $user;
if (!$this->logAdminAction($staff, 'Unbanned User', 'Unbanned '.$user->displayname . ' after strike expiry.')) {
if (!$this->logAdminAction($staff, 'Unbanned User', 'Unbanned '.$user->displayname.' after strike expiry.')) {
throw new \Exception('Failed to log admin action.');
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion config/lorekeeper/mod_mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

// Unban users if their strike expires and they are below the strike limit?
'unban_on_strike_expiry' => true,
];
];
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
public function up(): void {
Schema::table('mod_mails', function (Blueprint $table) {
//
$table->timestamp('strike_expiry')->nullable()->default(null)->after('strike_count');
Expand All @@ -21,8 +19,7 @@ public function up(): void
/**
* Reverse the migrations.
*/
public function down(): void
{
public function down(): void {
Schema::table('mod_mails', function (Blueprint $table) {
//
$table->dropColumn('strike_expiry');
Expand Down

0 comments on commit 5f8ded8

Please sign in to comment.