public function comments()
{
return $this->hasMany('App\Comments');
}
Task::find($id)->comments()->count();
$count = 0;
foreach(Task::All() as $task)
{
$count += $task->comments()->count();
}
.tooltip {
z-index: 9999;
}
class Object extends Model {
protected $table = 'object';
public function type(){
return $this->belongsTo('App\Type', 'id');
}
}
class Type extends Model {
protected $table = 'types';
public function type_name(){
return $this->hasMany('App\Object','type','id');
}
}
$obj = Object::find(1);
var_dump($obj->type);