Heera/Modules/Admin/app/Repositories/FieldRepository.php

49 lines
941 B
PHP
Raw Permalink Normal View History

2024-05-16 03:46:08 +00:00
<?php
namespace Modules\Admin\Repositories;
use Modules\Admin\Models\Field;
class FieldRepository implements FieldInterface
{
public function findAll()
{
return Field::get();
}
public function getFieldById($FieldId)
{
return Field::findOrFail($FieldId);
}
public function getList()
{
return Field::pluck('title', 'id');
}
public function getDropdownByAlias($alias)
{
$fieldModel = Field::where("alias", $alias)->first();
if ($fieldModel) {
return $fieldModel->dropdown()->pluck('title', 'id');
}
}
public function delete($FieldId)
{
Field::destroy($FieldId);
}
public function create(array $FieldDetails)
{
return Field::create($FieldDetails);
}
public function update($FieldId, array $newDetails)
{
return Field::where('id', $FieldId)->update($newDetails);
}
}