first commit
This commit is contained in:
58
app/Models/EventHealthAllowance.php
Normal file
58
app/Models/EventHealthAllowance.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class EventHealthAllowance extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasFactory;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'event_health_allowances';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
58
app/Models/EventImprovedHealth.php
Normal file
58
app/Models/EventImprovedHealth.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class EventImprovedHealth extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasFactory;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'event_improved_healths';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
58
app/Models/EventMetabolism.php
Normal file
58
app/Models/EventMetabolism.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class EventMetabolism extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasFactory;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'event_metabolisms';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
58
app/Models/EventRegistrationInfo.php
Normal file
58
app/Models/EventRegistrationInfo.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class EventRegistrationInfo extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasFactory;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'event_registration_infos';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
86
app/Models/Faq.php
Normal file
86
app/Models/Faq.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Ericli1018\AwesomeFieldsForBackpack\Models\Traits\HasUploadImgFields;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class Faq extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasFactory;
|
||||
use HasUploadImgFields;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'faqs';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
protected $casts = [
|
||||
'post_at' => 'datetime',
|
||||
'photos' => 'array',
|
||||
];
|
||||
protected $attributes = [
|
||||
'description' => 'N/A',
|
||||
];
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::deleting(function($obj) {
|
||||
if (count((array)$obj->photos)) {
|
||||
foreach ($obj->photos as $item) {
|
||||
\Storage::disk('public')->delete($item['file_path']);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function faqCatalog()
|
||||
{
|
||||
return $this->belongsTo(FaqCatalog::class, 'faq_catalog_id');
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function setPhotosAttribute($value)
|
||||
{
|
||||
$attribute_name = "photos";
|
||||
$disk = "public";
|
||||
$destination_path = "faqs";
|
||||
|
||||
$this->uploadImgMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
|
||||
}
|
||||
}
|
64
app/Models/FaqCatalog.php
Normal file
64
app/Models/FaqCatalog.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FaqCatalog extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use HasFactory;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'faq_catalogs';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(FaqCatalog::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(FaqCatalog::class, 'parent_id');
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
86
app/Models/HealthInfo.php
Normal file
86
app/Models/HealthInfo.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Ericli1018\AwesomeFieldsForBackpack\Models\Traits\HasUploadImgFields;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class HealthInfo extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasFactory;
|
||||
use HasUploadImgFields;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'health_infos';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
protected $casts = [
|
||||
'post_at' => 'datetime',
|
||||
'photos' => 'array',
|
||||
];
|
||||
protected $attributes = [
|
||||
'description' => 'N/A',
|
||||
];
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::deleting(function($obj) {
|
||||
if (count((array)$obj->photos)) {
|
||||
foreach ($obj->photos as $item) {
|
||||
\Storage::disk('public')->delete($item['file_path']);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function healthInfoCatalog()
|
||||
{
|
||||
return $this->belongsTo(HealthInfoCatalog::class, 'news_catalog_id');
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function setPhotosAttribute($value)
|
||||
{
|
||||
$attribute_name = "photos";
|
||||
$disk = "public";
|
||||
$destination_path = "health_info";
|
||||
|
||||
$this->uploadImgMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
|
||||
}
|
||||
}
|
64
app/Models/HealthInfoCatalog.php
Normal file
64
app/Models/HealthInfoCatalog.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class HealthInfoCatalog extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use HasFactory;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'health_info_catalogs';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(HealthInfoCatalog::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(HealthInfoCatalog::class, 'parent_id');
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
86
app/Models/News.php
Normal file
86
app/Models/News.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Ericli1018\AwesomeFieldsForBackpack\Models\Traits\HasUploadImgFields;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class News extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasFactory;
|
||||
use HasUploadImgFields;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'news';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
protected $casts = [
|
||||
'post_at' => 'datetime',
|
||||
'photos' => 'array',
|
||||
];
|
||||
protected $attributes = [
|
||||
'description' => 'N/A',
|
||||
];
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::deleting(function($obj) {
|
||||
if (count((array)$obj->photos)) {
|
||||
foreach ($obj->photos as $item) {
|
||||
\Storage::disk('public')->delete($item['file_path']);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function newsCatalog()
|
||||
{
|
||||
return $this->belongsTo(NewsCatalog::class, 'news_catalog_id');
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function setPhotosAttribute($value)
|
||||
{
|
||||
$attribute_name = "photos";
|
||||
$disk = "public";
|
||||
$destination_path = "news";
|
||||
|
||||
$this->uploadImgMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
|
||||
}
|
||||
}
|
64
app/Models/NewsCatalog.php
Normal file
64
app/Models/NewsCatalog.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NewsCatalog extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use HasFactory;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'news_catalogs';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(NewsCatalog::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(NewsCatalog::class, 'parent_id');
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
86
app/Models/Notice.php
Normal file
86
app/Models/Notice.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Ericli1018\AwesomeFieldsForBackpack\Models\Traits\HasUploadImgFields;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class Notice extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasFactory;
|
||||
use HasUploadImgFields;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'notices';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
protected $casts = [
|
||||
'post_at' => 'datetime',
|
||||
'photos' => 'array',
|
||||
];
|
||||
protected $attributes = [
|
||||
'description' => 'N/A',
|
||||
];
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::deleting(function($obj) {
|
||||
if (count((array)$obj->photos)) {
|
||||
foreach ($obj->photos as $item) {
|
||||
\Storage::disk('public')->delete($item['file_path']);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function noticeCatalog()
|
||||
{
|
||||
return $this->belongsTo(NoticeCatalog::class, 'news_catalog_id');
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function setPhotosAttribute($value)
|
||||
{
|
||||
$attribute_name = "photos";
|
||||
$disk = "public";
|
||||
$destination_path = "notices";
|
||||
|
||||
$this->uploadImgMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
|
||||
}
|
||||
}
|
64
app/Models/NoticeCatalog.php
Normal file
64
app/Models/NoticeCatalog.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NoticeCatalog extends Model
|
||||
{
|
||||
use CrudTrait;
|
||||
use HasFactory;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected $table = 'notice_catalogs';
|
||||
// protected $primaryKey = 'id';
|
||||
// public $timestamps = false;
|
||||
protected $guarded = ['id'];
|
||||
// protected $fillable = [];
|
||||
// protected $hidden = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELATIONS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(HealthInfoCatalog::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(HealthInfoCatalog::class, 'parent_id');
|
||||
}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SCOPES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ACCESSORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| MUTATORS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
}
|
22
app/Models/Traits/LogsActivity.php
Normal file
22
app/Models/Traits/LogsActivity.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity as OriginalLogsActivity;
|
||||
|
||||
trait LogsActivity
|
||||
{
|
||||
use OriginalLogsActivity;
|
||||
|
||||
/**
|
||||
* Spatie Log Options
|
||||
* By default will log only the changes between fillables
|
||||
*
|
||||
* @return LogOptions
|
||||
*/
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()->logAll()->logOnlyDirty();
|
||||
}
|
||||
}
|
49
app/Models/User.php
Normal file
49
app/Models/User.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use App\Models\Traits\LogsActivity;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use CrudTrait;
|
||||
use LogsActivity;
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
Reference in New Issue
Block a user