foggy
foggy
Explore posts from servers
FFilament
Created by foggy on 1/29/2025 in #❓┊help
Newb question: populating table based on query
Got it. Thanks for your input 🤗.
17 replies
FFilament
Created by foggy on 1/29/2025 in #❓┊help
Newb question: populating table based on query
I found some time at the weekend to read through the above. I'd read it before but didn't connect it with what you were saying. So, yes I get what global scopes are, and how and where they're applied. In the context of Filament tables, I'm confused as to the why though? Is it a form of protection? In other words, if I define a scope such as: class currentOrgScope implements Scope { public function apply(Builder $builder, Model $model): void { $builder->where('organisation', '=', Session::get('currentOrg'); } } And then #[ScopedBy([currentOrgScope::class])] class Widget extends Model { on the model, that will ensure 100% that any results on the widgets table will belong to that organisation (provided of course it has such a column). The desired effect being that I can't erroneously code something that leaks the widgets from all organisations. This should probably be best practice anyway right? Not just Filament table stuff?
17 replies
FFilament
Created by foggy on 1/29/2025 in #❓┊help
Newb question: populating table based on query
Yes, authenticated. May I ask for a bit of an explanation of, or pointers to, what you're talking about here? You're suggesting that I don't put the filter on the table - why? And where should I put it? I'm not sure what you mean by global scopes and parentless models (again, apols for being dumb, learning here!)
17 replies
FFilament
Created by foggy on 1/29/2025 in #❓┊help
Newb question: populating table based on query
->query(User::query()->where('organisation',Session::get('currentOrg')) Thanks! That's the incantation I was looking for! I think I must have tried every other possible incantation of that but somehow missing the correct one! I'll definitely look into awcodes suggestion if that's the better way to do this. THANKS!
17 replies
FFilament
Created by foggy on 1/29/2025 in #❓┊help
Newb question: populating table based on query
Thanks - admittedly, I'm scratching my head here. Looking at your example: ->query(fn() => static::getEloquentQuery()....... I replace my ->query(User::query()) with: ->query(fn() => static::getEloquentQuery()->where('organisation_id', 2) but it borks saying it can't find method getEloquentQuery. I see some other code examples suggesting to add public static function getEloquentQuery(): Builder { return parent::getEloquentQuery(); } which doesn't work and also doesn't make much sense to me, not least because I don't see where I reference the User:: model now? Sorry if I'm being dumb here... I'm just not used to this way of doing things... once I get a working example though, I'll be off to the races!
17 replies
KPCKevin Powell - Community
Created by foggy on 1/5/2024 in #back-end
App statistic recording strategies
Interesting. Thanks guys!
23 replies
KPCKevin Powell - Community
Created by foggy on 1/5/2024 in #back-end
App statistic recording strategies
I think a similar situation might be faced by banks. How do they provide you with your balance on demand? Do they calculate all transactions on your account since forever, or do they maintain a running total somewhere? My needs are nothing like those of a bank (in terms of scale!) but I do want to be as efficient as possible. Good point about frameworks. I'm slowly learning and feeling my way around this thing (loving it so far!)
23 replies
KPCKevin Powell - Community
Created by foggy on 1/5/2024 in #back-end
App statistic recording strategies
thanks - needs are just to store stats like I say so I can produce a graph. I'll look into the Redis thing. Ideally, I'd like to keep it all within the Laravel/mysql realm though. Don't want to introduce extra components if I can avoid it.
23 replies
KPCKevin Powell - Community
Created by foggy on 6/1/2023 in #back-end
POST contents of a listbox
Yes absolutely - and it's a great feeling when the bits you've cobbled together finally work! Sometimes it's good just to get a nudge in the right direction though. I'm not always sure what I'm doing is the 'right' way of doing something!
3 replies
KPCKevin Powell - Community
Created by foggy on 6/1/2023 in #back-end
POST contents of a listbox
thanks - i worked it out in the end. Yes, it would work if I selected the things on the right before sending, but thats not what I want. I used some JS to scan the lists then post the contents to a hidden <input> the value of which was submitted on the POST. All works now and my MySQL db is being populated with the contents of the column on the right, which is what I wanted :).
3 replies
KPCKevin Powell - Community
Created by foggy on 5/17/2023 in #back-end
PHP - What's going on here?
thanks both... !
8 replies
KPCKevin Powell - Community
Created by foggy on 5/17/2023 in #back-end
PHP - What's going on here?
yep makes total sense
8 replies
KPCKevin Powell - Community
Created by foggy on 5/17/2023 in #back-end
PHP - What's going on here?
Got it!! Thanks a lot! Makes sense... (condition) ? true : false ;
8 replies