Skip to content

Commit

Permalink
seeder updated and service provider optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Sep 27, 2023
1 parent 7529055 commit db4e1a8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/Http/Controllers/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
namespace Fintech\Auth\Http\Controllers;

use Fintech\Auth\Http\Requests\RegistrationRequest;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;

class RegisteredUserController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/LoginRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function authenticate(): void
{
$this->ensureIsNotRateLimited();

if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
if (! Auth::guard('api')->attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());

throw ValidationException::withMessages([
Expand Down
11 changes: 8 additions & 3 deletions src/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
namespace Fintech\Auth\Models;

use Fintech\Core\Traits\BlameableTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use OwenIt\Auditing\Contracts\Auditable;

class User extends Model implements Auditable
class User extends Authenticatable implements Auditable
{
use BlameableTrait;
use \OwenIt\Auditing\Auditable;
use SoftDeletes;
// use SoftDeletes;

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -41,6 +41,11 @@ class User extends Model implements Auditable
|--------------------------------------------------------------------------
*/

public function userProfile()
{
return $this->hasOne(UserProfile::class);
}

/*
|--------------------------------------------------------------------------
| SCOPES
Expand Down
2 changes: 2 additions & 0 deletions src/Repositories/Eloquent/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function list(array $filters = [])
//Handle Sorting
$query->orderBy($filters['sort'] ?? $this->model->getKeyName(), $filters['direction'] ?? 'asc');

$query->with(['userProfile']);

//Prepare Output
return (isset($filters['paginate']) && $filters['paginate'] == true)
? $query->paginate(($filters['per_page'] ?? 20))
Expand Down
11 changes: 5 additions & 6 deletions src/RepositoryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ class RepositoryServiceProvider extends ServiceProvider implements DeferrablePro
public function register(): void
{
foreach ($this->repositories as $interface => $bindings) {
$this->app->bind($interface, function () use ($bindings) {
return match (config('database.default')) {
'mongodb' => new $bindings['mongodb'](),
default => new $bindings['default'](),
};
}, true);
$this->app->bind($interface, function ($app) use ($bindings) {
return (config('database.default') == 'mongodb')
? $app->make($bindings['mongodb'])
: $app->make($bindings['default']);
});
}
}

Expand Down

0 comments on commit db4e1a8

Please sign in to comment.