Reputation:
I am understanding Laravel(5.1 version although 5.2 now recently comes) framework...and studying it deeply...What I am trying to ask let me elaborate through some example:
I have created the model named Blog:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Blog extends Model {
protected $fillable = ['title','body'];
}
Now in my controller I am accessing the function create()
of this class in my controller store() method like:
public function store(BlogRequest $request)
{
$input = Request::all();
Blog::create($input);
return redirect('blogs');
}
As you can see that in above controller method we are accessing the static function/method create() i.e
Blog::create($input)
..so the question is as there are so many other methods exists like create()
method of a model(Blog) class which extends the Model class...is there any way/strategy/function to find out/know all the functions of this Model Class...
Upvotes: 1
Views: 3007
Reputation: 633
Yes! You can refer to the API documentation.
For example, I searched for model and found Illuminate\Database\Eloquent\Model, which is the class your models extend and there it is the create static method.
You can change the Laravel version on the top left and filter for classes, namespaces, interfaces and traits on the top right. Pretty neat!
Edit:
You can use the getMethods method on the ReflectionClass to list all available methods for a given class.
For example:
$methods = (new ReflectionClass('\App\Blog'))->getMethods();
dd($methods);
Upvotes: 2