Server : LiteSpeed System : Linux server335.web-hosting.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : cardxfeb ( 2452) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/cardxfeb/www/app/Repositories/ |
<?php
namespace App\Repositories;
use App\Models\Feature;
use Spatie\MediaLibrary\MediaCollections\Exceptions\FileDoesNotExist;
use Spatie\MediaLibrary\MediaCollections\Exceptions\FileIsTooBig;
/**
* Class featureRepository
*/
class featureRepository extends BaseRepository
{
/**
* @var array
*/
protected $fieldSearchable = [
'name', 'description',
];
/**
* Return searchable fields
*/
public function getFieldsSearchable(): array
{
return $this->fieldSearchable;
}
/**
* Configure the Model
**/
public function model()
{
return Feature::class;
}
/**
* @throws FileIsTooBig
* @throws FileDoesNotExist
*/
public function update($input, $id)
{
$language = $input['language'];
// Generate slug if not providd
if (empty($input['slug'])) {
$count = Feature::where('language', $language)->count();
$input['slug'] = $language . '.features.' . ($count + 1);
}
$feature = Feature::findOrFail($id);
//$feature = Feature::find($id);
if($feature){
$feature->update($input);
}else{
$feature = Feature::create($input);
}
if (isset($input['featureImage']) && ! empty($input['featureImage'])) {
$feature->clearMediaCollection(Feature::PROFILE);
$feature->addMedia($input['featureImage'])->toMediaCollection(Feature::PROFILE, config('app.media_disc'));
}
return $feature;
}
}