0

I have created a procedure for insertion but dont know how to call parameters "name" and "path" in controller and model

Stored procedure:

CREATE DEFINER=`root`@`localhost` 
     PROCEDURE `insert_document_details`
        (IN `name` VARCHAR(50), IN `path` VARCHAR(255) )
BEGIN
    INSERT INTO `document_details`
      (`document_name`, `document_path`) 
    VALUES (name,path);
END

Routes:

Route::post('insert_document_details/{name}/{path}',array('as'=>'insert_document_details',
'uses'=>'AuthorsController@post_document_details'));

AuthorController:

class AuthorsController extends BaseController{
        public $restful = true;

        public function post_document_details($name,$path)
        {

            $document_details=Response::json(Author::insert_document_details_Call());
            return $document_details;
        }
}

Author(model):

class Author extends Eloquent {

    public $table = 'document_details';
    protected $primaryKey = 'id';

    public static function insert_document_details_Call($name,$path)
    {
        return DB::select('call insert_document_details');
    }
}
DolDurma
  • 15,753
  • 51
  • 198
  • 377
user2655547
  • 11
  • 1
  • 5

1 Answers1

2

The second takes a list of parameters that can be passed as below

DB::select('call insert_document_details(?,?)',array($name,$path));

or

DB::statement('call insert_document_details(' . DB::raw($name) . ',' . DB::raw($path) . ')');
Abishek
  • 11,191
  • 19
  • 72
  • 111