belykia
239
10
Laravel

save( ) a POST <Form > using an array ? laravel 5.6

Posted 1 year ago by belykia

Hello Everybody :

i m a beginner in laravel .

trying to solve the problem i used this link , but it doesn't help :(https://laravel.com/docs/5.1/quickstart) , i went back until the title "Creating The Task" .

i created a of 5 inputs ,in home.blade.php each one is a string :

AS Number peeringRS Yes No peeringDB AS-SET Contact

next step in the web.php , i wrote the following ligne : Route::post('/POST', '[email protected]');

then finally , i wrote the following code in PostController.php,in order to save the form in the database table :

public function store(Request $request) {

    //$this->validate($request,[
        //'body'=>'required|unique:todos']);
    $data = new Post ;
    $ASNumber= $request->input('ASNumber');

  $choice=$request->input('choice');
  $peeringDB=$request->input('peeringDB');
     $ASSET =$request->input('AS-SET');
      $Contact=$request->input('Contact');  
  
   $data = array('asnumber'=>$ASNumber,'peeringrs'=>$choice,'peeringdb'=>$peeringDB,'AS

-SET'=>$ASSET,'contact'=>$Contact);

   $data->save();
 return  redirect('/');    
}

the answer in the "http://127.0.0.1:8000/POST" , was "Call to a member function save() on array" .

a last question , why should i redirect ???

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.