Current File : /home/getxxhzo/app.genicards.com/app/Repositories/FrontFaqsRepository.php |
<?php
namespace App\Repositories;
use App\Models\FrontFAQs;
use App\Models\FrontTestimonial;
use Illuminate\Support\Facades\DB;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
class FrontFaqsRepository extends BaseRepository
{
/**
* @var array
*/
protected $fieldSearchable = [
'title',
'description',
];
/**
* Return searchable fields
*/
public function getFieldsSearchable(): array
{
return $this->fieldSearchable;
}
/**
* Configure the Model
**/
public function model()
{
return FrontFAQs::class;
}
/**
* @return mixed
*/
public function store($input)
{
try {
DB::beginTransaction();
$faqs = FrontFAQs::create($input);
DB::commit();
return $faqs;
} catch (Exception $e) {
DB::rollBack();
throw new UnprocessableEntityHttpException($e->getMessage());
}
}
public function update($input, $id)
{
try {
DB::beginTransaction();
$faqs = FrontFAQs::findOrFail($id);
$faqs->update($input);
DB::commit();
return $faqs;
} catch (Exception $e) {
DB::rollBack();
throw new UnprocessableEntityHttpException($e->getMessage());
}
}
}