mardi 3 juillet 2018

Laravel: Passing Inputted Data and Email it

I'm new to this So i've made an input form to save data to database and it works. This time I'm trying to get the data and send it through email. I'm trying to get the data but it's still error.

error:

ErrorException (E_NOTICE)
Use of undefined constant inputName - assumed 'inputName'

controller:

public function store(Request $request)
    {
        $inputs = new Inputs();

        $inputs->inputName = $request->inputName;
        $inputs->inputAddress = $request->inputAddress;
        $inputs->inputBDO = Carbon::parse($request->inputBDO);
        $inputs->inputEmail = $request->inputEmail;
        $inputs->inputPhone = $request->inputPhone;
        $inputs->inputJob = $request->inputJob;

        $inputs->save();

        return redirect ('sendhtmlemail', ['inputName' => Inputs::get('inputName')]);
    }
    public function html_email(Request $request){
        $inputs = new Inputs();
        $inputs -> inputName = $request->inputName;
        $inputs = array('name'=>$inputs->inputName);
        Mail::send('mail', $inputs, function($message) {
            $message->to('stevemichaelruru@gmail.com', 'Tutorials Point')->subject
            ('Laravel HTML Testing Mail');
            $message->from('stevemichaelruru@gmail.com','$inputName');
        });
        echo "HTML Email Sent. Check your inbox.";
    }

routes:

Route::get('/', 'TicketController@index');
Route::get('/input/create', 'TicketController@create');
Route::post('/input', array('as' => 'form', 'uses'=>'TicketController@store'));
Route::get('sendhtmlemail','TicketController@html_email')->with('inputName',inputName);;

mail blade

<h1>Hi, </h1>
<p>Sending Mail from Laravel.</p>




Aucun commentaire:

Enregistrer un commentaire