You can generate model for your stored procedures (aka functions) by typing this command
php artisan generate-sp
Only stored procedures which name start with sp_ will have a model generated, other ones will be ignored.
Models will be written in app/store_procedures directory (or the one defined in configuration file). Do not edit these models ! They will be overwritten at next generation.
You can override default configuration by publishing configuration file and editing it.
Generated models have an execute() methods that allow you to execute stored procedure and get result (if the procedure returns one) from it.
If procedure have IN or INOUT parameter, the execute() method will have the same parameter in the same order.
If it has OUT or INOUT parameter, model will have an attribute with getter/setter for every OUT parameters.
Setters will not modify data, they are only present to allow you to format data if you want to use it on views by uysing whole model instead of simple variables.
Giving the following stored procedure, that retrieve all friends of a user giving its id...
CREATE OR REPLACEFUNCTIONsp_getfriends(IN id integer, OUT id integer, OUT username character varying, OUT firstname character varying, OUT lastname character varying, OUT facebook_id character varying)
RETURNS SETOF record AS
$BODY$SELECT id, username, firstname, lastname, facebook_id
LEFT JOIN friends ONusers.id=friends.friend_with_idWHEREfriends.user_id= $1$BODY$
LANGUAGE sql VOLATILE
...we will have a SP_Getfriends class generated. We can use it like this :