Reputation:
i have seen class like where they use facade and register something on acessor.
use Illuminate\Support\Facades\Facade;
/**
* @see \Collective\Html\FormBuilder
*/
class FormFacade extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'form'; }
}
it just taken from the laravel package it just returned facade but what actually that return form does ?
Upvotes: 1
Views: 155
Reputation: 24579
Laravel's facades are a sort of "gateway" to a service. It's "syntactic sugar" to make code look more readable. So if you did something like:
Form::open(array('route' => 'route.name'));
What you are actually doing is asking the application to resolve the service provider configured with the name 'form' as it's key. This is another way that it could be done:
app('form')->open(array('route' => 'route.name'));
In reality, you could do it the old fashion way too, but DI (dependency injection) is a great tool:
// Rough example without the actual parameters
$form = new Illuminate\Html\FormBuilder();
$form->open(array('route' => 'route.name'));
Upvotes: 1