dongliulu1122 2014-10-27 14:34
浏览 40
已采纳

Laravel PHP 4:修改控制器导致'从空值创建默认对象'问题

I'm trying to modify a controller from a third-party package by having it be used locally instead of from the package source. When it is used from the package source, everything runs fine but when I use it locally, I keep getting a 'Creating default object from empty value' error.

Controller:

use JeroenG\LaravelPhotoGallery\Controllers\AlbumsController; /* Third party controller */

use JeroenG\LaravelPhotoGallery\Controllers\PhotosController; /* Third party controller */

use JeroenG\LaravelPhotoGallery\Validators as Validators; /* Third party validator */

class GalleryController extends BaseController {


/* The album model @var \JeroenG\LaravelPhotoGallery\Models\Album */
protected $album;

/*The photo model @var \JeroenG\LaravelPhotoGallery\Models\Photo */

protected $photo;

/* Instantiate the controller 
 * @param \JeroenG\LaravelPhotoGallery\Models\Album $album
 * @param \JeroenG\LaravelPhotoGallery\Models\Photo $photo
 * @return void
*/

public function __construct()
{
    $this->album = \App::make('Repositories\AlbumRepository');
    $this->photo = \App::make('Repositories\PhotoRepository');
}

/*Listing all albums * @return \Illuminate\View\View */

  public function index()
  {
    $allAlbums = $this->album->all();
    /* Error occurs at line of code below */
    $this->layout->content = \View::make('gallery::index', array('allAlbums' => $allAlbums));
  }
}   

Since I am referencing the third-party controllers above with the 'use' statements at the beginning of the controller, I don't understand why I keep getting this error.

  • 写回答

1条回答 默认 最新

  • dougan1884 2014-10-27 15:40
    关注

    Not sure if this helps. But my suspicion lies on two questions:

    1. whether gallery::index exists or lies in the correct path
    2. you may dd($allAlbums ) to let us know more possible info.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 5037端口被adb自己占了
  • ¥15 Error in check.length("fill") : 'gpar'成分'fill'的长度不能为零
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误