49 lines
941 B
PHP
49 lines
941 B
PHP
<?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);
|
|
}
|
|
|
|
}
|