Friday, March 17, 2017

How to pass an object for DB insert?

I need to insert the record into the db. How should i pass it throught controller?

For example to delete record i pass Id, and it looks like

routes.php func:

Route::get('/template/delete/{id}', array(
'as' => 'template_delete',
'uses' => 'ThoughtRiver\Template\Controllers\TemplateController@deleteTemplate'
));

controller func:

public function deleteTemplate($id)
    {
        return DB::table('template')->where('Id', '=', $id)->delete();
    }

So how to pass record object in the case of insert? It's a backend functional, so object should be taken not from the form. (From the http post request body?)



via Mira

Advertisement