Laravel PHP:控制器未更新

时间:2014-11-10 16:44:22

标签: php laravel-4

我正在尝试对我的某个控制器进行一些更改,但在保存文件后,更改不会生效,并且无法识别变量。我已经向控制器添加了一些文件,所以我不确定它是否是命名空间问题,或者使用'composer dump-autoload'对它有影响。

OverviewController.php(Controller):

 <?php 

 use controllers\VideosController;

 use app\models\Video;

 use Acme\repositories\VideoRepository;

 /* Added the 3 'Picture' files below */   

 use controllers\PicturesController;

 use app\models\Picture;

 use Acme\repositories\PictureRepository;

 use models\Validators as Validators;

 class OverviewController extends BaseController {

  /* 
  The Video model for the repository
  */
  protected $video;

  /* 
  The Picture model for the repository
  */
  protected $picture;

  /* The layout for the Videos and Pictures Overview */
  protected $layout = 'layouts.master';


 public function __construct(VideoRepository $video)
 {
    $this->video = $video;
 }

/* Added this repository function as well. */

 public function __construct(PictureRepository $picture)
 {
    $this->picture = $picture;
 }

 /* List all the videos and stones
 Included Pagination for neatness */

 public function index()
 {
    $allpicsvids = Video::paginate(10);

    /* Added this variable to this function and it is not being recognized */
    $allpics = Picture::paginate(10);


    $this->layout->content = \View::make('home.pics_vids_overview', array('allpicsvids' => $allpicsvids, 'allpics' =>$allpics));
 }


}

我不知道为什么在保存之后无法识别此控制器的添加内容。我试过运行'php artisan dump-autoload'和'composer dump-autoload',但我仍然不确定为什么会这样。

1 个答案:

答案 0 :(得分:1)

我在这方面挣扎了几个小时,直到我意识到我将变量传递给index.blade.php,但在其中我使用了部分而忘记再次从index.blade传递变量。 php到偏。

因此,基本上,您必须手动传播vars,例如Controller-&gt; View-&gt; Partials。