Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Post
- subject
- body
- source_id
- status_id
- Status
- id
- label
- other_field
- Source
- id
- label
- other_field
- View
- create view read_only_posts as
- SELECT statuses.label as status, sources.label as source, posts.*
- from posts
- left join statuses on statuses.id = posts.status_id
- left join sources on sources.id = posts.source_id
- // Post.php
- class Post extends Model
- {
- //
- }
- // ReadOnlyPost.php
- class ReadOnlyPost extends Post
- {
- protected $table = 'read_only_posts';
- }
- // Post.php Model
- public function tags()
- {
- return $this->morphToMany(Tag::class, 'taggable');
- }
- // AppServiceProvider
- public function boot()
- {
- Relation::morphMap([
- 'properties' => Post::class,
- 'properties' => ReadOnlyPost::class, <--- Can't do this
Add Comment
Please, Sign In to add comment