1. Custom value request->all()
public function kirimData(Request $request){
$input = $request->all();
$input['username'] = "new value";
$input['nama'] = ""nama baru;
Service::create($input); // store to database
//untuk penambahan request modifikasi request sama saja kodingnya
}
2 . Custom value request->all() v2
User::create($request->all() + ['umur' => 'value']);
3. Custom value request->all() dengan array merge
function store(Request $request)
{
User::create(array_merge($request->all(), ['index' => 'value']));
}
4. Custom value request
$request->request->add(['variable' => 'value']); //add request
$request->request->set(['variable', 'value']); //set request
0 Comments