0

我正在使用 Laravel 构建一个简单的电影管理系统。

当用户在我的数据库中创建电影时,我使用以下内容

public function store()
{
    $input = Input::except('_token');
    $id = Helpers::loggedInUser()->id;
    $input['creator_id'] = $id;
    $this->title->create($input);
    return Redirect::back()->withSuccess( trans('main.created successfully') );
}

这成功地传递了用户 id 并在其中存储了 creator_id 字段

我想限制用户编辑他们没有创建的电影。 所以在编辑功能中我有

public function edit($title)
{
    $title = $this->title->byURi( e($title) );      
    $id = Helpers::loggedInUser()->id;
    $titleuser=$title['creator_id'];        
    if ( $titleuser = $id )
    {
        return View::make('Titles.Edit')->withTitle($title)->withType('movies');
    }

}

但是,这似乎不起作用。movie.edit在我的哨兵用户 db 中拥有权限的任何人仍然可以看到该视图。

4

1 回答 1

1

如果比较两个变量,则必须使用两个等号,否则将第一个变量设置为第二个变量的值。

if ( $titleuser == $id )
于 2014-01-28T11:22:02.810 回答