Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoguenet committed Mar 8, 2024
1 parent d28f134 commit 7eafb98
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 158 deletions.
7 changes: 4 additions & 3 deletions app/Http/Controllers/Admin/Nudge/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

class EditController extends Controller
{
public function __invoke(Nudge $nudge): View
{
return view('nudges.edit', [
public function __invoke(
Nudge $nudge,
): View {
return view('nudges.create', [
'nudge' => $nudge,
]);
}
Expand Down
15 changes: 7 additions & 8 deletions app/Http/Controllers/Admin/Nudge/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@

class UpdateController extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(Nudge $nudge, Request $request): RedirectResponse
{
public function __invoke(
Nudge $nudge,
Request $request,
): RedirectResponse {
$validated = $request->validate([
'title' => ['required', 'unique:nudges,title,'.$nudge->id, 'max:100'],
'content' => 'required|string|max:500',
'title' => ['required', 'unique:nudges,title,'.$nudge->id, 'min:3', 'max:100'],
'content' => 'required|string|min:10|max:500',
'code' => 'required|string',
]);

$nudge->update($validated);

return redirect()->route('admin.index');
return redirect()->back()->with('status', 'nudge-edited');
}
}
5 changes: 3 additions & 2 deletions app/Http/Controllers/Api/Nudge/ToggleLikeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

class ToggleLikeController extends Controller
{
public function __invoke(Nudge $nudge): Response
{
public function __invoke(
Nudge $nudge,
): Response {
/** @var User $user */
$user = auth()->user();

Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Nudge/ShowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

class ShowController extends Controller
{
public function __invoke(Nudge $nudge): View
{
public function __invoke(
Nudge $nudge,
): View {
abort_if(! $nudge->validated, 404);

$randomSynonym = (new GenerateRandomSynonym)->handle();
Expand Down
9 changes: 5 additions & 4 deletions app/Http/Controllers/Nudge/StoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

class StoreController extends Controller
{
public function __invoke(Request $request): RedirectResponse
{
public function __invoke(
Request $request,
): RedirectResponse {
$validated = $request->validate([
'title' => 'required|unique:nudges|max:100',
'content' => 'required|string|max:500',
'title' => 'required|unique:nudges|min:3|max:100',
'content' => 'required|string|min:10|max:500',
'code' => 'required|string',
]);

Expand Down
2 changes: 1 addition & 1 deletion resources/views/homepage.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="mx-auto max-w-4xl">
@if ($nudge)
<div x-data="nudge({{ Js::from(auth()->user()?->isLiked($nudge)) }})">
<h1 class="text-4xl font-bold tracking-tight text-gray-900 mb-5">{{ $nudge->title }}</h1>
<h1 class="text-4xl font-bold tracking-tight text-gray-900 mb-5">{{ Str::title($nudge->title) }}</h1>

<article class="flex items-center justify-between text-md leading-8 text-gray-500 sm:text-lg mb-2.5">
<span class="prose">{!! Str::markdown($nudge->content) !!}</span>
Expand Down
155 changes: 85 additions & 70 deletions resources/views/nudges/create.blade.php

Large diffs are not rendered by default.

183 changes: 115 additions & 68 deletions resources/views/nudges/edit.blade.php

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tests/Feature/Admin/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
->get(route('admin.index'))
->assertRedirect();
});

it('can edit a nudge')->todo();
2 changes: 2 additions & 0 deletions tests/Feature/Admin/NudgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

use function Pest\Laravel\actingAs;

it('can create a nudge')->todo();

it('can validate nudges', function () {
$user = User::factory()->admin()->create();
$nudge = Nudge::factory()->create();
Expand Down

0 comments on commit 7eafb98

Please sign in to comment.