Dev
Dev
FFilament
Created by Dev on 4/2/2025 in #❓┊help
CSRF Mismatch
I'm trying to setup connected login with Sanctum / Next.js Currently This is my setup
User.php
class User extends Authenticatable
{
use HasApiTokens;
protected $fillable = [
'name',
'email',
'password',
'avatar_url',
'total_points',
'last_played_at'
];
User.php
class User extends Authenticatable
{
use HasApiTokens;
protected $fillable = [
'name',
'email',
'password',
'avatar_url',
'total_points',
'last_played_at'
];
http://127.0.0.1:8000/login
http://127.0.0.1:8000/login
{ "email": "[email protected]", "password": "password" }
```php

AuthController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use App\Models\User;

class AuthController extends Controller
{
public function login(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required',
]);

if (!Auth::attempt($request->only('email', 'password'))) {
return response()->json([
'message' => 'Invalid credentials'
], 401);
}

return response()->json([
'token' => $request->user()->createToken('auth_token')->plainTextToken,
'user' => $request->user()
]);
}

public function logout(Request $request)
{
$request->user()->currentAccessToken()->delete();

return response()->json([
'message' => 'Logged out successfully'
]);
}
}
```php

AuthController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use App\Models\User;

class AuthController extends Controller
{
public function login(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required',
]);

if (!Auth::attempt($request->only('email', 'password'))) {
return response()->json([
'message' => 'Invalid credentials'
], 401);
}

return response()->json([
'token' => $request->user()->createToken('auth_token')->plainTextToken,
'user' => $request->user()
]);
}

public function logout(Request $request)
{
$request->user()->currentAccessToken()->delete();

return response()->json([
'message' => 'Logged out successfully'
]);
}
}
web.php
<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;

// Public routes
Route::post('/login', [AuthController::class, 'login']);

// Protected routes
Route::middleware('auth:sanctum')->group(function () {
Route::post('/logout', [AuthController::class, 'logout']);
Route::get('/user', function (Request $request) {
return $request->user();
});
});
web.php
<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;

// Public routes
Route::post('/login', [AuthController::class, 'login']);

// Protected routes
Route::middleware('auth:sanctum')->group(function () {
Route::post('/logout', [AuthController::class, 'logout']);
Route::get('/user', function (Request $request) {
return $request->user();
});
});
Response:
{
"message": "CSRF token mismatch.",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
"file": "C:\\Users\\User\\Desktop\\Trivia\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php",
"line": 644,
"trace": [
{
"file": "C:\\Users\\User\\Desktop\\Trivia\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php",
"line": 587,
"function": "prepareException",
"class": "Illuminate\\Foundation\\Exceptions\\Handler",
"type": "->"
},
{
"message": "CSRF token mismatch.",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
"file": "C:\\Users\\User\\Desktop\\Trivia\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php",
"line": 644,
"trace": [
{
"file": "C:\\Users\\User\\Desktop\\Trivia\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php",
"line": 587,
"function": "prepareException",
"class": "Illuminate\\Foundation\\Exceptions\\Handler",
"type": "->"
},
5 replies
FFilament
Created by Dev on 3/31/2025 in #❓┊help
Border Issue
protected function getAnswerCards(): array
{
$answers = $this->getRecord()->answers;

return $answers->map(function ($answer) {
return Components\Card::make()
->schema([
Components\TextEntry::make('answer_text')
->state($answer->answer_text)
->weight($answer->is_correct ? 'bold' : 'normal')
->color($answer->is_correct ? 'success' : 'gray')
->columnSpan(2),

Components\IconEntry::make('is_correct')
->state($answer->is_correct)
->label('Correct Answer')
->icon(fn (bool $state): string => $state ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle')
->color(fn (bool $state): string => $state ? 'success' : 'danger')
->size(Components\IconEntry\IconEntrySize::Large)
->alignCenter(),
])
->columns(2)
->extraAttributes([
'class' => $answer->is_correct ? 'border-2 border-indigo-500' : 'border-gray-300',
'style' => 'min-height: 120px; display: flex; flex-direction: column; justify-content: space-between;',
]);
})->toArray();
}
protected function getAnswerCards(): array
{
$answers = $this->getRecord()->answers;

return $answers->map(function ($answer) {
return Components\Card::make()
->schema([
Components\TextEntry::make('answer_text')
->state($answer->answer_text)
->weight($answer->is_correct ? 'bold' : 'normal')
->color($answer->is_correct ? 'success' : 'gray')
->columnSpan(2),

Components\IconEntry::make('is_correct')
->state($answer->is_correct)
->label('Correct Answer')
->icon(fn (bool $state): string => $state ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle')
->color(fn (bool $state): string => $state ? 'success' : 'danger')
->size(Components\IconEntry\IconEntrySize::Large)
->alignCenter(),
])
->columns(2)
->extraAttributes([
'class' => $answer->is_correct ? 'border-2 border-indigo-500' : 'border-gray-300',
'style' => 'min-height: 120px; display: flex; flex-direction: column; justify-content: space-between;',
]);
})->toArray();
}
The border shows, but only as white, i cannot change the color to indigo or whatever other color Im trying to make it green, i tried indigo, i tried to make border-2 to border -3 it completely disappears, trying to understand why is that happening
5 replies
FFilament
Created by Dev on 2/19/2025 in #❓┊help
Sending a SMS Notification, just like a Mail Notification
So currently I have a working SMTP integration, where if a request is done, it would send an email to the user How can i do the same for an email using filamentphp? is there a plugin or anything of that sort? I found a whatsapp integration with twilio but no direct SMS
4 replies
FFilament
Created by Dev on 12/5/2024 in #❓┊help
Dark mode different primary color
->colors([ 'primary' => Color::hex('#CDC1B3'), 'dark:primary' => Color::hex('#A89887'), // Set your dark mode primary color here ]) I want a way to choose different primary color for dark mode, is that doable in filament?
3 replies