static function hasManyThrough($where, $join, $through, $foreign, $local) { $auth = self::auth(); if (isset($auth)) { if (is_object($where)) { if (isset($where->permission)) { $permission = $where->permission; } else { $permission = 0; } } else { throw new \RuntimeException('Only object.'); } $auth = Authorization::get_auth("show", $auth, $permission, get_join_name($join)); $select = $auth['fields']; $own = $auth['own']; if (count($select) == 0) { abort(403); } $objects = $where->first()->hasManyThrough($join, $through, $foreign, $local)->select($select); if ($where->permission == 1) { if ($own != null) { $objects->where($own, "=", Auth::user()->id); } } $objects->permission = $permission; return $objects; } }