Update domain::public() to only show public domains to admins, update status to be consistent with domain::public()

This commit is contained in:
Deon George 2023-11-25 00:10:21 +11:00
parent 82cee02fa8
commit a13497df5f
2 changed files with 6 additions and 1 deletions

View File

@ -292,6 +292,7 @@ class HomeController extends Controller
->where('addresses.active',TRUE)
->where('zones.active',TRUE)
->where('domains.active',TRUE)
->when(! ($x=Auth::user()) || (! $x->isAdmin()),function($query) { return $query->where('domains.public',TRUE); })
->join('addresses',['addresses.id'=>'a.id'])
->join('zones',['zones.id'=>'addresses.zone_id'])
->join('domains',['domains.id'=>'zones.domain_id'])

View File

@ -7,6 +7,7 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use App\Casts\CompressedString;
@ -30,7 +31,10 @@ class Domain extends Model
*/
public function scopePublic($query)
{
return $query->where('public',TRUE);
$user = Auth::user();
return $query
->when(((! $user) || (! $user->isAdmin())),function($query) { return $query->where('public',TRUE)->active(); });
}
/* RELATIONS */