Welcome Guest, Not a member yet? Register   Sign In
Entity class not working on 2 module
#5

(10-16-2020, 11:19 AM)InsiteFX Wrote: Our you defining the use clause like I showed?

If the Entity is in the acp then the use clause should be like below.

Site/Post controller
use app/Modules/Acp/Entities/entityName;
use app/Modules/Acp/Models/PostModel;

Is that how you have your Site controller?

yes, you're right, in my Site/Controller i used: use app/Modules/Acp/Models/PostModel; and call that model to load data

and in my postModel code i return Entity class, my code is like this:


PHP Code:
namespace Modules\Acp\Models;

use 
CodeIgniter\Model;
use 
Modules\Acp\Entities\Post;

class 
PostModel extends Model
{
    protected $table 'post';
    protected $primaryKey 'id';

    protected $returnType Post::class;
    protected $useSoftDeletes true


With this code when i call the model in Acp/Controller it successfully return the Entity class

I also try to create new PostModel in Site/Model and new Entity in Site/Entities, my new model code is like:


PHP Code:
namespace Modules\Site\Models;

use 
CodeIgniter\Model;
use 
Modules\Site\Entities\Post;

class 
PostModel extends Model
{
    protected $table 'post';
    protected $primaryKey 'id';

    protected $returnType  'Modules\Site\Entities\Post';
    protected $useSoftDeletes true

but when i try to call the new model it does not return the entity object, i got the same problem as above. I dont know what wrong...
Reply


Messages In This Thread
Entity class not working on 2 module - by tmtuan - 10-15-2020, 09:00 PM
RE: Entity class not working on 2 module - by tmtuan - 10-16-2020, 07:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB