Comments (6)
Oh i get it, you are not overwriting a column with your attribute function, but rather creating a new one, understood, thats why it worked for me and not for you.
Yes the problem probably happens here in the resolveUsers
function as there the columns are read:
public function resolveUsers(Collection $ids): Collection
{
if ($this->usersResolver) {
return collect(($this->usersResolver)($ids));
} elseif (class_exists(\App\Models\User::class)) {
return \App\Models\User::whereKey($ids)->get(['id', 'name', 'email']);
} elseif (class_exists(\App\User::class)) {
return \App\User::whereKey($ids)->get(['id', 'name', 'email']);
}
return $ids->map(fn (string|int $id) => [
'id' => $id,
'name' => "User ID: {$id}",
]);
}
You probaly need to overwrite the user resolver as you do above..i thnik that is the recommended solution in this case. I'd tend to say this is not a bug but working as intended (out of the box with standard laravel installation, where the name field does exist on the users table afaik). But i guess only a maintainer can answer that for sure :)
from pulse.
@joostvanhoof isn't these kindof attributes deprecated? could you try with the new one with Attribute::make?
protected function name(): Attribute
{
return Attribute::make(get: fn () => $this->first_name.' '.$this->last_name);
}
from pulse.
@joostvanhoof Do you have any special configuration / model? Because i tried what you did and it workes flawlessly, having a quick look at the pulse source it should also work for you
from pulse.
@pyr0hu I had no clue 😅. I tried using Attribute::make
but it gives the same error.
@toitzi not that I can think of, I left the Pulse config as is, and not sure what else could be 'special' about my setup.
Edit:
Interestingly, this works, using the name
attribute:
Pulse::users(function ($ids) {
return User::findMany($ids)->map(fn ($user) => [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'avatar' => '',
]);
});
from pulse.
Sorry, reopening here as there does seem something related to Pulse.
I have a some custom Middleware with this:
public function handle(Request $request, Closure $next)
{
if (! auth()->user()) {
return $next($request);
}
if (! auth()->user()->last_active_at or auth()->user()->last_active_at->isPast()) {
auth()->user()->last_active_at = now();
}
return $next($request);
}
and Flare indicates the error is in the part return $next($request);
on the last line of that function, which makes me think that it's something else. This error only happens when visiting the Pulse dashboard.
This is the error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name' in 'field list'
SELECT `id`, `name`, `email` FROM `users` WHERE `users`.`id` IN (1)
Now when I add
Pulse::users(function ($ids) {
return User::findMany($ids)->map(fn ($user) => [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'avatar' => '',
]);
});
in AppServiceProvider
, the error disappears.
from pulse.
Yes that makes sense, thanks for your help. I sometimes struggle with the stack trace not actually pointing to where the query happens. Will close this issue.
from pulse.
Related Issues (20)
- Logout Event with laravel/ui causes TypeError HOT 5
- redis cluster not supported for ingesting data HOT 5
- Support for sqlsrv HOT 3
- Locking and Trimming HOT 2
- Memory leak when running tests. HOT 1
- Running mysql command "optimize" fails on pulse_aggregates HOT 2
- Just an idea: Recording request data when logging exceptions HOT 1
- internal hooks HOT 1
- Feature request: ability to configure how many days of data is kept in pulse entries HOT 4
- Pulse significantly slows down Laravel Octane when using multiple CPU cores HOT 7
- SQLSTATE[HY000]: General error: 1 no such column: true HOT 6
- Feature Request: Extend nav bar with items HOT 2
- Enhancement Request: Customizable Context Tags for Monitoring Entries. HOT 1
- Dashboard with empty screen HOT 2
- Pulse Scalability rocks! - extract Pulse data repository? HOT 1
- Change logo for the dark theme HOT 1
- Integrate Pulse into Nova? HOT 1
- TypeError in `Pulse::rememberUser()` (Logout Event) HOT 1
- 500 Server Error displaying HOT 1
- UI issue (supports-scrollbars:pr-3) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pulse.