Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Models
fluttersdk/magic-starter-laravel
cursor
eloquent
models
traits
uuids
relations
pivot
notifications

Models & Traits

Install
php artisan boost:add-skill fluttersdk/magic-starter-laravel

Save this content to: .cursor/rules/models.md

# Models & Traits

## Models

- Apply `ConditionallyUsesUuids` trait on every model (runtime UUID/integer PK switching)
- PHPDoc `@property` for every column, `@property-read` for accessors and computed attributes
- Type relations explicitly: `BelongsTo<User, $this>`, `HasMany<Team, $this>`, `BelongsToMany<User, $this>`
- Use `casts()` method (Laravel 11+ syntax), not `$casts` property
- Resolve related models dynamically: `MagicStarter::userModel()` in relation definitions
- BelongsToMany pivot: always chain `->using(MagicStarter::membershipModel())` and `->withPivot('role')`
- No soft deletes in `src/Models` — use `cascadeOnDelete()` on foreign keys instead. The one opt-in exception is the published Team stub (`stubs/models/Team.php`), which uses `SoftDeletes` for the restorable team delete (`Features::restorableTeams()`); the shipped `Team` model must stay free of the trait so a consumer without the `deleted_at` column keeps working
- `$fillable` array for mass assignment, not `$guarded`

## Traits

- Defensive: `method_exists($this, 'method')` before calling methods from other optional traits
- Return typed morphMany/morphTo: `MorphMany<NotificationSetting, $this>`
- HasProfilePhoto: `null` when no photo is stored; the client draws its own initials, never a generated third-party image
- HasNotifications: `prefers()` returns true by default if notification type not in registry
- HasNotifications: `routeNotificationForOneSignal()` returns `['external_id' => ['user_'.$this->getKey()]]` for OneSignal v5 alias targeting; channel driver is `FlutterSdk\MagicStarter\Notifications\Channels\OneSignalChannel`

Models & Traits

Models

  • Apply ConditionallyUsesUuids trait on every model (runtime UUID/integer PK switching)
  • PHPDoc @property for every column, @property-read for accessors and computed attributes
  • Type relations explicitly: BelongsTo<User, $this>, HasMany<Team, $this>, BelongsToMany<User, $this>
  • Use casts() method (Laravel 11+ syntax), not $casts property
  • Resolve related models dynamically: MagicStarter::userModel() in relation definitions
  • BelongsToMany pivot: always chain ->using(MagicStarter::membershipModel()) and ->withPivot('role')
  • No soft deletes in src/Models — use cascadeOnDelete() on foreign keys instead. The one opt-in exception is the published Team stub (stubs/models/Team.php), which uses SoftDeletes for the restorable team delete (Features::restorableTeams()); the shipped Team model must stay free of the trait so a consumer without the deleted_at column keeps working
  • $fillable array for mass assignment, not $guarded

Traits

  • Defensive: method_exists($this, 'method') before calling methods from other optional traits
  • Return typed morphMany/morphTo: MorphMany<NotificationSetting, $this>
  • HasProfilePhoto: null when no photo is stored; the client draws its own initials, never a generated third-party image
  • HasNotifications: prefers() returns true by default if notification type not in registry
  • HasNotifications: routeNotificationForOneSignal() returns ['external_id' => ['user_'.$this->getKey()]] for OneSignal v5 alias targeting; channel driver is FlutterSdk\MagicStarter\Notifications\Channels\OneSignalChannel
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels