File manager - Edit - /var/www/html/spdc/api/app/Http/Services/SignatureService.php
Back
<?php namespace App\Http\Services; use App\Models\Signature; use Illuminate\Http\Request; use App\Classes\BaseServiceResponse; use Intervention\Image\Facades\Image; use Illuminate\Support\Facades\Storage; use App\Http\Resources\SignatureResource; class SignatureService extends BaseService { public function sign(array $inputs, string $signatureableType, string $signatureableId): BaseServiceResponse { // convert to file $path = uploadFile($inputs['signature_file'], 'temp'); if (empty($path)) { return $this->response([], 422, 'Invalid file input.'); } // rotate -90 $file = Storage::get($path); $image = Image::make($file)->rotate(-90)->encode('png'); $image->save(storage_path("app/$path")); // convert to base64 $signatureBase64 = base64_encode(Storage::get($path)); // save $signature = Signature::create([ ...$inputs, 'file' => $signatureBase64, 'signatureable_id' => $signatureableId, 'signatureable_type' => $signatureableType ]); // deleting file from storage Storage::delete($path); return $this->response(new SignatureResource($signature)); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings