1<?php
2
3namespace App;
4
5use Illuminate\Database\Eloquent\Model;
6
7class Image extends Model
8{
9 /**
10 * Get the owning imageable model.
11 */
12 public function imageable()
13 {
14 return $this->morphTo();
15 }
16}
17
18class Post extends Model
19{
20 /**
21 * Get the post's image.
22 */
23 public function image()
24 {
25 return $this->morphOne('App\Image', 'imageable');
26 }
27}
28
29class User extends Model
30{
31 /**
32 * Get the user's image.
33 */
34 public function image()
35 {
36 return $this->morphOne('App\Image', 'imageable');
37 }
38}