I have a class called Messaging and I created a facade to using it like
Messaging::getConversationMessages($conv_id, $user_id);
I have followed all the instructions in this link below
How do I create a facade class with Laravel?
This is my MessagingServiceProvider calss below which does the binding
<?php
use Illuminate\Support\ServiceProvider;
class MessagingServiceProvider extends ServiceProvider {
/**
* Register the service provider.
*
* @return void
*/
public function register() {
App::bind('messaging', function()
{
return new \Messaging\Messaging;
}
);
}
}
Below is my facade class that I created for me to use it in the way I wanted to
<?php
use Illuminate\Support\Facades\Facade;
class Messaging extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'messaging'; }
}
I have placed my MessagingServiceProvider.php inside a folder called serviceproviders inside app folder, and placed the messaging.php(the file containing the facade class) inside a folder called facade in the app folder and added them to auto load.
Below is the model class for the facade
<?php
namespace Messaging;
use Eloquent; // if you're extending Eloquent
class Messaging extends Eloquent {
...
}
After doing all this still I am getting an error "Non-static method Messaging\Messaging::getConversationMessages() should not be called statically, assuming $this from incompatible context"