added date class
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use App\Utilities\Date;
|
||||
use Illuminate\Support\Str;
|
||||
use Jenssegers\Date\Date;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace App\Abstracts;
|
||||
|
||||
use App\Traits\Import as ImportHelper;
|
||||
use App\Utilities\Date;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Jenssegers\Date\Date;
|
||||
use Maatwebsite\Excel\Concerns\Importable;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\SkipsOnError;
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\Abstracts;
|
||||
|
||||
use App\Traits\Charts;
|
||||
use Date;
|
||||
use App\Utilities\Date;
|
||||
|
||||
abstract class Widget
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Listeners\Auth;
|
||||
|
||||
use Date;
|
||||
use App\Utilities\Date;
|
||||
use Illuminate\Auth\Events\Login as ILogin;
|
||||
|
||||
class Login
|
||||
@ -18,13 +18,13 @@ class Login
|
||||
{
|
||||
// Get first company
|
||||
$company = $event->user->companies()->enabled()->first();
|
||||
|
||||
|
||||
// Logout if no company assigned
|
||||
if (!$company) {
|
||||
app('App\Http\Controllers\Auth\Login')->logout();
|
||||
|
||||
|
||||
flash(trans('auth.error.no_company'))->error();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
60
app/Utilities/Date.php
Normal file
60
app/Utilities/Date.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Date extends Carbon
|
||||
{
|
||||
/**
|
||||
* Function to call instead of format.
|
||||
*
|
||||
* @var string|callable|null
|
||||
*/
|
||||
protected static $formatFunction = 'translatedFormat';
|
||||
|
||||
/**
|
||||
* Function to call instead of createFromFormat.
|
||||
*
|
||||
* @var string|callable|null
|
||||
*/
|
||||
protected static $createFromFormatFunction = 'createFromFormatWithCurrentLocale';
|
||||
|
||||
/**
|
||||
* Function to call instead of parse.
|
||||
*
|
||||
* @var string|callable|null
|
||||
*/
|
||||
protected static $parseFunction = 'parseWithCurrentLocale';
|
||||
|
||||
public static function parseWithCurrentLocale($time = null, $timezone = null)
|
||||
{
|
||||
if (is_string($time)) {
|
||||
$time = static::translateTimeString($time, static::getLocale(), 'en');
|
||||
}
|
||||
|
||||
return parent::rawParse($time, $timezone);
|
||||
}
|
||||
|
||||
public static function createFromFormatWithCurrentLocale($format, $time = null, $timezone = null)
|
||||
{
|
||||
if (is_string($time)) {
|
||||
$time = static::translateTimeString($time, static::getLocale(), 'en');
|
||||
}
|
||||
|
||||
return parent::rawCreateFromFormat($format, $time, $timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the language portion of the locale.
|
||||
*
|
||||
* @param string $locale
|
||||
* @return string
|
||||
*/
|
||||
public static function getLanguageFromLocale($locale)
|
||||
{
|
||||
$parts = explode('_', str_replace('-', '_', $locale));
|
||||
|
||||
return $parts[0];
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Traits\DateTime;
|
||||
use App\Utilities\Date;
|
||||
use App\Utilities\Widgets;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
if (!function_exists('user')) {
|
||||
/**
|
||||
|
Reference in New Issue
Block a user