Suppose I have this Facade
in one of my module:
// workbench/vendor/module1/src/Vendor/Module1/Facades/Module1.php
<?php namespace Vendor\Module1\Facades;
use Illuminate\Support\Facades\Facade;
class Module1 extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'module1'; }
}
And I create an Eloquent
of the same module, like this:
// workbench/vendor/module1/src/models/Module1.php
<?php
class Module1 extends \Eloquent {
protected $table = 'tb_module_1';
}
When I'm trying to call Module1
in my code that was intended to Eloquent
, ex. $module1 = new Model1
, it returns a Facade
instead of Eloquent
(ex. I can't use $module1->save()).
How to make Eloquent
and Facade
works in module development of Laravel? (If there are any suggestion that it is pointless to use both Eloquent
and Facade
, I would really love to hear the opinion)