![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/clinic.corals.io/app/Repositories/ |
<?php namespace App\Repositories; use App\Models\FrontPatientTestimonial; use Illuminate\Support\Facades\DB; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; use Exception; /** * Class FrontPatientTestimonialRepository * @package App\Repositories * @version September 22, 2021, 11:20 am UTC */ class FrontPatientTestimonialRepository extends BaseRepository { /** * @var array */ protected $fieldSearchable = [ 'name', 'designation', 'short_description', ]; /** * Return searchable fields * * @return array */ public function getFieldsSearchable() { return $this->fieldSearchable; } /** * Configure the Model **/ public function model() { return FrontPatientTestimonial::class; } /** * @param $input * * @return bool */ public function store($input) { try { DB::beginTransaction(); $slider = FrontPatientTestimonial::create($input); if (isset($input['profile']) && ! empty($input['profile'])) { $slider->addMedia($input['profile'])->toMediaCollection(FrontPatientTestimonial::FRONT_PATIENT_PROFILE, config('app.media_disc')); } DB::commit(); return true; } catch (Exception $e) { DB::rollBack(); throw new UnprocessableEntityHttpException($e->getMessage()); } } /** * @param array $input * @param int $id * @return bool */ public function update($input, $id) { try { DB::beginTransaction(); $slider = FrontPatientTestimonial::findOrFail($id); $slider->update($input); if (isset($input['profile']) && ! empty($input['profile'])) { $slider->clearMediaCollection(FrontPatientTestimonial::FRONT_PATIENT_PROFILE); $slider->media()->delete(); $slider->addMedia($input['profile'])->toMediaCollection(FrontPatientTestimonial::FRONT_PATIENT_PROFILE, config('app.media_disc')); } DB::commit(); return true; } catch (Exception $e) { DB::rollBack(); throw new UnprocessableEntityHttpException($e->getMessage()); } } }