55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\BaseModel;
|
|
|
|
class Section extends BaseModel
|
|
{
|
|
protected $table = 'sections';
|
|
protected $primaryKey = 'id';
|
|
protected $fillable = [
|
|
'section_name',
|
|
'description',
|
|
'updated_at',
|
|
'updated_by',
|
|
];
|
|
public $timestamps = false;
|
|
const CREATED_AT = 'created_at';
|
|
const UPDATED_AT = 'updated_at';
|
|
|
|
/**
|
|
* Get section by name.
|
|
*
|
|
* @param string $sectionName
|
|
* @return array|null
|
|
*/
|
|
public function getSectionByName($sectionName)
|
|
{
|
|
return $this->where('section_name', $sectionName)->first();
|
|
}
|
|
|
|
/**
|
|
* Update section details by ID.
|
|
*
|
|
* @param int $sectionId
|
|
* @param array $data
|
|
* @return bool
|
|
*/
|
|
public function updateSection($sectionId, $data)
|
|
{
|
|
$data['updated_at'] = utc_now(); // Set the updated_at timestamp
|
|
return $this->update($sectionId, $data);
|
|
}
|
|
|
|
/**
|
|
* Delete section by ID.
|
|
*
|
|
* @param int $sectionId
|
|
* @return bool
|
|
*/
|
|
public function deleteSection($sectionId)
|
|
{
|
|
return $this->delete($sectionId);
|
|
}
|
|
} |