added date class
This commit is contained in:
parent
ee6041ecd1
commit
201a3696a4
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Abstracts;
|
namespace App\Abstracts;
|
||||||
|
|
||||||
|
use App\Utilities\Date;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
namespace App\Abstracts;
|
namespace App\Abstracts;
|
||||||
|
|
||||||
use App\Traits\Import as ImportHelper;
|
use App\Traits\Import as ImportHelper;
|
||||||
|
use App\Utilities\Date;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
use Maatwebsite\Excel\Concerns\Importable;
|
use Maatwebsite\Excel\Concerns\Importable;
|
||||||
use Maatwebsite\Excel\Concerns\ToModel;
|
use Maatwebsite\Excel\Concerns\ToModel;
|
||||||
use Maatwebsite\Excel\Concerns\SkipsOnError;
|
use Maatwebsite\Excel\Concerns\SkipsOnError;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace App\Abstracts;
|
namespace App\Abstracts;
|
||||||
|
|
||||||
use App\Traits\Charts;
|
use App\Traits\Charts;
|
||||||
use Date;
|
use App\Utilities\Date;
|
||||||
|
|
||||||
abstract class Widget
|
abstract class Widget
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Listeners\Auth;
|
namespace App\Listeners\Auth;
|
||||||
|
|
||||||
use Date;
|
use App\Utilities\Date;
|
||||||
use Illuminate\Auth\Events\Login as ILogin;
|
use Illuminate\Auth\Events\Login as ILogin;
|
||||||
|
|
||||||
class Login
|
class Login
|
||||||
@ -18,13 +18,13 @@ class Login
|
|||||||
{
|
{
|
||||||
// Get first company
|
// Get first company
|
||||||
$company = $event->user->companies()->enabled()->first();
|
$company = $event->user->companies()->enabled()->first();
|
||||||
|
|
||||||
// Logout if no company assigned
|
// Logout if no company assigned
|
||||||
if (!$company) {
|
if (!$company) {
|
||||||
app('App\Http\Controllers\Auth\Login')->logout();
|
app('App\Http\Controllers\Auth\Login')->logout();
|
||||||
|
|
||||||
flash(trans('auth.error.no_company'))->error();
|
flash(trans('auth.error.no_company'))->error();
|
||||||
|
|
||||||
return;
|
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
|
<?php
|
||||||
|
|
||||||
use App\Traits\DateTime;
|
use App\Traits\DateTime;
|
||||||
|
use App\Utilities\Date;
|
||||||
use App\Utilities\Widgets;
|
use App\Utilities\Widgets;
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
|
|
||||||
if (!function_exists('user')) {
|
if (!function_exists('user')) {
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
"graham-campbell/markdown": "12.0.*",
|
"graham-campbell/markdown": "12.0.*",
|
||||||
"guzzlehttp/guzzle": "^6.5",
|
"guzzlehttp/guzzle": "^6.5",
|
||||||
"intervention/image": "2.5.*",
|
"intervention/image": "2.5.*",
|
||||||
"jenssegers/date": "4.0.0-beta",
|
|
||||||
"kyslik/column-sortable": "^6.0",
|
"kyslik/column-sortable": "^6.0",
|
||||||
"laracasts/flash": "3.1.*",
|
"laracasts/flash": "3.1.*",
|
||||||
"laravel/framework": "^7.0",
|
"laravel/framework": "^7.0",
|
||||||
|
@ -206,6 +206,7 @@ return [
|
|||||||
'Config' => Illuminate\Support\Facades\Config::class,
|
'Config' => Illuminate\Support\Facades\Config::class,
|
||||||
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
||||||
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||||
|
'Date' => App\Utilities\Date::class,
|
||||||
'DB' => Illuminate\Support\Facades\DB::class,
|
'DB' => Illuminate\Support\Facades\DB::class,
|
||||||
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||||
'Event' => Illuminate\Support\Facades\Event::class,
|
'Event' => Illuminate\Support\Facades\Event::class,
|
||||||
|
@ -51,7 +51,7 @@ return [
|
|||||||
| This option the language of jenssegers/date library.
|
| This option the language of jenssegers/date library.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
'date' => true,
|
'date' => false,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -8,9 +8,9 @@ use App\Models\Auth\User;
|
|||||||
use App\Models\Common\Contact;
|
use App\Models\Common\Contact;
|
||||||
use App\Models\Common\Item;
|
use App\Models\Common\Item;
|
||||||
use App\Models\Purchase\Bill;
|
use App\Models\Purchase\Bill;
|
||||||
use Faker\Generator as Faker;
|
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
use App\Models\Setting\Tax;
|
use App\Models\Setting\Tax;
|
||||||
|
use App\Utilities\Date;
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$user = User::first();
|
$user = User::first();
|
||||||
$company = $user->companies()->first();
|
$company = $user->companies()->first();
|
||||||
|
@ -10,8 +10,8 @@ use App\Models\Common\Contact;
|
|||||||
use App\Models\Common\Item;
|
use App\Models\Common\Item;
|
||||||
use App\Models\Sale\Invoice;
|
use App\Models\Sale\Invoice;
|
||||||
use App\Models\Setting\Tax;
|
use App\Models\Setting\Tax;
|
||||||
|
use App\Utilities\Date;
|
||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
|
|
||||||
$user = User::first();
|
$user = User::first();
|
||||||
$company = $user->companies()->first();
|
$company = $user->companies()->first();
|
||||||
|
@ -5,8 +5,8 @@ namespace Tests\Feature\Commands;
|
|||||||
use App\Jobs\Purchase\CreateBill;
|
use App\Jobs\Purchase\CreateBill;
|
||||||
use App\Models\Purchase\Bill;
|
use App\Models\Purchase\Bill;
|
||||||
use App\Notifications\Purchase\Bill as BillNotification;
|
use App\Notifications\Purchase\Bill as BillNotification;
|
||||||
|
use App\Utilities\Date;
|
||||||
use Illuminate\Support\Facades\Notification as Notification;
|
use Illuminate\Support\Facades\Notification as Notification;
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class BillReminderTest extends FeatureTestCase
|
class BillReminderTest extends FeatureTestCase
|
||||||
|
@ -5,8 +5,8 @@ namespace Tests\Feature\Commands;
|
|||||||
use App\Jobs\Sale\CreateInvoice;
|
use App\Jobs\Sale\CreateInvoice;
|
||||||
use App\Models\Sale\Invoice;
|
use App\Models\Sale\Invoice;
|
||||||
use App\Notifications\Sale\Invoice as InvoiceNotification;
|
use App\Notifications\Sale\Invoice as InvoiceNotification;
|
||||||
|
use App\Utilities\Date;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class InvoiceReminderTest extends FeatureTestCase
|
class InvoiceReminderTest extends FeatureTestCase
|
||||||
|
Loading…
x
Reference in New Issue
Block a user