Laravel中的形式动作 - php

我的Laravel表格有问题,
所以我的项目结构是:

controllers/
       administration/
            NewsController.php

在NewsController中,我有一个方法调用:postCreate():

 public function postCreate(){
    $validator = Validator::make(Input::all(), \News::$rules);
    if($validator->passes()){
        $news = new \News();
        $news->title = Input::get('title');
        $news->content = Input::get('content');
        $news->author = Input::get('author');
        $news->type = Input::get('type');

        $image = Input::file('file');
        $filename = time().".".$image->getClientOriginalExtension();
        $path = public_path('content/images/' . $filename);
        Image::make($image->getRealPath())->resize(468,249)->save($path);
        $news->image = 'content/images/'.$filename;
        $news->save();

        return Redirect::to('/administration/news/add')
            ->with('message','Succes');
    }
    return Redirect::to('/administration/news/add')
        ->with('message','Error')
        ->withErrors($validator)
        ->withInput();
}

我的表格有动作:

{{ Form::open(array('url'=>'administration/news/create', 'files'=>true)) }}
{{ Form::close() }}

我的路线:

Route::post('/administration/news/create', array('uses'=>'App\Controllers\Administration \NewsController@postCreate'));

但是当我提交我得到一个错误:

Symfony \组件\ HttpKernel \异常\ NotFoundHttpException

我不明白我的问题在哪里。

参考方案

稍作调整...。忘记手动创建地址。

在routes.php中:

Route::post('/administration/news/create', 
          array('uses'=>'App\Controllers\Administration\NewsController@postCreate',
                 'as' => 'news.post.create'));

在视图中:

{{ Form::open(array('url'=>route('news.post.create'), 'files'=>true)) }}

无需记住任何这些地址。

检查对象是否已在集合中-Laravel - php

当我循环一系列不同的结果时,我希望将对象添加到新集合中。查询:$osRed = Item::where('category', 'Hardware') ->where(function ($query) { $query->where('operating_system', '…

Laravel-foreach局部变量正在覆盖全局变量 - php

今天,我面临一个非常奇怪的问题。我有一个控制器,将从该控制器向视图sections thread和threads发送三个变量。在我看来,我正在使用foreach循环遍历所有部分,如下所示:@foreach($sections as $i => $section) 对于每个部分,我都将创建一个div并给出如下的ID:id="{{ $thread…

PHP Laravel从另一个驱动器读取文件 - php

我目前正在学习Laravel。我想知道是否有一种方法可以在Laravel中使用Storage::从另一个硬盘访问文件(使用Windows)。例如,我在驱动器C:上安装了带有Laravel的Xampp,但是我想访问网站目录之外的E:上的文件。我试过使用Storage::files('E:')和File::files('E:…

Laravel迁移外键 - php

我正在尝试在Laravel中建立一些关系,我对关系和迁移有些困惑。这是我正在做的一个简单示例:Users -> has_many -> Cats 因此,我的用户迁移文件与Cats的关系如下:$table->foreign('cats_id')->references('id')->on(&…

Laravel-使用雄辩的语言在开始日期和结束日期之间选择行 - php

我想将此查询转换为雄辩的laravel,select * from schedule where (now() between start_date and end_date); 我尝试使用whereBetween,但是出现了一些错误。$schedule = Schedule::whereBetween(Carbon::now(), ['start…