src/: Formatting, doc block hints and cleanup

This commit is contained in:
Igor Scheller 2019-11-06 13:43:57 +01:00
parent 2cce967eb0
commit 8b5b9e2c65
13 changed files with 107 additions and 83 deletions

View File

@ -43,6 +43,7 @@ class Stats
->distinct();
$query->where(function ($query) use ($working) {
/** @var QueryBuilder $query */
if ($working) {
$query
->whereNotNull('ShiftEntry.SID')
@ -271,7 +272,7 @@ class Stats
{
$start = microtime(true);
EventConfig::findOrNew('last_metrics');
(new EventConfig())->findOrNew('last_metrics');
return microtime(true) - $start;
}
@ -281,7 +282,7 @@ class Stats
*/
public function databaseWrite()
{
$config = EventConfig::findOrNew('last_metrics');
$config = (new EventConfig())->findOrNew('last_metrics');
$config
->setAttribute('name', 'last_metrics')
->setAttribute('value', new Carbon());

View File

@ -74,7 +74,7 @@ class PasswordResetController extends BaseController
/** @var User $user */
$user = User::whereEmail($data['email'])->first();
if ($user) {
$reset = PasswordReset::findOrNew($user->id);
$reset = (new PasswordReset)->findOrNew($user->id);
$reset->user_id = $user->id;
$reset->token = md5(random_bytes(64));
$reset->save();

View File

@ -219,6 +219,8 @@ class LegacyMiddleware implements MiddlewareInterface
}
redirect(page_link_to('login'));
return [];
}
/**

View File

@ -3,17 +3,18 @@
namespace Engelsystem\Models;
use Carbon\Carbon;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property string $name
* @property string $value
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $name
* @property string $value
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\EventConfig[] whereName($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\EventConfig[] whereValue($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\EventConfig[] whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\EventConfig[] whereUpdatedAt($value)
* @method static QueryBuilder|EventConfig[] whereName($value)
* @method static QueryBuilder|EventConfig[] whereValue($value)
* @method static QueryBuilder|EventConfig[] whereCreatedAt($value)
* @method static QueryBuilder|EventConfig[] whereUpdatedAt($value)
*/
class EventConfig extends BaseModel
{

View File

@ -2,19 +2,21 @@
namespace Engelsystem\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property int $id
* @property string $level
* @property string $message
* @property \Carbon\Carbon|null $created_at
* @property int $id
* @property string $level
* @property string $message
* @property Carbon|null $created_at
*
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\LogEntry[] whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\LogEntry[] whereLevel($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\LogEntry[] whereMessage($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\LogEntry[] whereCreatedAt($value)
* @method static QueryBuilder|LogEntry[] whereId($value)
* @method static QueryBuilder|LogEntry[] whereLevel($value)
* @method static QueryBuilder|LogEntry[] whereMessage($value)
* @method static QueryBuilder|LogEntry[] whereCreatedAt($value)
*/
class LogEntry extends BaseModel
{

View File

@ -2,14 +2,16 @@
namespace Engelsystem\Models\User;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property string|null $dect
* @property string|null $email
* @property string|null $mobile
*
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Contact[] whereDect($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Contact[] whereEmail($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Contact[] whereMobile($value)
* @method static QueryBuilder|Contact[] whereDect($value)
* @method static QueryBuilder|Contact[] whereEmail($value)
* @method static QueryBuilder|Contact[] whereMobile($value)
*/
class Contact extends HasUserModel
{

View File

@ -2,12 +2,15 @@
namespace Engelsystem\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property string $token
* @property \Carbon\Carbon|null $created_at
* @property string $token
* @property Carbon|null $created_at
*
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PasswordReset[] whereToken($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PasswordReset[] whereCreatedAt($value)
* @method static QueryBuilder|PasswordReset[] whereToken($value)
* @method static QueryBuilder|PasswordReset[] whereCreatedAt($value)
*/
class PasswordReset extends HasUserModel
{

View File

@ -2,18 +2,21 @@
namespace Engelsystem\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property string|null $first_name
* @property string|null $last_name
* @property string|null $shirt_size
* @property \Carbon\Carbon|null $planned_arrival_date
* @property \Carbon\Carbon|null $planned_departure_date
* @property string|null $first_name
* @property string|null $last_name
* @property string|null $shirt_size
* @property Carbon|null $planned_arrival_date
* @property Carbon|null $planned_departure_date
*
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData[] whereFirstName($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData[] whereLastName($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData[] whereShirtSize($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData[] wherePlannedArrivalDate($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData[] wherePlannedDepartureDate($value)
* @method static QueryBuilder|PersonalData[] whereFirstName($value)
* @method static QueryBuilder|PersonalData[] whereLastName($value)
* @method static QueryBuilder|PersonalData[] whereShirtSize($value)
* @method static QueryBuilder|PersonalData[] wherePlannedArrivalDate($value)
* @method static QueryBuilder|PersonalData[] wherePlannedDepartureDate($value)
*/
class PersonalData extends HasUserModel
{

View File

@ -2,16 +2,18 @@
namespace Engelsystem\Models\User;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property string $language
* @property int $theme
* @property bool $email_human
* @property bool $email_shiftinfo
*
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Settings[] whereLanguage($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Settings[] whereTheme($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Settings[] whereEmailHuman($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Settings[] whereEmailShiftinfo($value)
* @method static QueryBuilder|Settings[] whereLanguage($value)
* @method static QueryBuilder|Settings[] whereTheme($value)
* @method static QueryBuilder|Settings[] whereEmailHuman($value)
* @method static QueryBuilder|Settings[] whereEmailShiftinfo($value)
*/
class Settings extends HasUserModel
{

View File

@ -2,20 +2,23 @@
namespace Engelsystem\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property bool $arrived
* @property \Carbon\Carbon|null $arrival_date
* @property bool $active
* @property bool $force_active
* @property bool $got_shirt
* @property int $got_voucher
* @property bool $arrived
* @property Carbon|null $arrival_date
* @property bool $active
* @property bool $force_active
* @property bool $got_shirt
* @property int $got_voucher
*
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereArrived($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereArrivalDate($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereActive($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereForceActive($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereGotShirt($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereGotVoucher($value)
* @method static QueryBuilder|State[] whereArrived($value)
* @method static QueryBuilder|State[] whereArrivalDate($value)
* @method static QueryBuilder|State[] whereActive($value)
* @method static QueryBuilder|State[] whereForceActive($value)
* @method static QueryBuilder|State[] whereGotShirt($value)
* @method static QueryBuilder|State[] whereGotVoucher($value)
*/
class State extends HasUserModel
{

View File

@ -2,32 +2,34 @@
namespace Engelsystem\Models\User;
use Carbon\Carbon;
use Engelsystem\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property integer $id
* @property string $name
* @property string $email
* @property string $password
* @property string $api_key
* @property \Carbon\Carbon|null $last_login_at
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property integer $id
* @property string $name
* @property string $email
* @property string $password
* @property string $api_key
* @property Carbon|null $last_login_at
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property-read \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Contact $contact
* @property-read \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData $personalData
* @property-read \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\Settings $settings
* @property-read \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State $state
* @property-read QueryBuilder|Contact $contact
* @property-read QueryBuilder|PersonalData $personalData
* @property-read QueryBuilder|Settings $settings
* @property-read QueryBuilder|State $state
*
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User[] whereName($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User[] whereEmail($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User[] wherePassword($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User[] whereApiKey($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User[] whereLastLoginAt($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User[] whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User[] whereUpdatedAt($value)
* @method static QueryBuilder|User whereId($value)
* @method static QueryBuilder|User[] whereName($value)
* @method static QueryBuilder|User[] whereEmail($value)
* @method static QueryBuilder|User[] wherePassword($value)
* @method static QueryBuilder|User[] whereApiKey($value)
* @method static QueryBuilder|User[] whereLastLoginAt($value)
* @method static QueryBuilder|User[] whereCreatedAt($value)
* @method static QueryBuilder|User[] whereUpdatedAt($value)
*/
class User extends BaseModel
{

View File

@ -3,13 +3,14 @@
namespace Engelsystem\Models\User;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* @property integer $user_id
* @property integer $user_id
*
* @property-read \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User $user
* @property-read QueryBuilder|User $user
*
* @method static \Illuminate\Database\Query\Builder|static whereUserId($value)
* @method static QueryBuilder|static whereUserId($value)
*/
trait UsesUserModel
{

View File

@ -52,6 +52,7 @@ function base_path($path = '')
*/
function config($key = null, $default = null)
{
/** @var Config $config */
$config = app('config');
if (empty($key)) {
@ -119,6 +120,7 @@ function response($content = '', $status = 200, $headers = [])
*/
function session($key = null, $default = null)
{
/** @var SessionInterface $session */
$session = app('session');
if (is_null($key)) {
@ -131,8 +133,8 @@ function session($key = null, $default = null)
/**
* Translate the given message
*
* @param string $key
* @param array $replace
* @param string $key
* @param array $replace
* @return string|Translator
*/
function trans($key = null, $replace = [])
@ -150,8 +152,8 @@ function trans($key = null, $replace = [])
/**
* Translate the given message
*
* @param string $key
* @param array $replace
* @param string $key
* @param array $replace
* @return string
*/
function __($key, $replace = [])
@ -165,10 +167,10 @@ function __($key, $replace = [])
/**
* Translate the given message
*
* @param string $key
* @param string $keyPlural
* @param int $number
* @param array $replace
* @param string $key
* @param string $keyPlural
* @param int $number
* @param array $replace
* @return string
*/
function _e($key, $keyPlural, $number, $replace = [])