Sahand-feizi wrote a reply+100 XP
2h ago
this is a common error in testing cookies, and I had this problem before. Something that works for me was changing the this:
$this->withCookie($cookie->getName(), $cookie->getValue())
->putJson(route('auth.refresh-tokens'));
to this:
$response = $this->call(
'PUT',
'/api/auth/refresh-tokens',
[],
[$cookie->getName() => $cookie->getValue()]
);
withCookie() relies on Laravel's testing cookie jar, while call() passes cookies directly to the request. In this case, using call() bypassed the helper layer and ensured the refresh_token cookie was attached to the PUT request correctly.
I hope this helps.
Sahand-feizi wrote a comment+100 XP
1mo ago
@LaramanCode I did the exact same, and I think this solution looks much cleaner.
Sahand-feizi liked a comment+100 XP
1mo ago
Another version
File app/IdeaStatus.php
<?php
declare(strict_types=1);
namespace App;
enum IdeaStatus: string
{
case PENDING = 'pending';
case IN_PROGRESS = 'in_progress';
case COMPLETED = 'completed';
public function label(): string
{
return match ($this) {
self::PENDING => 'Pending',
self::IN_PROGRESS => 'In Progress',
self::COMPLETED => 'Completed',
};
}
public function colors():string
{
return match ($this) {
self::PENDING => 'text-yellow-500 bg-yellow-500/10 border-yellow-500/20',
self::IN_PROGRESS => 'text-orange-500 bg-orange-500/10 border-orange-500/20',
self::COMPLETED => 'text-green-500 bg-green-500/10 border-green-500/20',
};
}
}
File resources/views/components/ide/status-label.blade.php \
<span @class(["inline-block text-xs rounded-full border mt-2 px-2 p-y-1 text-sx font-medium",
$status->colors(),
])>
{{ $status->label() }}
</span>
//File resources/views/components/card.blade.php \
<a href="{{route('ideas.show', $idea->id)}}" {{ $attributes(['class'=>'border border-border rounded-lg bg-card p-4 md:text-sm'])}} >
<h3 class="text-foreground text-lg">{{$idea->title}}</h3>
<x-idea.status-label :status="$idea->status" />
<div class="mt-5 line-clamp-3">{{ $idea->description }}</div>
<div class="mt-4">{{ $idea->created_at->diffForHumans() }}</div>
</a>
File resources/views/idea/index.blade.php
<x-layout>
<div class="text-muted-foreground">
<header class="py-8 md:py-12">
<h1 class="text-3xl font-bold">Ideas</h1>
<p class="text-muted-foreground text-sm mt-2"> Capture yor thoughts. Make a plan.</p>
</header>
<div class="mt-10">
<div class="grid md:grid-cols-2 gap-6">
@forelse($ideas as $idea)
<x-card :idea="$idea"/>
@empty
<h2 class="text-4xl font-bold text-purple-600 ">No ideas at this time</h2>
@endforelse
</div>
</div>
</div>
</x-layout>
Sahand-feizi wrote a comment+100 XP
1mo ago
@9icenet Thank you very mutch
Sahand-feizi wrote a comment+100 XP
1mo ago
Hi @jefrey. Thank you for this great course.