PHP laravel Add $request

Source: Internet
Author: User
PHP code

public function store(Request $request){        $name = $request->get('namne', 0);        $newname = $request->set('newname', 0);          // 前端提交 `data` 里面没有 `newname` 这个字段,    // 需要在这里处理一些业务逻辑,新增一个字段然后到下面一起保存起来        // $request->newname = 'newname'     // 尝试过这样好像没写进入        //想在保存数据前,添加一个字段 ;    // $request->all()->'新的字段名称' = '我是新加的字段值';    // 这个时候 $request->all() 会多出来上面新添加的字段        $post = Post::create($request->all());}

Vue Code

this.$http.post('/backend/post', data).then(function(result) {})

The great God has wood, how to $request->all() add a field in it before saving

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.