php - How can i fetch another table data in different table column? -
firstly have given 3 table structure.
here how can action_id in permissions table actions table? , how can role_id in permissions table roles table? please tell me easy way , beginner in laravel.
action model:
<?php namespace app; use illuminate\database\eloquent\model; class action extends model { // protected $table = "actions"; //public $fillable = [] public function role(){ return $this->belongsto('app\action'); } public function permission(){ return $this->belongsto('app\action'); } } permission model:
<?php namespace app; use illuminate\database\eloquent\model; class permission extends model { // protected $table ="permissions"; public function actionget(){ return $this->hasone('app/permission'); } }
update permission_table join action_table b on a.id = b.id join roles_table c on a.id = c.id set a.action_id = b.id, a.role_id = c.id; this update action_id in permission table id action table also, role_id in permission table id role table. assume want.



Comments
Post a Comment