Loan Order
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Laravel\Nova\Actions\ActionEvent;
|
||||
|
||||
class EventType
|
||||
{
|
||||
/**
|
||||
@@ -56,9 +58,27 @@ class EventType
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Laravel nova events
|
||||
*/
|
||||
public static function laravelNovaEvents(): array
|
||||
{
|
||||
return [
|
||||
self::laravelNovaActionEvent(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Laravel nova action event
|
||||
*/
|
||||
public static function laravelNovaActionEvent(): string
|
||||
{
|
||||
return ActionEvent::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guest the event
|
||||
* @param object $event
|
||||
* @param string|object $event
|
||||
*/
|
||||
public static function guessEvent(string|object $event): string
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Events\EventType;
|
||||
use App\Models\System\Verification;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Request as GuzzleRequest;
|
||||
@@ -67,7 +68,7 @@ function storeAuthEvent(string $name, Request $request): void
|
||||
{
|
||||
Log::channel('auth_activity')
|
||||
->info(sprintf(
|
||||
'%s, APP_NAME: %s, REQUEST_TYPE: %s, SOURCE_IP: %s, SOURCE_PORT: %s, SOURCE_URL: %s, DESTINATION_IP: %s, DESTINATION_PORT: %s, DESTINATION_COUNTRY: %s',
|
||||
'%s, APP_NAME: %s, REQUEST_TYPE: %s, SOURCE_IP: %s, SOURCE_PORT: %s, SOURCE_URL: %s, DESTINATION_IP: %s, DESTINATION_PORT: %s, DESTINATION_COUNTRY: %s, USER_ID: %s',
|
||||
$name,
|
||||
config('app.name'),
|
||||
$request->method(),
|
||||
@@ -77,5 +78,45 @@ function storeAuthEvent(string $name, Request $request): void
|
||||
$request->host(),
|
||||
$request->getPort(),
|
||||
'tk',
|
||||
$request->user()->id ?? '-',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store resource events
|
||||
*/
|
||||
function storeResourceEvent(string $name, array $data, Request $request): void
|
||||
{
|
||||
if ($name === EventType::laravelNovaActionEvent() || empty($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$before = [];
|
||||
$after = [];
|
||||
foreach ($data[0]->getChanges() as $key => $value) {
|
||||
$before[] = [$key => $data[0]->getOriginal()[$key]];
|
||||
$after[] = [$key => $value];
|
||||
}
|
||||
|
||||
Log::channel('resource_activity')
|
||||
->info(sprintf(
|
||||
'%s, APP_NAME: %s, REQUEST_TYPE: %s, SOURCE_IP: %s, SOURCE_PORT: %s, SOURCE_URL: %s, DESTINATION_IP: %s, DESTINATION_PORT: %s, DESTINATION_COUNTRY: %s, USER_ID: %s, MODEL_NAME: %s, BEFORE: %s, AFTER: %s',
|
||||
$name,
|
||||
config('app.name'),
|
||||
$request->method(),
|
||||
$request->ip(),
|
||||
$_SERVER['REMOTE_PORT'],
|
||||
$request->url(),
|
||||
$request->host(),
|
||||
$request->getPort(),
|
||||
'tk',
|
||||
$request->user()->id ?? '-',
|
||||
get_class($data[0]),
|
||||
json_encode($before),
|
||||
json_encode($after),
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
Log::error('Error in storeResourceEvent() helpers', $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Boolean;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Fields\Textarea;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
@@ -94,7 +95,7 @@ class Branch extends Resource
|
||||
|
||||
Textarea::make(__('Address'), 'address'),
|
||||
|
||||
NovaSwitcher::make(__('Active'), 'active')
|
||||
Boolean::make(__('Active'), 'active')
|
||||
->default(true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Nova\Resource;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Fields\Boolean;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Trin4ik\NovaSwitcher\NovaSwitcher;
|
||||
|
||||
@@ -69,7 +70,7 @@ class CardState extends Resource
|
||||
Text::make(__('Notes'), 'notes')
|
||||
->rules('nullable', 'string', 'max:255'),
|
||||
|
||||
NovaSwitcher::make(__('Active'), 'active')
|
||||
Boolean::make(__('Active'), 'active')
|
||||
->default(true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Trin4ik\NovaSwitcher\NovaSwitcher;
|
||||
use Laravel\Nova\Fields\Boolean;
|
||||
|
||||
class CardType extends Resource
|
||||
{
|
||||
@@ -69,7 +70,7 @@ class CardType extends Resource
|
||||
Text::make(__('Notes'), 'notes')
|
||||
->rules('nullable', 'string', 'max:255'),
|
||||
|
||||
NovaSwitcher::make(__('Active'), 'active')
|
||||
Boolean::make(__('Active'), 'active')
|
||||
->default(true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -165,51 +165,6 @@ class LoanOrder extends Resource
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
]),
|
||||
|
||||
new Panel(__('Loan'), [
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Nova\Resource;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Number;
|
||||
use Laravel\Nova\Fields\Boolean;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Trin4ik\NovaSwitcher\NovaSwitcher;
|
||||
@@ -74,7 +75,7 @@ class LoanType extends Resource
|
||||
Text::make(__('Notes'), 'notes')
|
||||
->rules('required', 'string', 'max:255'),
|
||||
|
||||
NovaSwitcher::make(__('Active'), 'active')
|
||||
Boolean::make(__('Active'), 'active')
|
||||
->default(true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Resource;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\Boolean;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
@@ -75,7 +76,7 @@ class Province extends Resource
|
||||
->translatable()
|
||||
->rules('required', 'string', 'max:255'),
|
||||
|
||||
NovaSwitcher::make(__('Active'), 'active')
|
||||
Boolean::make(__('Active'), 'active')
|
||||
->default(true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use Laravel\Nova\Fields\HasMany;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\MorphToMany;
|
||||
use Laravel\Nova\Fields\Password;
|
||||
use Laravel\Nova\Fields\Boolean;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Nurmuhammet\NovaInputmask\NovaInputmask;
|
||||
@@ -108,7 +109,7 @@ class User extends Resource
|
||||
->creationRules('required', Rules\Password::defaults())
|
||||
->updateRules('nullable', Rules\Password::defaults()),
|
||||
|
||||
NovaSwitcher::make(__('Active'), 'active')
|
||||
Boolean::make(__('Active'), 'active')
|
||||
->default(true)
|
||||
->canSeeWhen('isAdmin', $this),
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -21,5 +22,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
Model::shouldBeStrict(! app()->isProduction());
|
||||
|
||||
Event::listen(['eloquent.created: *', 'eloquent.updated: *', 'eloquent.deleted: *'], function(string $eventName, array $data) {
|
||||
storeResourceEvent($eventName, $data, request());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user