Honour site redirect and permenant if URI doesnt have it set.

This commit is contained in:
Deon George 2022-10-29 00:38:22 +11:00
parent 7181c33a26
commit 94b50bea3e
2 changed files with 7 additions and 1 deletions

View File

@ -45,6 +45,7 @@ class RequestController extends Controller
$u = SiteUri::where('site_id',$s->id)->firstOrNew(['uri'=>request()->getRequestUri()]);
$u->hits++;
$s->uris()->save($u);
$u->refresh();
// If the site is not active, return
if (! $s->getRawOriginal('active')) {

View File

@ -24,7 +24,7 @@ class SiteUri extends Model
public function getActiveAttribute(bool $value): bool
{
return $value && (strlen($this->redirect) > 0);
return ($value && (strlen($this->redirect) > 0)) || $this->site->redirect;
}
public function getDelayAttribute(int $value=NULL): int
@ -37,6 +37,11 @@ class SiteUri extends Model
return $this->active && $value ? $value : $this->site->message;
}
public function getPermanentAttribute(bool $value): bool
{
return $value || $this->site->permanent;
}
public function getRedirectAttribute(string $value=NULL): string
{
return ($x=($this->getRawOriginal('active') && $value ? $value : $this->site->redirect)) ? $x.(request()->getRequestUri() != '/' ? request()->getRequestUri() : '') : '';