first commit
This commit is contained in:
28
app/Models/GambarCarousel.php
Normal file
28
app/Models/GambarCarousel.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// 2. Model: GambarCarousel.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class GambarCarousel extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'tajuk', 'keterangan', 'fail_nama', 'fail_path', 'tarikh_upload',
|
||||
'tarikh_mula', 'tarikh_tamat', 'admin_id'
|
||||
];
|
||||
|
||||
protected $dates = ['tarikh_upload', 'tarikh_mula', 'tarikh_tamat'];
|
||||
|
||||
public function scopeAktif($query)
|
||||
{
|
||||
$today = now()->toDateString();
|
||||
return $query->where('tarikh_mula', '<=', $today)
|
||||
->where('tarikh_tamat', '>=', $today);
|
||||
}
|
||||
|
||||
public function admin()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'admin_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user