mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-17 02:35:02 +00:00
Billing profile implementation
This commit is contained in:
@@ -4,9 +4,12 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Oasis\Client;
|
||||
use App\Models\Oasis\Invoice;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Factories\Sequence;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SetupOasisEnvironment extends Command
|
||||
{
|
||||
@@ -44,6 +47,7 @@ class SetupOasisEnvironment extends Command
|
||||
$this->info('Setting up Oasis environment');
|
||||
|
||||
$this->create_demo_content();
|
||||
$this->set_oasis_data();
|
||||
|
||||
$this->info('Dispatching jobs...');
|
||||
$this->call('queue:work', [
|
||||
@@ -58,6 +62,33 @@ class SetupOasisEnvironment extends Command
|
||||
$user = User::whereEmail('howdy@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$hash = Str::random(12);
|
||||
|
||||
// Get invoice logo and stamp
|
||||
Storage::putFileAs("system", storage_path("demo/app/logo-horizontal.svg"), "{$hash}-logo-horizontal.svg", "private");
|
||||
Storage::putFileAs("system", storage_path("demo/oasis/stamp.png"), "{$hash}-stamp.png", "private");
|
||||
|
||||
$profile = $user->invoiceProfile()->create([
|
||||
'company' => 'VueFileManager Inc.',
|
||||
'registration_notes' => 'Registrácia na OR SR Bratislava I. oddiel: Sro vl. č. 91906',
|
||||
'logo' => "system/{$hash}-logo-horizontal.svg",
|
||||
'ico' => '46530045',
|
||||
'dic' => '2023489457',
|
||||
'ic_dph' => 'SK2023489457',
|
||||
'address' => 'Does 11',
|
||||
'state' => 'Slovakia',
|
||||
'city' => 'Bratislava',
|
||||
'postal_code' => '04001',
|
||||
'country' => 'SK',
|
||||
'bank' => 'Fio Banka',
|
||||
'iban' => 'SK20000054236423624',
|
||||
'swift' => 'FIOZXXX',
|
||||
'phone' => '+421950123456',
|
||||
'email' => 'howdy@hi5ve.digital',
|
||||
'author' => 'John Doe',
|
||||
'stamp' => "system/{$hash}-stamp.png",
|
||||
]);
|
||||
|
||||
$clients = Client::factory(Client::class)
|
||||
->count(6)
|
||||
->create(['user_id' => $user->id]);
|
||||
@@ -72,8 +103,10 @@ class SetupOasisEnvironment extends Command
|
||||
['client_id' => $clients[5]->id],
|
||||
))->count(2)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'invoice_type' => 'regular-invoice'
|
||||
'user_id' => $user->id,
|
||||
'invoice_type' => 'regular-invoice',
|
||||
'discount_type' => null,
|
||||
'user' => $profile->toArray(),
|
||||
]);
|
||||
|
||||
$advance_invoices = Invoice::factory(Invoice::class)
|
||||
@@ -89,6 +122,7 @@ class SetupOasisEnvironment extends Command
|
||||
'user_id' => $user->id,
|
||||
'invoice_type' => 'advance-invoice',
|
||||
'discount_type' => null,
|
||||
'user' => $profile->toArray(),
|
||||
]);
|
||||
|
||||
// Generate PDF
|
||||
@@ -109,4 +143,13 @@ class SetupOasisEnvironment extends Command
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public function set_oasis_data()
|
||||
{
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'app_color'
|
||||
], [
|
||||
'value' => '#ae5fec'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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";
|
||||
|
||||
@@ -21,7 +21,9 @@ class Invoice extends Model
|
||||
'client' => 'array',
|
||||
];
|
||||
|
||||
public $guarded = ['id'];
|
||||
public $guarded = [
|
||||
'id'
|
||||
];
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user