Laravel post 有鼻涕虫

Laravel post with slug

我想执行一个 post 方法,但这似乎不起作用...

所以我现在 URL localhost/newthread/5.

没关系,但现在我想让 5(slug)可以 posted。

我该怎么做?

查看:

@include('globs.header')

<div class="panel-group col-sm-offset-1 col-sm-10">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title">Nieuw topic maken</h3>
      </div>
      <div class="panel-body">
        <!-- Start Form -->
        {{ Form::open(array('url' => 'PostTopic')) }}
          <div class="form-group">
            <label>Topic Naam (onderwerp):</label>
            <input type="text" class="form-control" name="title">
          </div>

            <label>Bericht:</label>
            <textarea name="message" class="form-control" rows="5" placeholder="Typ uw bericht..."></textarea>

            <br>
          <button type="submit" class="btn btn-success">Nieuw topic plaatsen</button>

        {{ Form::close() }}
      </div>
    </div>
</div><!-- End page content -->

@include('globs.footer')

控制器:

public function PostTopic()
    {
        //Get all the data and store it inside Store Variable

        $data = Input::all();

        // Make's messages of faults
        $messages = array(
           'title.required'     => 'U moet een titel opgeven!',
           'message.required'   => 'u moet een bericht opgeven!',
           'spamprt'            => 'honeypot', //spam protection
           'time'               => 'required|honeytime:60'
        );

        $rules = array(
            'title' => 'required',
            'message' => 'required'
            );

        $validator = Validator::make($data, $rules, $messages);

        //process the storage
        if ($validator->fails())
        {
            return Redirect::back()->with('errors', $validator->errors())->withInput();
        }else{

            //store
            $thread                     = new Thread;
            $thread->cid                = Input::get('cid');
            $thread->title              = Input::get('title');
            $thread->message            = Input::get('message');
            $thread->prefix             = 0;
            $thread->uid                = Auth::id();
            $thread->username           = Auth::user()->username;
            $thread->date_posted        = Carbon\Carbon::now();
            $thread->save();
            Session::put('_token', sha1(microtime()));
            //redirect
            return Redirect::back()->with('message', 'Uw bericht is succesvol geplaatst!');
            }
    }

路线:

Route::group(array('before' => 'auth'), function()
{
    Route::get('/newthread/{cid}', array('uses' => 'ForumController@CreateTopic', 'as' => 'Nieuw topic'));
});
Route::post('/PostTopic', array('uses' => 'ForumController@PostTopic', 'as' => 'Post_topic'));

奇怪,隐藏输入是我做不到的。因为正如你在我看来所看到的,它只是一种观点。我应该如何解决这个问题?

尝试使用post{cid}作为查询参数

public function CreateTopic($cid)
    {
        $data['cid']=$cid;
        return View::make('sayfa.createtopic',$data);
    }

部分视图:

{{ Form::open(array('url' => 'PostTopic/'.$cid)) }}
                <div class="form-group">
                    <label>Topic Naam (onderwerp):</label>
                    <input type="text" class="form-control" name="title">
                </div>

                <label>Bericht:</label>
                <textarea name="message" class="form-control" rows="5" placeholder="Typ uw bericht..."></textarea>

                <br>
                <button type="submit" class="btn btn-success">Nieuw topic plaatsen</button>

                {{ Form::close() }}

路线:

Route::post('/PostTopic/{cid}', array('uses' => 'SOController@PostTopic', 'as' => 'Post_topic'));

Post方法:

public function PostTopic($cid){
       //you can now have $cid with other inputs
    }