⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
hospital.dev-unit.com
/
app
/
Repositories
/
View File Name :
AdminRepository.php
<?php namespace App\Repositories; use App\Models\Department; use App\Models\User; use Carbon\Carbon; use Exception; use Hash; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; /** * Class AdminRepository * * @version October 1, 2022, 7:18 pm UTC */ class AdminRepository extends BaseRepository { /** * @var array */ protected $fieldSearchable = [ 'id', 'first_name', 'last_name', 'email', 'contact_no', 'password', 'confirm_password', 'tenant_id', 'owner_id', 'owner_type', ]; /** * Return searchable fields */ public function getFieldsSearchable(): array { return $this->fieldSearchable; } /** * Configure the Model **/ public function model(): string { return User::class; } public function store($input) { try { $data = [ 'first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'email' => $input['email'], 'password' => Hash::make($input['password']), 'phone' => $input['phone'], 'region_code' => $input['region_code'], 'email_verified_at' => Carbon::now(), 'tenant_id' => null, 'owner_type' => null, 'owner_id' => null, 'status' => 1, 'gender' => 0, 'hospital_name' => '', ]; $user = User::create($data); $input['department_name'] = Department::whereName('Super Admin')->first()->name; $user->assignRole($input['department_name']); return $user; } catch (Exception $e) { throw new UnprocessableEntityHttpException($e->getMessage()); } } public function update($user, $input) { try { $data = [ 'first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'email' => $input['email'], 'phone' => $input['phone'], 'region_code' => $input['region_code'], 'tenant_id' => null, 'owner_type' => null, 'owner_id' => null, ]; if (isset($input['image']) && ! empty($input['image'])) { $mediaId = updateProfileImage($user, $input['image']); } if ($input['avatar_remove'] == 1 && isset($input['avatar_remove']) && ! empty($input['avatar_remove'])) { removeFile($user, User::COLLECTION_PROFILE_PICTURES); } $user->update($data); return true; } catch (Exception $e) { throw new UnprocessableEntityHttpException($e->getMessage()); } } public function delete($id) { try { $user = $this->find($id); $user->clearMediaCollection(User::COLLECTION_PROFILE_PICTURES); $user->delete($id); } catch (Exception $e) { throw new UnprocessableEntityHttpException($e->getMessage()); } } }