laravel polymorphic model

Solutions on MaxInterview for laravel polymorphic model by the best coders in the world

showing results for - "laravel polymorphic model"
Alex
22 Jul 2016
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}
queries leading to this page
polymorphic relationship laravel tutoriallaravel with polymorphicpolymorphisam relation in laravelpolymorphic laravelpolymorphic relationship laravellaravel polymorphic relations examplelaravel create model and polymorphic modelcreate polymorphic laravellaravel polymorphic modellaravel polymorphic both way relationshiplaravel relationshiplaravel eloquent user postswhat morph relationships in laravellaravel polimorphic relationlaravel polymorphic one to one polymorphicpolymorphic laravel withwhen to use polymorphic relationship laravellaravel morph relation examplelaravel polymorphic addlaravel polymorphic wherelaravel polymorphic relation shiplaravel poly morphic relationshiptutorial polymorphic laravel 6 24this morphto 28 29 laravel migrationlaravel morphmany examplelaravel morph tablepolymorphic laravel examplehow to update morph associations laravellaravel polymorphic ablelaravel morph examplelaravel polymorphic belongs tolaravel polymorphiceloquent polymorphic exampleslaravel where polymorphicpolymorphic relationships in laravelpolymorphism laravelget model with polymorphic with laravellaravel polymorphic relationship query tutoriallaravel polymorphic relationshiphow to store data for polymorphic relationship in laravel tutoriallaravel implement polymorphism in modellaravel polymorphic examplelaravel eloquent polymorphiclaravel polymorphic relationlaravel relation belongtomanythroughlaravel how to determine what model polymorphic relates tolaravel get morph get typescreate data in polymorphic model laravel morph laravel examplepolymorphic table laravelwhat is a polymorphic in laravellaravel morph relationmorphmany relationships in laravellaravel polymorphic get modelpolymorphism example in laravellaravel polymorphic createeloquent laravel many to many mappinglaravel polymorphismhow to get relation name in relation in relation in laravelbelongs to through morphed laravellaravel polymorphic model