Error in postContact function

Published 4 months ago by gfellainc

I got this error message for my postContact function

FatalErrorException in Front.php line 184: syntax error, unexpected '=', expecting ')'

What is the error in this code.

public function postContact(Request $request) { $this->validate($request, [ 'name'=>'required', 'email'=>'required|email', 'message'=>'min:10' ]);

    $data = array(
        'name' = $request->name ,
        'email' = $request->email ,
        'bodyMessage' = $request->message
    );
    
        
    Mail::send('emails.contact', $data, function(){
        
        }); 
}
Best Answer (As Selected By gfellainc)
jobcerto

You make the array with = but the correct way is =>


$data = array(
        'name' => $request->name ,
        'email' => $request->email ,
        'bodyMessage' => $request->message
    );
    

jobcerto

You make the array with = but the correct way is =>


$data = array(
        'name' => $request->name ,
        'email' => $request->email ,
        'bodyMessage' => $request->message
    );
    

StefanVoinea

try

$data = [
        'name' => $request->name ,
        'email' => $request->email ,
        'bodyMessage' => $request->message
    ];
gfellainc

Thank u very much for you both.

Sign In or create a forum account to participate in this discussion.