© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
Renzo

Table Data Visibility

I created a dispatch system in Laravel Filament where users can assign Workorders to Vendors. I get all my Vendors from my User model which has a 'role' of 'Vendor'. I've also set up a relationship between my User and Workorder model.

Currently, all Workorders can be seen by the Vendors even if that WO is not assigned to them. I want to add a function where 'Vendors' can only see the Workorder that was assigned to them.

Here's what I did which is throwing me an error of: Cannot use "::class" on value of type null

public static function table(Table $table): Table
{
return $table
->query(function (Builder $query) {
// Base query that fetches all work orders
$baseQuery = $query->select('*')->from('workorders');

// If user is a Vendor, modify the base query to only include their work orders
if (Auth::user()->hasRole('Vendor')) {
return $baseQuery->where('user_id', Auth::id());
}

// Otherwise, return the base query
return $baseQuery;
})
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

table column visibility base on record
FilamentFFilament / ❓┊help
3y ago
Table data aggregation
FilamentFFilament / ❓┊help
2y ago
S3 visibility
FilamentFFilament / ❓┊help
3y ago
Panels visibility
FilamentFFilament / ❓┊help
3y ago