refs #import date date time issue solved.
This commit is contained in:
@ -91,5 +91,9 @@ class Kernel extends HttpKernel
|
||||
'install' => \App\Http\Middleware\CanInstall::class,
|
||||
'company.settings' => \App\Http\Middleware\LoadSettings::class,
|
||||
'company.currencies' => \App\Http\Middleware\LoadCurrencies::class,
|
||||
'dateformat.paid_at' => \App\Http\Middleware\DateFormatPaidAt::class,
|
||||
'dateformat.due_at' => \App\Http\Middleware\DateFormatDueAt::class,
|
||||
'dateformat.billed_at' => \App\Http\Middleware\DateFormatBilledAt::class,
|
||||
'dateformat.invoiced_at' => \App\Http\Middleware\DateFormatInvoicedAt::class,
|
||||
];
|
||||
}
|
||||
|
29
app/Http/Middleware/DateFormatBilledAt.php
Normal file
29
app/Http/Middleware/DateFormatBilledAt.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Date;
|
||||
|
||||
class DateFormatBilledAt
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($request->method() == 'POST' || $request->method() == 'PATCH') {
|
||||
$date = Date::parse($request->get('billed_at'))->format('Y-m-d');
|
||||
|
||||
$date_time = $date . ' ' . Date::now()->format('H:i:s');
|
||||
|
||||
$request->request->set('billed_at', $date_time);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
29
app/Http/Middleware/DateFormatDueAt.php
Normal file
29
app/Http/Middleware/DateFormatDueAt.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Date;
|
||||
|
||||
class DateFormatDueAt
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($request->method() == 'POST' || $request->method() == 'PATCH') {
|
||||
$date = Date::parse($request->get('due_at'))->format('Y-m-d');
|
||||
|
||||
$date_time = $date . ' ' . Date::now()->format('H:i:s');
|
||||
|
||||
$request->request->set('due_at', $date_time);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
29
app/Http/Middleware/DateFormatInvoicedAt.php
Normal file
29
app/Http/Middleware/DateFormatInvoicedAt.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Date;
|
||||
|
||||
class DateFormatInvoicedAt
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($request->method() == 'POST' || $request->method() == 'PATCH') {
|
||||
$date = Date::parse($request->get('invoiced_at'))->format('Y-m-d');
|
||||
|
||||
$date_time = $date . ' ' . Date::now()->format('H:i:s');
|
||||
|
||||
$request->request->set('invoiced_at', $date_time);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
29
app/Http/Middleware/DateFormatPaidAt.php
Normal file
29
app/Http/Middleware/DateFormatPaidAt.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Date;
|
||||
|
||||
class DateFormatPaidAt
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($request->method() == 'POST' || $request->method() == 'PATCH') {
|
||||
$date = Date::parse($request->get('paid_at'))->format('Y-m-d');
|
||||
|
||||
$date_time = $date . ' ' . Date::now()->format('H:i:s');
|
||||
|
||||
$request->request->set('paid_at', $date_time);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -26,5 +26,4 @@ class LoadCurrencies
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Expense;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Date;
|
||||
|
||||
class Bill extends Request
|
||||
{
|
||||
@ -47,4 +48,16 @@ class Bill extends Request
|
||||
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if ($validator->errors()->count()) {
|
||||
// Set date
|
||||
$billed_at = Date::parse($this->request->get('billed_at'))->format('Y-m-d');
|
||||
$due_at = Date::parse($this->request->get('due_at'))->format('Y-m-d');
|
||||
|
||||
$this->request->set('billed_at', $billed_at);
|
||||
$this->request->set('due_at', $due_at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Expense;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Date;
|
||||
|
||||
class BillPayment extends Request
|
||||
{
|
||||
@ -32,4 +33,13 @@ class BillPayment extends Request
|
||||
'attachment' => 'mimes:' . setting('general.file_types', 'pdf,jpeg,jpg,png'),
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if ($validator->errors()->count()) {
|
||||
$paid_at = Date::parse($this->request->get('paid_at'))->format('Y-m-d');
|
||||
|
||||
$this->request->set('paid_at', $paid_at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Expense;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Date;
|
||||
|
||||
class Payment extends Request
|
||||
{
|
||||
@ -35,4 +36,13 @@ class Payment extends Request
|
||||
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if ($validator->errors()->count()) {
|
||||
$paid_at = Date::parse($this->request->get('paid_at'))->format('Y-m-d');
|
||||
|
||||
$this->request->set('paid_at', $paid_at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Date;
|
||||
|
||||
class Invoice extends Request
|
||||
{
|
||||
@ -47,4 +48,16 @@ class Invoice extends Request
|
||||
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if ($validator->errors()->count()) {
|
||||
// Set date
|
||||
$invoiced_at = Date::parse($this->request->get('invoiced_at'))->format('Y-m-d');
|
||||
$due_at = Date::parse($this->request->get('due_at'))->format('Y-m-d');
|
||||
|
||||
$this->request->set('invoiced_at', $invoiced_at);
|
||||
$this->request->set('due_at', $due_at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Date;
|
||||
|
||||
class InvoicePayment extends Request
|
||||
{
|
||||
@ -32,4 +33,13 @@ class InvoicePayment extends Request
|
||||
'attachment' => 'mimes:jpeg,jpg,png,pdf',
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if ($validator->errors()->count()) {
|
||||
$paid_at = Date::parse($this->request->get('paid_at'))->format('Y-m-d');
|
||||
|
||||
$this->request->set('paid_at', $paid_at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Income;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Date;
|
||||
|
||||
class Revenue extends Request
|
||||
{
|
||||
@ -35,4 +36,13 @@ class Revenue extends Request
|
||||
'attachment' => 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024,
|
||||
];
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if ($validator->errors()->count()) {
|
||||
$paid_at = Date::parse($this->request->get('paid_at'))->format('Y-m-d');
|
||||
|
||||
$this->request->set('paid_at', $paid_at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,28 +159,6 @@ class Bill extends Model
|
||||
$this->attributes['currency_rate'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert billed_at to datetime.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setBilledAtAttribute($value)
|
||||
{
|
||||
$this->attributes['billed_at'] = $value . ' ' . Date::now()->format('H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert due_at to datetime.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setDueAtAttribute($value)
|
||||
{
|
||||
$this->attributes['due_at'] = $value . ' ' . Date::now()->format('H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
|
@ -86,17 +86,6 @@ class BillPayment extends Model
|
||||
return $query->sum('amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert paid_at to datetime.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPaidAtAttribute($value)
|
||||
{
|
||||
$this->attributes['paid_at'] = $value . ' ' . Date::now()->format('H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
|
@ -132,17 +132,6 @@ class Payment extends Model
|
||||
return $query->orderBy('paid_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert paid_at to datetime.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPaidAtAttribute($value)
|
||||
{
|
||||
$this->attributes['paid_at'] = $value . ' ' . Date::now()->format('H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
|
@ -161,28 +161,6 @@ class Invoice extends Model
|
||||
$this->attributes['currency_rate'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert invoiced_at to datetime.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setInvoicedAtAttribute($value)
|
||||
{
|
||||
$this->attributes['invoiced_at'] = $value . ' ' . Date::now()->format('H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert due_at to datetime.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setDueAtAttribute($value)
|
||||
{
|
||||
$this->attributes['due_at'] = $value . ' ' . Date::now()->format('H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
|
@ -86,17 +86,6 @@ class InvoicePayment extends Model
|
||||
return $query->sum('amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert paid_at to datetime.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPaidAtAttribute($value)
|
||||
{
|
||||
$this->attributes['paid_at'] = $value . ' ' . Date::now()->format('H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
|
@ -133,17 +133,6 @@ class Revenue extends Model
|
||||
$this->attributes['currency_rate'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert paid_at to datetime.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPaidAtAttribute($value)
|
||||
{
|
||||
$this->attributes['paid_at'] = $value . ' ' . Date::now()->format('H:i:s');
|
||||
}
|
||||
|
||||
public function scopeLatest($query)
|
||||
{
|
||||
return $query->orderBy('paid_at', 'desc');
|
||||
|
Reference in New Issue
Block a user