Update domain::public() to only show public domains to admins, update status to be consistent with domain::public()
This commit is contained in:
parent
82cee02fa8
commit
a13497df5f
@ -292,6 +292,7 @@ class HomeController extends Controller
|
|||||||
->where('addresses.active',TRUE)
|
->where('addresses.active',TRUE)
|
||||||
->where('zones.active',TRUE)
|
->where('zones.active',TRUE)
|
||||||
->where('domains.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('addresses',['addresses.id'=>'a.id'])
|
||||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||||
->join('domains',['domains.id'=>'zones.domain_id'])
|
->join('domains',['domains.id'=>'zones.domain_id'])
|
||||||
|
@ -7,6 +7,7 @@ use Carbon\Carbon;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
use App\Casts\CompressedString;
|
use App\Casts\CompressedString;
|
||||||
@ -30,7 +31,10 @@ class Domain extends Model
|
|||||||
*/
|
*/
|
||||||
public function scopePublic($query)
|
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 */
|
/* RELATIONS */
|
||||||
|
Loading…
Reference in New Issue
Block a user