Skip to content

Commit

Permalink
beneficiary account type crud added
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed May 20, 2024
1 parent 8870b83 commit d33f67e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
5 changes: 3 additions & 2 deletions src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Fintech\Auth\Services\AuditService;
use Fintech\Auth\Services\FavouriteService;
use Fintech\Auth\Services\IpAddressService;
use Fintech\Auth\Services\LoginAttemptService;
use Fintech\Auth\Services\OneTimePinService;
use Fintech\Auth\Services\PasswordResetService;
use Fintech\Auth\Services\PermissionService;
Expand Down Expand Up @@ -110,11 +111,11 @@ public function ipAddress()
}

/**
* @return \Fintech\Auth\Services\LoginAttemptService
* @return LoginAttemptService
*/
public function loginAttempt()
{
return app(\Fintech\Auth\Services\LoginAttemptService::class);
return app(LoginAttemptService::class);
}

//** Crud Service Method Point Do not Remove **//
Expand Down
3 changes: 2 additions & 1 deletion src/Facades/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Fintech\Auth\Services\AuditService;
use Fintech\Auth\Services\FavouriteService;
use Fintech\Auth\Services\IpAddressService;
use Fintech\Auth\Services\LoginAttemptService;
use Fintech\Auth\Services\OneTimePinService;
use Fintech\Auth\Services\PasswordResetService;
use Fintech\Auth\Services\PermissionService;
Expand All @@ -27,7 +28,7 @@
* @method static AuditService audit()
* @method static FavouriteService favourite()
* @method static IpAddressService ipAddress()
* @method static \Fintech\Auth\Services\LoginAttemptService loginAttempt()
* @method static LoginAttemptService loginAttempt()
* // Crud Service Method Point Do not Remove //
*
* @see \Fintech\Auth\Auth
Expand Down
9 changes: 0 additions & 9 deletions src/Interfaces/LoginAttemptRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ public function list(array $filters = []);
*/
public function create(array $attributes = []);

/**
* find and update a resource attributes
*
* @param int|string $id
* @param array $attributes
* @return BaseModel
*/
public function update(int|string $id, array $attributes = []);

/**
* find and delete a entry from records
*
Expand Down
11 changes: 7 additions & 4 deletions src/Models/LoginAttempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class LoginAttempt extends BaseModel
{
use AuditableTrait;
use SoftDeletes;
use AuditableTrait;
use SoftDeletes;

/*
|--------------------------------------------------------------------------
Expand All @@ -23,7 +23,7 @@ class LoginAttempt extends BaseModel

protected $appends = ['links'];

protected $casts = ['login_attempt_data' => 'array', 'restored_at' => 'datetime', 'enabled' => 'bool'];
protected $casts = ['login_attempt_data' => 'array', 'restored_at' => 'datetime'];

protected $hidden = ['creator_id', 'editor_id', 'destroyer_id', 'restorer_id'];

Expand All @@ -38,6 +38,10 @@ class LoginAttempt extends BaseModel
| RELATIONS
|--------------------------------------------------------------------------
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(config('fintech.auth.user_model', User::class), 'user_id');
}

/*
|--------------------------------------------------------------------------
Expand All @@ -60,7 +64,6 @@ public function getLinksAttribute()

$links = [
'show' => action_link(route('auth.login-attempts.show', $primaryKey), __('core::messages.action.show'), 'get'),
'update' => action_link(route('auth.login-attempts.update', $primaryKey), __('core::messages.action.update'), 'put'),
'destroy' => action_link(route('auth.login-attempts.destroy', $primaryKey), __('core::messages.action.destroy'), 'delete'),
'restore' => action_link(route('auth.login-attempts.restore', $primaryKey), __('core::messages.action.restore'), 'post'),
];
Expand Down
13 changes: 13 additions & 0 deletions src/Repositories/Eloquent/LoginAttemptRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ public function list(array $filters = [])
$query->where($this->model->getKeyName(), 'like', "%{$filters['search']}%");
} else {
$query->where('name', 'like', "%{$filters['search']}%");
$query->orWhere('ip', 'like', "%{$filters['search']}%");
$query->orWhere('mac', 'like', "%{$filters['search']}%");
$query->orWhere('platform', 'like', "%{$filters['search']}%");
$query->orWhere('agent', 'like', "%{$filters['search']}%");
$query->orWhere('address', 'like', "%{$filters['search']}%");
$query->orWhere('city', 'like', "%{$filters['search']}%");
$query->orWhere('state', 'like', "%{$filters['search']}%");
$query->orWhere('country', 'like', "%{$filters['search']}%");
$query->orWhere('status', 'like', "%{$filters['search']}%");
$query->orWhere('login_attempt_data', 'like', "%{$filters['search']}%");
}
}
Expand All @@ -45,6 +54,10 @@ public function list(array $filters = [])
$query->onlyTrashed();
}

if (!empty($filters['user_id'])) {
$query->where('user_id', '=', $filters['user_id']);
}

//Handle Sorting
$query->orderBy($filters['sort'] ?? $this->model->getKeyName(), $filters['dir'] ?? 'asc');

Expand Down
9 changes: 2 additions & 7 deletions src/Services/LoginAttemptService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class LoginAttemptService
* LoginAttemptService constructor.
* @param LoginAttemptRepository $loginAttemptRepository
*/
public function __construct(LoginAttemptRepository $loginAttemptRepository) {
$this->loginAttemptRepository = $loginAttemptRepository;
public function __construct(private readonly LoginAttemptRepository $loginAttemptRepository)
{
}

/**
Expand All @@ -40,11 +40,6 @@ public function find($id, $onlyTrashed = false)
return $this->loginAttemptRepository->find($id, $onlyTrashed);
}

public function update($id, array $inputs = [])
{
return $this->loginAttemptRepository->update($id, $inputs);
}

public function destroy($id)
{
return $this->loginAttemptRepository->delete($id);
Expand Down

0 comments on commit d33f67e

Please sign in to comment.