Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jan 26, 2024
1 parent 2984ff4 commit 73b87af
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Cone\Root\Http\Controllers\Auth;

use App\Models\User;
use Cone\Root\Http\Controllers\Controller;
use Cone\Root\Models\User;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Http\RedirectResponse;
Expand Down
30 changes: 19 additions & 11 deletions src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,20 +387,28 @@ public function paginate(Request $request): LengthAwarePaginator
->paginate($request->input($this->getPerPageKey()))
->withQueryString()
->through(function (Model $model) use ($request): array {
return [
'id' => $model->getKey(),
'url' => $this->modelUrl($model),
'model' => $model,
'abilities' => $this->mapModelAbilities($request, $model),
'fields' => $this->resolveFields($request)
->subResource(false)
->authorized($request, $model)
->visible('index')
->mapToDisplay($request, $model),
];
return $this->mapModel($request, $model);
});
}

/**
* Map the model.
*/
public function mapModel(Request $request, Model $model): array
{
return [
'id' => $model->getKey(),
'url' => $this->modelUrl($model),
'model' => $model,
'abilities' => $this->mapModelAbilities($request, $model),
'fields' => $this->resolveFields($request)
->subResource(false)
->authorized($request, $model)
->visible('index')
->mapToDisplay($request, $model),
];
}

/**
* Handle the request.
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/Http/ForgotPasswordControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Cone\Root\Tests\Http;

use Cone\Root\Notifications\ResetPassword;
use Cone\Root\Tests\TestCase;
use Cone\Root\Tests\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Support\Facades\Notification;

class ForgotPasswordControllerTest extends TestCase
Expand All @@ -31,6 +31,6 @@ public function test_forgot_password_controller_handles_password_reset_request()
])->assertRedirect()
->assertSessionDoesntHaveErrors();

Notification::assertNothingSentTo($user);
Notification::assertSentTo($user, ResetPassword::class);
}
}
4 changes: 4 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Cone\Root\Tests;

use Cone\Root\Interfaces\Models\User as UserInterface;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Facades\Storage;
Expand All @@ -17,6 +18,8 @@ public function setUp(): void

$this->app['router']->getRoutes()->refreshNameLookups();

$this->app->bind(UserInterface::class, User::class);

$this->startSession();

$this->app['request']->setLaravelSession($this->app['session']);
Expand All @@ -30,5 +33,6 @@ public function setUp(): void

$this->app['config']->set('root.media.tmp_dir', Storage::disk('local')->path('root-tmp'));
$this->app['config']->set('root.media.chunk_expiration', 0);
$this->app['config']->set('auth.providers.users.model', User::class);
}
}

0 comments on commit 73b87af

Please sign in to comment.