An external endpoint

An external endpoint is required to activate the user, but when I request it for only one user, it also requests it for all records in the database why this issue happened ?
6 Replies
Matthew
Matthew2w ago
What is the best you were hoping for with that much information?
Shaza
ShazaOP2w ago
CheckboxColumn::make('active') ->updateStateUsing(function (User $record, bool $state): bool { $payload = [ 'user' => "user/{$record->id}",
'active' =>0,
]; Log::info('Sending payload to API:', $payload); try { $response = Http::post('127.0.0.1:8007/api/activateuser', $payload); if ($response->successful()) { Log::info('API response:', ['status' => $response->status(), 'body' => $response->body()]); $record->forceFill(['active' => $state])->save(); Notification::make() ->title('Status updated successfully') ->success() ->send(); return $state; } Log::error('API request failed:', ['status' => $response->status(), 'body' => $response->body()]); return $record->active; } catch (\Exception $e) { Log::error('API request exception:', ['error' => $e->getMessage()]); return $record->active; } }), The problem is that it requests the endpoint repeatedly for all users, meaning that it activates all users despite passing one user.
Matthew
Matthew2w ago
Does your log show multiple 'Send payload to API' instances?
awcodes
awcodes2w ago
I think the problem is that the entire table state is getting re-rendered per row so maybe an additional check to see if the active changed or not could be relevant and bail out early if it didn’t.
Shaza
ShazaOP2w ago
No only for one user, but the endpoint exits the timeout, and when I increased the request time and monitored the response, it responds to all inactive users and activates them, noting that the activation endpoints perform the process normally and were tested from the postman.
Dennis Koch
Dennis Koch2w ago
it responds to all inactive users and activates them,
What do you mean by that? Did you verify that Filament actually sends requests for all of them? PS: Please read #✅┊rules and format your code

Did you find this page helpful?