progress
This commit is contained in:
56
app/Models/Advertisement.php
Normal file
56
app/Models/Advertisement.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Advertisement extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'advertisement_id';
|
||||
protected $table = 'advertisement';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'parent_id',
|
||||
'alias',
|
||||
'description',
|
||||
'image',
|
||||
'video',
|
||||
'link',
|
||||
'display_order',
|
||||
'status',
|
||||
'remarks',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
56
app/Models/Authors.php
Normal file
56
app/Models/Authors.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Authors extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'author_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'alias',
|
||||
'author_email',
|
||||
'author_description',
|
||||
'author_image',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function publishedNews(){
|
||||
return $this->hasMany(News::class, 'authors_id', 'author_id')->where('status', 1);
|
||||
}
|
||||
}
|
54
app/Models/Economies.php
Normal file
54
app/Models/Economies.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Economies extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'economy_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'ecomomy_nepali_name',
|
||||
'alias',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function news(){
|
||||
return $this->hasMany(News::class, 'economics_id', 'economy_id');
|
||||
}
|
||||
}
|
@ -30,11 +30,11 @@ class OperationLog extends Model
|
||||
];
|
||||
|
||||
|
||||
// protected $appends = ['operation_by'];
|
||||
protected $appends = ['operation_by'];
|
||||
|
||||
// public function getOperationByAttribute()
|
||||
// {
|
||||
// $user = User::find($this->user_id);
|
||||
// return $user ? $user->name : '';
|
||||
// }
|
||||
public function getOperationByAttribute()
|
||||
{
|
||||
$user = User::find($this->user_id);
|
||||
return $user ? $user->name : '';
|
||||
}
|
||||
}
|
91
app/Models/News.php
Normal file
91
app/Models/News.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class News extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'news_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'newscategories_id',
|
||||
'provinces_id',
|
||||
'news_type_id',
|
||||
'economics_id',
|
||||
'authors_id',
|
||||
'parent_news',
|
||||
'title',
|
||||
'short_description',
|
||||
'nepali_title',
|
||||
'alias',
|
||||
'content',
|
||||
'featured_news',
|
||||
'image',
|
||||
'thumb',
|
||||
'image_source',
|
||||
'display_order',
|
||||
'status',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(News::class, 'parent_news');
|
||||
}
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(News::class, 'parent_news');
|
||||
}
|
||||
|
||||
public function newsType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(News_Type::class, 'news_type_id', 'news_type_id');
|
||||
}
|
||||
public function newsCategories(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Newscategories::class, 'newscategories_id', 'category_id');
|
||||
}
|
||||
|
||||
public function author(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'authors_id', 'author_id');
|
||||
}
|
||||
|
||||
public function provinces(): BelongsTo{
|
||||
return $this->belongsTo(Provinces::class, 'provinces_id', 'province_id');
|
||||
}
|
||||
}
|
56
app/Models/News_type.php
Normal file
56
app/Models/News_type.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class News_type extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'news_type_id';
|
||||
protected $table = 'news_type';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'title_nepali',
|
||||
'alias',
|
||||
'status',
|
||||
'display_order',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function news(): HasMany
|
||||
{
|
||||
return $this->hasMany(News::class, 'news_type_id', 'news_type_id');
|
||||
}
|
||||
|
||||
}
|
85
app/Models/Newscategories.php
Normal file
85
app/Models/Newscategories.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Newscategories extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'category_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'nepali_title',
|
||||
'alias',
|
||||
'parent_category',
|
||||
'display_order',
|
||||
'status',
|
||||
'remarks',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Newscategories::class, 'parent_category')->where('status',1);
|
||||
}
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(Newscategories::class, 'parent_category')->where('status',1);
|
||||
}
|
||||
|
||||
public function news(){
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->orderBy('display_order');
|
||||
}
|
||||
public function entertainmentNews(){
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function technologyNews(){
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function culturalNews(){
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function sportNews(){
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(9)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function interviewNews(){
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
|
||||
public function politicNews(){
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(5)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
}
|
61
app/Models/Provinces.php
Normal file
61
app/Models/Provinces.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Provinces extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'province_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'province_no',
|
||||
'province_nepali_name',
|
||||
'alias',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
// protected function createdBy(): Attribute
|
||||
// {
|
||||
// return Attribute::make(
|
||||
// get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
// );
|
||||
// }
|
||||
|
||||
// protected function updatedBy(): Attribute
|
||||
// {
|
||||
// return Attribute::make(
|
||||
// get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
// );
|
||||
// }
|
||||
|
||||
public function provinceNews():HasMany{
|
||||
return $this->hasMany(News::class,'provinces_id','province_id')
|
||||
->where('status','<>',-1)
|
||||
->where('news_type_id',2)
|
||||
->where('newscategories_id',1)
|
||||
->orderBy('display_order');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user