Merge pull request #2989 from boracakirel/added-dates-formating-event
Added dates formating event.
This commit is contained in:
commit
21777a8150
20
app/Events/Common/DatesFormating.php
Normal file
20
app/Events/Common/DatesFormating.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Common;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
|
||||
class DatesFormating extends Event
|
||||
{
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $request
|
||||
*/
|
||||
public function __construct($request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Events\Common\DatesFormating;
|
||||
use Closure;
|
||||
use Date;
|
||||
|
||||
@ -12,13 +13,24 @@ class DateFormat
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (($request->method() == 'POST') || ($request->method() == 'PATCH')) {
|
||||
// todo fire event
|
||||
$fields = ['paid_at', 'due_at', 'issued_at', 'started_at', 'ended_at', 'expire_at', 'recurring_started_at', 'recurring_limit_date'];
|
||||
event(new DatesFormating($request));
|
||||
|
||||
$fields = [
|
||||
'paid_at',
|
||||
'due_at',
|
||||
'issued_at',
|
||||
'started_at',
|
||||
'ended_at',
|
||||
'expire_at',
|
||||
'recurring_started_at',
|
||||
'recurring_limit_date',
|
||||
];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$date = $request->get($field);
|
||||
|
Loading…
x
Reference in New Issue
Block a user