普林斯顿大学 2020年文书范文

essay测试标题1

Or, you may find it convenient to specify middleware within your controller's constructor. Using the middleware method within your controller's constructor, you can assign middleware to the controller's actions:


The Save Method

Eloquent provides convenient methods for adding new models to relationships. For example, perhaps you need to insert a new Comment for a Post model. Instead of manually setting the post_id attribute on the Comment, you may insert the Comment directly from the relationship's save method:

$comment = new App\Comment(['message' => 'A new comment.']);

$post = App\Post::find(1);

$post->comments()->save($comment);

Notice that we did not access the comments relationship as a dynamic property. Instead, we called the comments method to obtain an instance of the relationship. The save method will automatically add the appropriate post_id value to the new Comment model.



范文点评

  • 评论于2021-04-22 19:16:47
    fgfgffggf
  • 评论于2021-04-22 16:45:41
    评论1评论1评论1评论1评论1 评论1评论1评论1评论1 评论1评论1 评论1评论1评论1