Skip to content

Commit

Permalink
styleci
Browse files Browse the repository at this point in the history
  • Loading branch information
recursivetree committed Jul 7, 2024
1 parent 8ec98f0 commit 6d74794
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 34 deletions.
3 changes: 0 additions & 3 deletions src/Events/UserRoleAdded.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

namespace Seat\Web\Events;

use Illuminate\Queue\SerializesModels;
use Seat\Web\Models\Acl\Role;

/**
* Class UserRoleAdded.
*
Expand Down
3 changes: 0 additions & 3 deletions src/Events/UserRoleRemoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

namespace Seat\Web\Events;

use Illuminate\Queue\SerializesModels;
use Seat\Web\Models\Acl\Role;

/**
* Class UserRoleRemoved.
*
Expand Down
22 changes: 11 additions & 11 deletions src/Http/Controllers/Configuration/ScheduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

namespace Seat\Web\Http\Controllers\Configuration;

use Illuminate\Support\Facades\Artisan;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
use Seat\Services\Models\Schedule;
use Seat\Web\Http\Controllers\Controller;
use Seat\Web\Http\Validation\NewSchedule;
Expand Down Expand Up @@ -97,12 +97,12 @@ public function newCharacterSchedulingRule(Request $request)
$request->validate([
'role_id' => 'required|integer',
'time' => 'required|decimal:0,2|min:1',
'timeunit' => 'required|string|in:hour,day,week'
'timeunit' => 'required|string|in:hour,day,week',
]);

$role = Role::find($request->role_id);
if($role === null) {
return redirect()->back()->with('error',trans('web::seat.role_not_found'));
return redirect()->back()->with('error', trans('web::seat.role_not_found'));
}

$rule = $role->character_scheduling_rule;
Expand All @@ -111,24 +111,24 @@ public function newCharacterSchedulingRule(Request $request)
$rule->role_id = $role->id;
}

if($request->timeunit === "hour") {
$time_modifier = 60*60;
} elseif ($request->timeunit === "day") {
$time_modifier = 60*60*24;
} elseif ($request->timeunit === "week") {
$time_modifier = 60*60*24*7;
if($request->timeunit === 'hour') {
$time_modifier = 60 * 60;
} elseif ($request->timeunit === 'day') {
$time_modifier = 60 * 60 * 24;
} elseif ($request->timeunit === 'week') {
$time_modifier = 60 * 60 * 24 * 7;
}

$rule->update_interval = $request->time * $time_modifier;
$rule->save();

return redirect()->back()->with('success',trans('web::seat.character_scheduling_rule_creation_success'));
return redirect()->back()->with('success', trans('web::seat.character_scheduling_rule_creation_success'));
}

public function deleteCharacterSchedulingRule(Request $request): \Illuminate\Http\RedirectResponse
{
$request->validate([
'role_id'=>'required|integer'
'role_id' => 'required|integer',
]);

CharacterSchedulingRule::destroy($request->role_id);
Expand Down
26 changes: 21 additions & 5 deletions src/Listeners/UpdateRefreshTokenSchedule.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

namespace Seat\Web\Listeners;

use Carbon\Carbon;
use Seat\Eveapi\Models\RefreshToken;
use Seat\Eveapi\Models\RefreshTokenSchedule;
use Seat\Web\Events\UserRoleAdded;
use Seat\Web\Events\UserRoleRemoved;
use Seat\Web\Models\Acl\Role;
use Seat\Web\Models\CharacterSchedulingRule;

class UpdateRefreshTokenSchedule
Expand All @@ -16,4 +32,4 @@ public function handle(UserRoleAdded|UserRoleRemoved $event): void
{
CharacterSchedulingRule::updateUserRefreshTokenSchedule($event->user());
}
}
}
25 changes: 22 additions & 3 deletions src/Models/CharacterSchedulingRule.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

namespace Seat\Web\Models;

use Carbon\Carbon;
Expand All @@ -12,15 +32,14 @@
* @property int $id
* @property int $role_id
* @property int update_interval
*
* @property Role $role
*/
class CharacterSchedulingRule extends ExtensibleModel
{
const DEFAULT_UPDATE_INTERVAL = 60 * 60;

public $timestamps = false;
protected $primaryKey = "role_id";
protected $primaryKey = 'role_id';
public $incrementing = false;

public function role(): \Illuminate\Database\Eloquent\Relations\BelongsTo
Expand Down Expand Up @@ -49,4 +68,4 @@ public static function updateUserRefreshTokenSchedule(User $user): void
$schedule->save();
});
}
}
}
1 change: 0 additions & 1 deletion src/Models/Squads/SquadMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
*
* @property int squad_id
* @property int user_id
*
* @property Squad squad
* @property User user
*/
Expand Down
1 change: 0 additions & 1 deletion src/Models/Squads/SquadRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
*
* @property int $role_id
* @property int $squad_id
*
* @property Role $role
* @property Squad $squad
*/
Expand Down
22 changes: 21 additions & 1 deletion src/Observers/CharacterSchedulingRuleObserver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

namespace Seat\Web\Observers;

use Seat\Web\Models\CharacterSchedulingRule;
Expand All @@ -19,4 +39,4 @@ public function deleted(CharacterSchedulingRule $rule)
CharacterSchedulingRule::updateUserRefreshTokenSchedule($affected_user);
}
}
}
}
4 changes: 2 additions & 2 deletions src/WebServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ private function add_events()
// Custom Events
$this->app->events->listen('security.log', SecLog::class);

Event::listen(UserRoleAdded::class,UpdateRefreshTokenSchedule::class);
Event::listen(UserRoleRemoved::class,UpdateRefreshTokenSchedule::class);
Event::listen(UserRoleAdded::class, UpdateRefreshTokenSchedule::class);
Event::listen(UserRoleRemoved::class, UpdateRefreshTokenSchedule::class);

// Characters / Corporations first auth - Jobs Events
CharacterRole::observe(CharacterRoleObserver::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function up()
});
}


/**
* Reverse the migrations.
*
Expand Down
6 changes: 3 additions & 3 deletions src/resources/lang/en/seat.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@
'esi_character_scheduling_rules' => 'Character Scheduling Rule|Character Scheduling Rules',
'new_esi_character_scheduling_rules' => 'Add Character Scheduling Rules',
'update_interval' => 'Update Interval',
'character_scheduling_rules_default'=>'When no rules apply to a character, an update interval of one hour is used.',
'character_scheduling_rules_empty'=>'no character scheduling rules defined, using a default of one hour for everyone',
'character_scheduling_rules_default' => 'When no rules apply to a character, an update interval of one hour is used.',
'character_scheduling_rules_empty' => 'no character scheduling rules defined, using a default of one hour for everyone',
'character_scheduling_rule_deleted' => 'Successfully deleted character scheduling rule!',
'character_scheduling_rules_interval_input_label' => 'Update Interval',
'add_character_scheduling_rule' => 'Add Scheduling Rule',
'role_not_found' => 'The selected roles doesn\'t exist. Please reload the page and try again.',
'character_scheduling_rule_creation_success'=>'Successfully created new scheduling rule!',
'character_scheduling_rule_creation_success' => 'Successfully created new scheduling rule!',

// Security
'category' => 'Category',
Expand Down

0 comments on commit 6d74794

Please sign in to comment.