Issue
is that possible to use direct table name in hasMany. for example
public function Permissions()
{
return $this->hasMany('TABLE NAME');
}
I have table named PERMISSION but don't have a model of this table, but i want to use this table in hasmany.
Solution
Just create a model for that table
php artisan make:model Permisson
then add the table name to the model class
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Permisson extends Model
{
protected $table = "table_name";
}
and add the relation
public function permissions()
{
return $this->hasMany(Permisson::class)
}
I hope it helps
Answered By - larsbadke Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.