04 10 2023 snapshot

This commit is contained in:
Anatoliy Poloz
2023-10-04 17:57:09 +03:00
parent 1e546fa48e
commit 09a00744a0
441 changed files with 41582 additions and 254079 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/* use Illuminate\Database\Eloquent\Builder; */
@@ -26,8 +27,15 @@ class BlogPost extends Model implements Viewable
public function author()
{
/* return $this->belongsToMany(User::class, 'blog_post_author', 'blog_post_id', 'user_id'); */
return $this->hasOneThrough(User::class, BlogPostAuthor::class, 'blog_post_id', 'id', 'id', 'user_id');
return $this
->hasOneThrough(User::class, BlogPostAuthor::class, 'blog_post_id', 'id', 'id', 'user_id')
->withDefault(
[
'name' => 'Guest Author',
'id' => 0,
'profile_photo_url' => 'https://dev2.eatvio.com/storage/profile-photos/mW87tqy9P8O31Dauyvg8f7GowMNMsgt9J6u47T7S.jpg'
]
);
}
public function comments()
@@ -60,6 +68,10 @@ class BlogPost extends Model implements Viewable
return false;
}
public function scopeNoEagerLoads($query) {
return $query->setEagerLoads([]);
}
public function scopeContainsTag($query, $tagString): Builder
{
$tagId = Str::of($tagString)->split('/-/')->first();