Laravel belongsTo and hasMany not returning data












1















I'm new to laravel/eloquent and so far very much enjoying them, but I'm having trouble getting belongsTo and hasMany working.
I've read through countless issues others have had and haven't found a solution that solves it for me.



I have a "Page" model and a "Category" model. Here is the definition for the tables:



Schema::create('pages', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});

Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->integer('page_id');
$table->foreign('page_id')->references('id')->on('pages');
$table->string('name');
$table->timestamps();
});


Here is my Page model:



namespace App;

use IlluminateDatabaseEloquentModel;

class Page extends Model
{
public function categories()
{
return $this->hasMany('AppCategory');
}
}


Here is my Category model:



namespace App;

use IlluminateDatabaseEloquentModel;

class Category extends Model
{
public function page()
{
return $this->belongsTo('AppPage');
}
}


Here are the results from some tinkering:



> php artisan cache:clear
Application cache cleared!
> php artisan tinker
>>> AppCategory::find(1)
=> AppCategory {#2916
id: "1",
page_id: "1",
name: "First Category",
created_at: "2018-12-30 03:18:07.347",
updated_at: "2018-12-30 03:18:07.347",
}
>>> AppCategory::find(1)->page()
=> IlluminateDatabaseEloquentRelationsBelongsTo {#2918}
>>> AppPage::find(1)
=> AppPage {#2902
id: "1",
name: "First Page",
created_at: "2018-12-30 03:18:07.220",
updated_at: "2018-12-30 03:18:07.220",
}
>>> AppPage::find(1)->categories()
=> IlluminateDatabaseEloquentRelationsHasMany {#2922}
>>>


I'm getting my objects just fine, but when I try to pull the relationship I'm just getting what seem like null objects:



=> IlluminateDatabaseEloquentRelationsBelongsTo {#2918}



=> IlluminateDatabaseEloquentRelationsHasMany {#2922}



If I swap out my page() and categories() functions for ones like these all works well:



public function page() 
{
return AppPage::find($this->page_id);
}

public function categories()
{
return AppCategory::where('page_id', $this->id)->get();
}


Here are those results:



> php artisan cache:clear
Application cache cleared!
> php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> AppPage::find(1)
=> AppPage {#2916
id: "1",
name: "First Page",
created_at: "2018-12-30 03:18:07.220",
updated_at: "2018-12-30 03:18:07.220",
}
>>> AppPage::find(1)->categories()
=> IlluminateDatabaseEloquentCollection {#2918
all: [
AppCategory {#2921
id: "1",
page_id: "1",
name: "First Category",
created_at: "2018-12-30 03:18:07.347",
updated_at: "2018-12-30 03:18:07.347",
},
AppCategory {#2922
id: "2",
page_id: "1",
name: "Second Category",
created_at: "2018-12-30 03:18:07.480",
updated_at: "2018-12-30 03:18:07.480",
},
AppCategory {#2923
id: "3",
page_id: "1",
name: "Third Category",
created_at: "2018-12-30 03:18:07.623",
updated_at: "2018-12-30 03:18:07.623",
},
],
}
>>> AppCategory::find(1)
=> AppCategory {#2904
id: "1",
page_id: "1",
name: "First Category",
created_at: "2018-12-30 03:18:07.347",
updated_at: "2018-12-30 03:18:07.347",
}
>>> AppCategory::find(1)->page()
=> AppPage {#2921
id: "1",
name: "First Page",
created_at: "2018-12-30 03:18:07.220",
updated_at: "2018-12-30 03:18:07.220",
}
>>>


EDIT:



I found if I add ->get() I see the data while tinkering as I was expecting:



public function page() 
{
return $this->belongsTo('AppPage')->get();
}


However, none of the examples I've seen show anyone doing this. Am I just misunderstanding how this is supposed to work? I would expect while tinkering just doing $page->categories(); would give me the categories without needing to do $page->categories()->get();










share|improve this question





























    1















    I'm new to laravel/eloquent and so far very much enjoying them, but I'm having trouble getting belongsTo and hasMany working.
    I've read through countless issues others have had and haven't found a solution that solves it for me.



    I have a "Page" model and a "Category" model. Here is the definition for the tables:



    Schema::create('pages', function (Blueprint $table) {
    $table->increments('id');
    $table->string('name');
    $table->timestamps();
    });

    Schema::create('categories', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('page_id');
    $table->foreign('page_id')->references('id')->on('pages');
    $table->string('name');
    $table->timestamps();
    });


    Here is my Page model:



    namespace App;

    use IlluminateDatabaseEloquentModel;

    class Page extends Model
    {
    public function categories()
    {
    return $this->hasMany('AppCategory');
    }
    }


    Here is my Category model:



    namespace App;

    use IlluminateDatabaseEloquentModel;

    class Category extends Model
    {
    public function page()
    {
    return $this->belongsTo('AppPage');
    }
    }


    Here are the results from some tinkering:



    > php artisan cache:clear
    Application cache cleared!
    > php artisan tinker
    >>> AppCategory::find(1)
    => AppCategory {#2916
    id: "1",
    page_id: "1",
    name: "First Category",
    created_at: "2018-12-30 03:18:07.347",
    updated_at: "2018-12-30 03:18:07.347",
    }
    >>> AppCategory::find(1)->page()
    => IlluminateDatabaseEloquentRelationsBelongsTo {#2918}
    >>> AppPage::find(1)
    => AppPage {#2902
    id: "1",
    name: "First Page",
    created_at: "2018-12-30 03:18:07.220",
    updated_at: "2018-12-30 03:18:07.220",
    }
    >>> AppPage::find(1)->categories()
    => IlluminateDatabaseEloquentRelationsHasMany {#2922}
    >>>


    I'm getting my objects just fine, but when I try to pull the relationship I'm just getting what seem like null objects:



    => IlluminateDatabaseEloquentRelationsBelongsTo {#2918}



    => IlluminateDatabaseEloquentRelationsHasMany {#2922}



    If I swap out my page() and categories() functions for ones like these all works well:



    public function page() 
    {
    return AppPage::find($this->page_id);
    }

    public function categories()
    {
    return AppCategory::where('page_id', $this->id)->get();
    }


    Here are those results:



    > php artisan cache:clear
    Application cache cleared!
    > php artisan tinker
    Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
    >>> AppPage::find(1)
    => AppPage {#2916
    id: "1",
    name: "First Page",
    created_at: "2018-12-30 03:18:07.220",
    updated_at: "2018-12-30 03:18:07.220",
    }
    >>> AppPage::find(1)->categories()
    => IlluminateDatabaseEloquentCollection {#2918
    all: [
    AppCategory {#2921
    id: "1",
    page_id: "1",
    name: "First Category",
    created_at: "2018-12-30 03:18:07.347",
    updated_at: "2018-12-30 03:18:07.347",
    },
    AppCategory {#2922
    id: "2",
    page_id: "1",
    name: "Second Category",
    created_at: "2018-12-30 03:18:07.480",
    updated_at: "2018-12-30 03:18:07.480",
    },
    AppCategory {#2923
    id: "3",
    page_id: "1",
    name: "Third Category",
    created_at: "2018-12-30 03:18:07.623",
    updated_at: "2018-12-30 03:18:07.623",
    },
    ],
    }
    >>> AppCategory::find(1)
    => AppCategory {#2904
    id: "1",
    page_id: "1",
    name: "First Category",
    created_at: "2018-12-30 03:18:07.347",
    updated_at: "2018-12-30 03:18:07.347",
    }
    >>> AppCategory::find(1)->page()
    => AppPage {#2921
    id: "1",
    name: "First Page",
    created_at: "2018-12-30 03:18:07.220",
    updated_at: "2018-12-30 03:18:07.220",
    }
    >>>


    EDIT:



    I found if I add ->get() I see the data while tinkering as I was expecting:



    public function page() 
    {
    return $this->belongsTo('AppPage')->get();
    }


    However, none of the examples I've seen show anyone doing this. Am I just misunderstanding how this is supposed to work? I would expect while tinkering just doing $page->categories(); would give me the categories without needing to do $page->categories()->get();










    share|improve this question



























      1












      1








      1








      I'm new to laravel/eloquent and so far very much enjoying them, but I'm having trouble getting belongsTo and hasMany working.
      I've read through countless issues others have had and haven't found a solution that solves it for me.



      I have a "Page" model and a "Category" model. Here is the definition for the tables:



      Schema::create('pages', function (Blueprint $table) {
      $table->increments('id');
      $table->string('name');
      $table->timestamps();
      });

      Schema::create('categories', function (Blueprint $table) {
      $table->increments('id');
      $table->integer('page_id');
      $table->foreign('page_id')->references('id')->on('pages');
      $table->string('name');
      $table->timestamps();
      });


      Here is my Page model:



      namespace App;

      use IlluminateDatabaseEloquentModel;

      class Page extends Model
      {
      public function categories()
      {
      return $this->hasMany('AppCategory');
      }
      }


      Here is my Category model:



      namespace App;

      use IlluminateDatabaseEloquentModel;

      class Category extends Model
      {
      public function page()
      {
      return $this->belongsTo('AppPage');
      }
      }


      Here are the results from some tinkering:



      > php artisan cache:clear
      Application cache cleared!
      > php artisan tinker
      >>> AppCategory::find(1)
      => AppCategory {#2916
      id: "1",
      page_id: "1",
      name: "First Category",
      created_at: "2018-12-30 03:18:07.347",
      updated_at: "2018-12-30 03:18:07.347",
      }
      >>> AppCategory::find(1)->page()
      => IlluminateDatabaseEloquentRelationsBelongsTo {#2918}
      >>> AppPage::find(1)
      => AppPage {#2902
      id: "1",
      name: "First Page",
      created_at: "2018-12-30 03:18:07.220",
      updated_at: "2018-12-30 03:18:07.220",
      }
      >>> AppPage::find(1)->categories()
      => IlluminateDatabaseEloquentRelationsHasMany {#2922}
      >>>


      I'm getting my objects just fine, but when I try to pull the relationship I'm just getting what seem like null objects:



      => IlluminateDatabaseEloquentRelationsBelongsTo {#2918}



      => IlluminateDatabaseEloquentRelationsHasMany {#2922}



      If I swap out my page() and categories() functions for ones like these all works well:



      public function page() 
      {
      return AppPage::find($this->page_id);
      }

      public function categories()
      {
      return AppCategory::where('page_id', $this->id)->get();
      }


      Here are those results:



      > php artisan cache:clear
      Application cache cleared!
      > php artisan tinker
      Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
      >>> AppPage::find(1)
      => AppPage {#2916
      id: "1",
      name: "First Page",
      created_at: "2018-12-30 03:18:07.220",
      updated_at: "2018-12-30 03:18:07.220",
      }
      >>> AppPage::find(1)->categories()
      => IlluminateDatabaseEloquentCollection {#2918
      all: [
      AppCategory {#2921
      id: "1",
      page_id: "1",
      name: "First Category",
      created_at: "2018-12-30 03:18:07.347",
      updated_at: "2018-12-30 03:18:07.347",
      },
      AppCategory {#2922
      id: "2",
      page_id: "1",
      name: "Second Category",
      created_at: "2018-12-30 03:18:07.480",
      updated_at: "2018-12-30 03:18:07.480",
      },
      AppCategory {#2923
      id: "3",
      page_id: "1",
      name: "Third Category",
      created_at: "2018-12-30 03:18:07.623",
      updated_at: "2018-12-30 03:18:07.623",
      },
      ],
      }
      >>> AppCategory::find(1)
      => AppCategory {#2904
      id: "1",
      page_id: "1",
      name: "First Category",
      created_at: "2018-12-30 03:18:07.347",
      updated_at: "2018-12-30 03:18:07.347",
      }
      >>> AppCategory::find(1)->page()
      => AppPage {#2921
      id: "1",
      name: "First Page",
      created_at: "2018-12-30 03:18:07.220",
      updated_at: "2018-12-30 03:18:07.220",
      }
      >>>


      EDIT:



      I found if I add ->get() I see the data while tinkering as I was expecting:



      public function page() 
      {
      return $this->belongsTo('AppPage')->get();
      }


      However, none of the examples I've seen show anyone doing this. Am I just misunderstanding how this is supposed to work? I would expect while tinkering just doing $page->categories(); would give me the categories without needing to do $page->categories()->get();










      share|improve this question
















      I'm new to laravel/eloquent and so far very much enjoying them, but I'm having trouble getting belongsTo and hasMany working.
      I've read through countless issues others have had and haven't found a solution that solves it for me.



      I have a "Page" model and a "Category" model. Here is the definition for the tables:



      Schema::create('pages', function (Blueprint $table) {
      $table->increments('id');
      $table->string('name');
      $table->timestamps();
      });

      Schema::create('categories', function (Blueprint $table) {
      $table->increments('id');
      $table->integer('page_id');
      $table->foreign('page_id')->references('id')->on('pages');
      $table->string('name');
      $table->timestamps();
      });


      Here is my Page model:



      namespace App;

      use IlluminateDatabaseEloquentModel;

      class Page extends Model
      {
      public function categories()
      {
      return $this->hasMany('AppCategory');
      }
      }


      Here is my Category model:



      namespace App;

      use IlluminateDatabaseEloquentModel;

      class Category extends Model
      {
      public function page()
      {
      return $this->belongsTo('AppPage');
      }
      }


      Here are the results from some tinkering:



      > php artisan cache:clear
      Application cache cleared!
      > php artisan tinker
      >>> AppCategory::find(1)
      => AppCategory {#2916
      id: "1",
      page_id: "1",
      name: "First Category",
      created_at: "2018-12-30 03:18:07.347",
      updated_at: "2018-12-30 03:18:07.347",
      }
      >>> AppCategory::find(1)->page()
      => IlluminateDatabaseEloquentRelationsBelongsTo {#2918}
      >>> AppPage::find(1)
      => AppPage {#2902
      id: "1",
      name: "First Page",
      created_at: "2018-12-30 03:18:07.220",
      updated_at: "2018-12-30 03:18:07.220",
      }
      >>> AppPage::find(1)->categories()
      => IlluminateDatabaseEloquentRelationsHasMany {#2922}
      >>>


      I'm getting my objects just fine, but when I try to pull the relationship I'm just getting what seem like null objects:



      => IlluminateDatabaseEloquentRelationsBelongsTo {#2918}



      => IlluminateDatabaseEloquentRelationsHasMany {#2922}



      If I swap out my page() and categories() functions for ones like these all works well:



      public function page() 
      {
      return AppPage::find($this->page_id);
      }

      public function categories()
      {
      return AppCategory::where('page_id', $this->id)->get();
      }


      Here are those results:



      > php artisan cache:clear
      Application cache cleared!
      > php artisan tinker
      Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
      >>> AppPage::find(1)
      => AppPage {#2916
      id: "1",
      name: "First Page",
      created_at: "2018-12-30 03:18:07.220",
      updated_at: "2018-12-30 03:18:07.220",
      }
      >>> AppPage::find(1)->categories()
      => IlluminateDatabaseEloquentCollection {#2918
      all: [
      AppCategory {#2921
      id: "1",
      page_id: "1",
      name: "First Category",
      created_at: "2018-12-30 03:18:07.347",
      updated_at: "2018-12-30 03:18:07.347",
      },
      AppCategory {#2922
      id: "2",
      page_id: "1",
      name: "Second Category",
      created_at: "2018-12-30 03:18:07.480",
      updated_at: "2018-12-30 03:18:07.480",
      },
      AppCategory {#2923
      id: "3",
      page_id: "1",
      name: "Third Category",
      created_at: "2018-12-30 03:18:07.623",
      updated_at: "2018-12-30 03:18:07.623",
      },
      ],
      }
      >>> AppCategory::find(1)
      => AppCategory {#2904
      id: "1",
      page_id: "1",
      name: "First Category",
      created_at: "2018-12-30 03:18:07.347",
      updated_at: "2018-12-30 03:18:07.347",
      }
      >>> AppCategory::find(1)->page()
      => AppPage {#2921
      id: "1",
      name: "First Page",
      created_at: "2018-12-30 03:18:07.220",
      updated_at: "2018-12-30 03:18:07.220",
      }
      >>>


      EDIT:



      I found if I add ->get() I see the data while tinkering as I was expecting:



      public function page() 
      {
      return $this->belongsTo('AppPage')->get();
      }


      However, none of the examples I've seen show anyone doing this. Am I just misunderstanding how this is supposed to work? I would expect while tinkering just doing $page->categories(); would give me the categories without needing to do $page->categories()->get();







      php laravel laravel-5.7






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 30 '18 at 4:07







      Eilert Hjelmeseth

















      asked Dec 30 '18 at 3:58









      Eilert HjelmesethEilert Hjelmeseth

      35819




      35819
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Try this.



              Schema::create('categories', function (Blueprint $table) {
          $table->increments('id');
          $table->integer('page_id')->unsigned();
          $table->foreign('page_id')->references('id')->on('pages');
          $table->string('name');
          $table->timestamps();
          });





          share|improve this answer
























          • Unfortunately that did not help. Thanks for the suggestion, though! For clarity, is the only thing you changed adding ->unsigned() to page_id?

            – Eilert Hjelmeseth
            Dec 30 '18 at 4:09



















          0














          Ah, as usual I found this to be a simple fix.



          Calling $page->categories as a property gives me the data



          Calling $page->categories() as a function returns an object I can continue chaining further commands to.



          In case it helps anyone, I found the solution by revisiting the extremely helpful laracasts videos. Specifically the episode on eloquent relationships where what I just posted is clearly explained:
          https://laracasts.com/series/laravel-from-scratch-2018/episodes/16






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53975170%2flaravel-belongsto-and-hasmany-not-returning-data%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Try this.



                Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('page_id')->unsigned();
            $table->foreign('page_id')->references('id')->on('pages');
            $table->string('name');
            $table->timestamps();
            });





            share|improve this answer
























            • Unfortunately that did not help. Thanks for the suggestion, though! For clarity, is the only thing you changed adding ->unsigned() to page_id?

              – Eilert Hjelmeseth
              Dec 30 '18 at 4:09
















            0














            Try this.



                Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('page_id')->unsigned();
            $table->foreign('page_id')->references('id')->on('pages');
            $table->string('name');
            $table->timestamps();
            });





            share|improve this answer
























            • Unfortunately that did not help. Thanks for the suggestion, though! For clarity, is the only thing you changed adding ->unsigned() to page_id?

              – Eilert Hjelmeseth
              Dec 30 '18 at 4:09














            0












            0








            0







            Try this.



                Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('page_id')->unsigned();
            $table->foreign('page_id')->references('id')->on('pages');
            $table->string('name');
            $table->timestamps();
            });





            share|improve this answer













            Try this.



                Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('page_id')->unsigned();
            $table->foreign('page_id')->references('id')->on('pages');
            $table->string('name');
            $table->timestamps();
            });






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 30 '18 at 4:02









            reirei

            2216




            2216













            • Unfortunately that did not help. Thanks for the suggestion, though! For clarity, is the only thing you changed adding ->unsigned() to page_id?

              – Eilert Hjelmeseth
              Dec 30 '18 at 4:09



















            • Unfortunately that did not help. Thanks for the suggestion, though! For clarity, is the only thing you changed adding ->unsigned() to page_id?

              – Eilert Hjelmeseth
              Dec 30 '18 at 4:09

















            Unfortunately that did not help. Thanks for the suggestion, though! For clarity, is the only thing you changed adding ->unsigned() to page_id?

            – Eilert Hjelmeseth
            Dec 30 '18 at 4:09





            Unfortunately that did not help. Thanks for the suggestion, though! For clarity, is the only thing you changed adding ->unsigned() to page_id?

            – Eilert Hjelmeseth
            Dec 30 '18 at 4:09













            0














            Ah, as usual I found this to be a simple fix.



            Calling $page->categories as a property gives me the data



            Calling $page->categories() as a function returns an object I can continue chaining further commands to.



            In case it helps anyone, I found the solution by revisiting the extremely helpful laracasts videos. Specifically the episode on eloquent relationships where what I just posted is clearly explained:
            https://laracasts.com/series/laravel-from-scratch-2018/episodes/16






            share|improve this answer




























              0














              Ah, as usual I found this to be a simple fix.



              Calling $page->categories as a property gives me the data



              Calling $page->categories() as a function returns an object I can continue chaining further commands to.



              In case it helps anyone, I found the solution by revisiting the extremely helpful laracasts videos. Specifically the episode on eloquent relationships where what I just posted is clearly explained:
              https://laracasts.com/series/laravel-from-scratch-2018/episodes/16






              share|improve this answer


























                0












                0








                0







                Ah, as usual I found this to be a simple fix.



                Calling $page->categories as a property gives me the data



                Calling $page->categories() as a function returns an object I can continue chaining further commands to.



                In case it helps anyone, I found the solution by revisiting the extremely helpful laracasts videos. Specifically the episode on eloquent relationships where what I just posted is clearly explained:
                https://laracasts.com/series/laravel-from-scratch-2018/episodes/16






                share|improve this answer













                Ah, as usual I found this to be a simple fix.



                Calling $page->categories as a property gives me the data



                Calling $page->categories() as a function returns an object I can continue chaining further commands to.



                In case it helps anyone, I found the solution by revisiting the extremely helpful laracasts videos. Specifically the episode on eloquent relationships where what I just posted is clearly explained:
                https://laracasts.com/series/laravel-from-scratch-2018/episodes/16







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 30 '18 at 4:15









                Eilert HjelmesethEilert Hjelmeseth

                35819




                35819






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53975170%2flaravel-belongsto-and-hasmany-not-returning-data%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Mossoró

                    Error while reading .h5 file using the rhdf5 package in R

                    Pushsharp Apns notification error: 'InvalidToken'