Append array Request::all()

Submitted by mlselegant - 1 year ago

Append array in $request::all() while saving data in laravel 5.2

public function store(Request $request){
        $arr = ['user'=> 'Elegant'];    // ['key' => 'value']
        $data = array_merge($request::all(), $arr);
        
        Profile::create($data); // table name = Profile
        return back();
}

Ads cover the costs of maintaining Laravel-tricks

comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks