Skip to content

Commit

Permalink
Update DateFormat middleware event..
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jun 23, 2023
1 parent dfc0c7e commit 03c9e55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/Events/Common/DatesFormating.php
Expand Up @@ -6,15 +6,18 @@

class DatesFormating extends Event
{
public $columns;

public $request;

/**
* Create a new event instance.
*
* @param $request
*/
public function __construct($request)
public function __construct($columns, $request)
{
$this->columns = $columns;
$this->request = $request;
}
}
9 changes: 6 additions & 3 deletions app/Http/Middleware/DateFormat.php
Expand Up @@ -19,9 +19,8 @@ class DateFormat
public function handle($request, Closure $next)
{
if (($request->method() == 'POST') || ($request->method() == 'PATCH')) {
event(new DatesFormating($request));

$fields = [
$columns = new \stdClass();
$columns->fields = [
'paid_at',
'due_at',
'issued_at',
Expand All @@ -32,6 +31,10 @@ public function handle($request, Closure $next)
'recurring_limit_date',
];

event(new DatesFormating($columns, $request));

$fields = $columns->fields;

foreach ($fields as $field) {
$date = $request->get($field);

Expand Down

0 comments on commit 03c9e55

Please sign in to comment.