Initial Commit
This commit is contained in:
31
app/Models/Category.php
Normal file
31
app/Models/Category.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
protected $fillable = ["name","slug", "parent", "ordering"];
|
||||
|
||||
public function sluggable(): array {
|
||||
return [
|
||||
"slug" => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function parent_category() {
|
||||
return $this->belongsTo(ParentCategory::class, 'parent', 'id');
|
||||
}
|
||||
|
||||
public function posts() {
|
||||
return $this->hasMany(Post::class, 'category', 'id');
|
||||
}
|
||||
}
|
||||
21
app/Models/GeneralSetting.php
Normal file
21
app/Models/GeneralSetting.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GeneralSetting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'site_title',
|
||||
'site_email',
|
||||
'site_phone',
|
||||
'site_meta_keywords',
|
||||
'site_meta_description',
|
||||
'site_logo',
|
||||
'site_favicon',
|
||||
];
|
||||
}
|
||||
13
app/Models/NewsletterSubscriber.php
Normal file
13
app/Models/NewsletterSubscriber.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class NewsletterSubscriber extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['email'];
|
||||
}
|
||||
28
app/Models/ParentCategory.php
Normal file
28
app/Models/ParentCategory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
|
||||
|
||||
class ParentCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
protected $fillable = ["name", "slug", "ordering"];
|
||||
|
||||
public function sluggable(): array {
|
||||
return [
|
||||
"slug" => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function children() {
|
||||
return $this->hasMany(Category::class, 'parent', 'id');
|
||||
}
|
||||
}
|
||||
51
app/Models/Post.php
Normal file
51
app/Models/Post.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use App\Models\User;
|
||||
use App\Models\Category;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
protected $fillable = [
|
||||
'author_id',
|
||||
'category',
|
||||
'title',
|
||||
'slug',
|
||||
'content',
|
||||
'tags',
|
||||
'meta_keywords',
|
||||
'meta_description',
|
||||
'visibility',
|
||||
'is_notified',
|
||||
];
|
||||
|
||||
public function sluggable(): array {
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'title'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function author() {
|
||||
return $this->hasOne(User::class, 'id', 'author_id');
|
||||
}
|
||||
|
||||
public function post_category() {
|
||||
return $this->hasOne(Category::class, 'id', 'category');
|
||||
}
|
||||
|
||||
public function scopeSearch($query, $term) {
|
||||
$term = "%$term%";
|
||||
$query->where(function($query) use ($term) {
|
||||
$query->where('title', 'like', $term);
|
||||
});
|
||||
}
|
||||
}
|
||||
19
app/Models/SiteSocialLink.php
Normal file
19
app/Models/SiteSocialLink.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class SiteSocialLink extends Model
|
||||
{
|
||||
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'facebook_url',
|
||||
'instagram_url',
|
||||
'linkedin_url',
|
||||
'twitter_url',
|
||||
];
|
||||
}
|
||||
20
app/Models/Slide.php
Normal file
20
app/Models/Slide.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
|
||||
class Slide extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'image',
|
||||
'heading',
|
||||
'link',
|
||||
'status',
|
||||
'ordering',
|
||||
];
|
||||
}
|
||||
76
app/Models/User.php
Normal file
76
app/Models/User.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use App\UserStatus;
|
||||
use App\UserType;
|
||||
use App\Models\UserSocialLink;
|
||||
use App\Models\Post;
|
||||
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
"username",
|
||||
"picture",
|
||||
"bio",
|
||||
"type",
|
||||
"status"
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
"status" => UserStatus::class,
|
||||
"type" => UserType::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function getPictureAttribute($value) {
|
||||
return $value ? asset("/images/users/".$value) : asset("/images/users/default-avatar.png");
|
||||
}
|
||||
|
||||
public function social_links() {
|
||||
return $this->hasOne(UserSocialLink::class, "id", "user_id");
|
||||
}
|
||||
|
||||
public function getTypeAttribute($value) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function posts() {
|
||||
return $this->hasMany(Post::class, 'author_id', 'id');
|
||||
}
|
||||
}
|
||||
19
app/Models/UserSocialLink.php
Normal file
19
app/Models/UserSocialLink.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserSocialLink extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'facebook_url',
|
||||
'instagram_url',
|
||||
'youtube_url',
|
||||
'twitter_url',
|
||||
'github_url',
|
||||
'linkedin_url',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user