Hello i was wondering which is better to use:
" $request or request() " ,
" Auth:: facade or auth() " ,
" Session:: facade or session() "
is there some different or it is the same i guess like a function is a little bit faster ?
I believe a difference would be facades are mockable for testing where helpers are not, but I'm not even sure about helpers not being mockable, so at the end of the day, I really don't know anything about this and you can just ignore my post ☺
@SaeedPrez I didn't think about the testing part. I do most of my testing old fashion way, like if a query computes something, I crunch the numbers in MS Excel to ensure the query is correct prior to calling it good. As you know a join / group by query can give wrong results.
@jlrdw you should definitely check out the testing series if you haven't already. It can't get easier than writing for example $this->assertEquals(1, App\Model::count())
To the best of my knowledge, the helper method would resolve the binding using the facade reference.
If you override the binding with a mock object in your test, (SomeFacade::fake()), all binding instances for that class should be overridden with the mock, including the one called by the helper function.