小编rel*_*ien的帖子

将数据从一个模型加载到另一个模型,空数组.Laravel

我有Post和Category模型.当我创建一个新帖子时,我希望在复选框类别上显示现有视线,但方法all()返回一个数组,表中没有任何数据的表中现有类别数量的大小.

    $categorias = Categoria::all();
    dd($categorias);

    return View::make('posts.nuevo')->with('categorias' => $categorias);
Run Code Online (Sandbox Code Playgroud)

这是dd($ categorias)的内容:

object(Illuminate\Database\Eloquent\Collection)[218]
protected 'items' => 
array (size=7)
  0 => 
    object(Categoria)[209]
      public 'table' => string 'categorias' (length=10)
      public 'timestamps' => boolean false
      protected 'fillable' => 
        array (size=1)
          ...
      protected 'connection' => null
      protected 'primaryKey' => string 'id' (length=2)
      protected 'perPage' => int 15
      public 'incrementing' => boolean true
      protected 'attributes' => 
        array (size=2)
          ...
      protected 'original' => 
        array (size=2)
          ...
      ///// CONTINUE /////
    6 => 
    object(Categoria)[223]
      public 'table' => string 'categorias' …
Run Code Online (Sandbox Code Playgroud)

php arrays model laravel

5
推荐指数
1
解决办法
700
查看次数

标签 统计

arrays ×1

laravel ×1

model ×1

php ×1