【问题标题】:Adding another table named posts that contains the user_id of Sentinel Cartalyst添加另一个名为 posts 的表,其中包含 Sentinel Cartalyst 的 user_id
【发布时间】:2018-01-24 20:40:13
【问题描述】:

我正在使用 Sentinel 对我的评分系统项目进行身份验证,并添加了社交网络系统和高级身份验证系统等附加功能,我的问题是:

$post = new Post;

$post->title=$request->title; 
$post->body=$request->body; 
$post->user_id = auth()->user()->id; //need to convert into a cartalyst way
$post->save();

我希望将 user 表的 id 保存在 posts 表的 user_id 上。

【问题讨论】:

    标签: php cartalyst-sentinel


    【解决方案1】:

    在模型中建立关系,然后使用 attach() 函数附加用户发布以获取更多信息,请查看 Laravel 文档 [https://laravel.com/docs/5.5/eloquent-relationships]

    【讨论】:

      猜你喜欢
      • 2020-08-24
      • 2019-05-27
      • 1970-01-01
      • 2018-11-09
      • 1970-01-01
      • 1970-01-01
      • 2021-03-15
      • 1970-01-01
      • 2017-04-03
      相关资源
      最近更新 更多