Questions tagged [laravel-facade]

Facades in Laravel framework provide a "static" interface to classes that are available in the application's IoC container.

Facades provide a "static" interface to classes that are available in the application's IoC container. Laravel ships with many facades, and you have probably been using them without even knowing it! Laravel "facades" serve as "static proxies" to underlying classes in the IoC container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

168 questions
1
vote
1 answer

Where can I use Laravel Facade aliases?

I have built a Laravel 5.4 application with a custom facade, App\Facades\Repo. The Repo facade proxies to a RepositoryFactory class. In my app configuration I have an alias Repo which points to the Repo facade. I use it to get repositories with…
DatsunBing
  • 8,684
  • 17
  • 87
  • 172
1
vote
1 answer

Facade error in laravel 5.2

I installed a package in Laravel 5.2 named jonnywilliamson/laragram And put in config\app.php a alias and service provider like below : 'providers' => [ . . ., Illuminate\Translation\TranslationServiceProvider::class, …
bitcodr
  • 1,395
  • 5
  • 21
  • 44
1
vote
2 answers

Mock Illuminate Config facade without Laravel

I'm working on a package that relies on the Config facade. The code itself works fine, but I'm encountering issues when testing. Initially, I was using this code: Config::shouldReceive('foo.bar') ->andReturn(true); As many others, I bumped into…
Quetzy Garcia
  • 1,820
  • 1
  • 21
  • 23
1
vote
0 answers

Laravel 5.2 : Can I use a custom laravel facade in multiple classes?

I am learning about Laravel facades in Laravel version 5.2, and I made my own facade to use in multiple custom classes of my own, so I don't have repeating code. However I've been getting the following problem. I've referenced the Facade Alias…
1
vote
1 answer

error while trying to run artisan command with Artisan Facade

here's the code Route::get('run-cmd', function() { Artisan::call('make:controller HelloController'); }); and I wonder I'm getting this error... InvalidArgumentException in Application.php line 549: Command "make:controller HelloController"…
bobD
  • 1,037
  • 2
  • 9
  • 17
1
vote
1 answer

Laravel - interface and multiple services

I need to create an interface to send SMS with multiple providers. I have create an SMSInterface which contains all the method available to send sms. Now I have created an abstract class which implements the…
Christian Giupponi
  • 7,408
  • 11
  • 68
  • 113
1
vote
3 answers

Laravel 5.2 - Common OBJECT to all controllers and views

I am new in Laravel, and currently coding an intranet app, which is basically a dashboard with a lot of informations, with Laravel 5.2, and one of the requirements is to be able to navigate thu different stores. Each page of the app, will require…
1
vote
2 answers

Is it possible to use Laravel 5 without facades?

I read that facades are not good. I have no idea if that is correct. I also read that Laravel uses a lot of them. Further, I read you can turn them off in Lumen. "Turn off" may not be the right word. Do you have to use Laravel with facades? If…
johnny
  • 19,272
  • 52
  • 157
  • 259
1
vote
2 answers

Laravel detach Pivot tables

I'm new with Laravel and I'm having problems while I try to detach some values from my pivot tables. The pivot tables I'm woking with are: excercise_workout (ejercicio_rutina) & excise_day (ejercicio_dia) (those tables have just two id's each one).…
1
vote
1 answer

Laravel - Response:: or response() - which one is better

I was just curious about Facade and service container binding functions in Laravel 5.1, let's say Reponse::json() and response()->json() are the same. But is there any reason that one of them is better than the other?
DucCuong
  • 638
  • 1
  • 7
  • 26
1
vote
1 answer

Laravel class Auth

Hi can I ask about this in laravel framework namespace Illuminate\Support\Facades; /** * @see \Illuminate\Auth\AuthManager * @see \Illuminate\Contracts\Auth\Factory * @see \Illuminate\Contracts\Auth\Guard * @see…
jemz
  • 4,987
  • 18
  • 62
  • 102
1
vote
1 answer

Why does accessing a Facade in a Laravel constructor fail?

I'm currently trying to implement the repository pattern in Laravel. I have an interface that declares the minimum methods required to be a valid repository.
user4165455
1
vote
1 answer

Work of laravel facade facadeaccessor

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…
user5117846
1
vote
1 answer

Laravel5 extend Facade

I want to extend Laravel5 Cookies functionality. I want to make it this way: I will create file App\Support\Facades\Cookie.php and than file App\Libraries\CookieJar.php. In app.php I will change row for Cookie to this: 'Cookie' =>…
Jan Kožušník
  • 683
  • 3
  • 16
  • 30
1
vote
1 answer

Laravel 5.1 Custom Facade Stopped Working

I am trying to make custom Facades for my Laravel 5.1.17 application. I have followed the Laravel documentation as well as this tutorial step by step and indeed I was able to create a custom Facade for my custom service. However, all of a sudden it…
tam5
  • 3,197
  • 5
  • 24
  • 45