Billing profile implementation

This commit is contained in:
Peter Papp
2021-04-28 15:55:01 +02:00
parent 1e4bbd10f3
commit b37edd298a
18 changed files with 582 additions and 183 deletions
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use App\Http\Resources\Oasis\InvoiceProfileResource;
use App\Models\Oasis\InvoiceProfile;
use App\Models\Setting;
use Auth;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\Request;
@@ -13,6 +14,15 @@ use Illuminate\Http\Response;
class InvoiceProfileController extends Controller
{
/**
* @return Application|ResponseFactory|Response
*/
public function show()
{
return response(
new InvoiceProfileResource(Auth::user()->invoiceProfile), 200
);
}
/**
* @param Request $request
* @return Application|ResponseFactory|Response
@@ -21,8 +31,8 @@ class InvoiceProfileController extends Controller
{
$profile = InvoiceProfile::create([
'user_id' => $request->user()->id,
'logo' => store_avatar($request, 'logo') ?? null,
'stamp' => store_avatar($request, 'stamp') ?? null,
'logo' => store_system_image($request, 'logo') ?? null,
'stamp' => store_system_image($request, 'stamp') ?? null,
'company' => $request->company,
'email' => $request->email,
'ico' => $request->ico,
@@ -59,7 +69,7 @@ class InvoiceProfileController extends Controller
$request->user()
->invoiceProfile()
->update([
$request->name => store_avatar($request, $request->name)
$request->name => store_system_image($request, $request->name)
]);
return response('Done', 204);
+14 -6
View File
@@ -290,14 +290,22 @@ function store_avatar($request, $name)
// Store avatar
$image_path = Str::random(16) . '-' . $image->getClientOriginalName();
// Create intervention image
$img = Image::make($image->getRealPath());
if (in_array($image->getClientMimeType(), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp'])) {
// Generate thumbnail
$img->fit('150', '150')->stream();
// Create intervention image
$img = Image::make($image->getRealPath());
// Store thumbnail to disk
Storage::put("avatars/$image_path", $img);
// Generate thumbnail
$img->fit('150', '150')->stream();
// Store thumbnail to disk
Storage::put("avatars/$image_path", $img);
}
if ($image->getClientMimeType() === 'image/svg+xml') {
Storage::putFileAs("avatars", $image, $image_path);
}
// Return path to image
return "avatars/$image_path";