If you create a property in the Resource class to reuse it in methods, make it STATIC.
Both form() and table() methods are static, so if you use something like $this->options, it will throw an error.
Create a static property and then use it as self::$options
class ProductResource extends Resource{ protected array $options; protected static array $staticOptions; public static function form(Form $form): Form { $options = $this->options; // will throw error $options = self::$staticOptions; // this will works } public static function table(Table $table): Table { $options = $this->options; // will throw error $options = self::$staticOptions; // this will works }}
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses
[NEW] Building a Typical Laravel SaaS
8 lessons
1 h 07 min
Laravel Coding with AI Agents: Cursor, Claude Code, Codex
5 lessons
1 h 01 min
Laravel HTTP Client and 3rd-Party APIs
7 lessons
50 min