added date class

This commit is contained in:
denisdulici
2020-03-25 20:21:42 +03:00
parent ee6041ecd1
commit 201a3696a4
13 changed files with 75 additions and 15 deletions

View File

@ -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;

View File

@ -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;

View File

@ -3,7 +3,7 @@
namespace App\Abstracts;
use App\Traits\Charts;
use Date;
use App\Utilities\Date;
abstract class Widget
{

View File

@ -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
View 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];
}
}

View File

@ -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')) {
/**