Skip to content

Commit

Permalink
v6 update
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpanjwani committed Jan 10, 2022
1 parent b770e62 commit bdea879
Show file tree
Hide file tree
Showing 722 changed files with 18,963 additions and 9,102 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ SANCTUM_STATEFUL_DOMAINS=crater.test
SESSION_DOMAIN=crater.test

TRUSTED_PROXIES="*"

CRON_JOB_AUTH_TOKEN=""
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/Modules
/node_modules
/public/storage
/public/hot
Expand All @@ -12,3 +13,4 @@ Homestead.yaml
/.expo
/.vscode
/docker-compose/db/data/
.gitkeep
45 changes: 45 additions & 0 deletions app/Console/Commands/InstallModuleCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Crater\Console\Commands;

use Crater\Space\ModuleInstaller;
use Illuminate\Console\Command;

class InstallModuleCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'install:module {module} {version}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Install cloned module.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
ModuleInstaller::complete($this->argument('module'), $this->argument('version'));

return Command::SUCCESS;
}
}
3 changes: 2 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class Kernel extends ConsoleKernel
protected $commands = [
Commands\ResetApp::class,
Commands\UpdateCommand::class,
Commands\CreateTemplateCommand::class
Commands\CreateTemplateCommand::class,
Commands\InstallModuleCommand::class,
];

/**
Expand Down
26 changes: 26 additions & 0 deletions app/Events/ModuleDisabledEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Crater\Events;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ModuleDisabledEvent
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $module;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct($module)
{
$this->module = $module;
}
}
26 changes: 26 additions & 0 deletions app/Events/ModuleEnabledEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Crater\Events;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ModuleEnabledEvent
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $module;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct($module)
{
$this->module = $module;
}
}
26 changes: 26 additions & 0 deletions app/Events/ModuleInstalledEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Crater\Events;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ModuleInstalledEvent
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $module;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct($module)
{
$this->module = $module;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public function __invoke(Request $request, Estimate $estimate, Invoice $invoice)
'base_total' => $estimate->total * $exchange_rate,
'base_tax' => $estimate->tax * $exchange_rate,
'currency_id' => $estimate->currency_id,
'sales_tax_type' => $estimate->sales_tax_type,
'sales_tax_address_type' => $estimate->sales_tax_address_type,
]);

$invoice->unique_hash = Hashids::connection(Invoice::class)->encode($invoice->id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public function __invoke(SendEstimatesRequest $request, Estimate $estimate)

$markdown = new Markdown(view(), config('mail.markdown'));

return $markdown->render('emails.send.estimate', ['data' => $estimate->sendEstimateData($request->all())]);
$data = $estimate->sendEstimateData($request->all());
$data['url'] = $estimate->estimatePdfUrl;

return $markdown->render('emails.send.estimate', ['data' => $data]);
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/V1/Admin/Expense/ExpensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function index(Request $request)
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Crater\Http\Requests\ExpenseRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function store(ExpenseRequest $request)
Expand Down Expand Up @@ -67,7 +67,7 @@ public function show(Expense $expense)
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Crater\Http\Requests\ExpenseRequest $request
* @param \Crater\Models\Expense $expense
* @return \Illuminate\Http\JsonResponse
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
namespace Crater\Http\Controllers\V1\Admin\Expense;

use Crater\Http\Controllers\Controller;
use Crater\Http\Requests\ExpenseRequest;
use Crater\Models\Expense;
use Illuminate\Http\Request;

class UploadReceiptController extends Controller
{
/**
* Upload the expense receipts to storage.
*
* @param \Illuminate\Http\Request $request
* @param \Crater\Http\Requests\ExpenseRequest $request
* @param Expense $expense
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(Request $request, Expense $expense)
public function __invoke(ExpenseRequest $request, Expense $expense)
{
$this->authorize('update', $expense);

Expand Down
6 changes: 6 additions & 0 deletions app/Http/Controllers/V1/Admin/General/BootstrapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Crater\Models\Company;
use Crater\Models\CompanySetting;
use Crater\Models\Currency;
use Crater\Models\Module;
use Crater\Models\Setting;
use Crater\Traits\GeneratesMenuTrait;
use Illuminate\Http\Request;
use Silber\Bouncer\BouncerFacade;
Expand Down Expand Up @@ -47,6 +49,8 @@ public function __invoke(Request $request)

BouncerFacade::refreshFor($current_user);

$global_settings = Setting::getSettings(['api_token', 'admin_portal_theme']);

return response()->json([
'current_user' => new UserResource($current_user),
'current_user_settings' => $current_user_settings,
Expand All @@ -56,8 +60,10 @@ public function __invoke(Request $request)
'current_company_settings' => $current_company_settings,
'current_company_currency' => $current_company_currency,
'config' => config('crater'),
'global_settings' => $global_settings,
'main_menu' => $main_menu,
'setting_menu' => $setting_menu,
'modules' => Module::where('enabled', true)->pluck('name'),
]);
}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/V1/Admin/General/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __invoke(Request $request)
$user = $request->user();

$customers = Customer::applyFilters($request->only(['search']))
->whereCompany()
->latest()
->paginate(10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function __invoke(Request $request, Invoice $invoice)
'base_tax' => $invoice->tax * $exchange_rate,
'base_due_amount' => $invoice->total * $exchange_rate,
'currency_id' => $invoice->currency_id,
'sales_tax_type' => $invoice->sales_tax_type,
'sales_tax_address_type' => $invoice->sales_tax_address_type,
]);

$newInvoice->unique_hash = Hashids::connection(Invoice::class)->encode($newInvoice->id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public function __invoke(SendInvoiceRequest $request, Invoice $invoice)

$markdown = new Markdown(view(), config('mail.markdown'));

return $markdown->render('emails.send.invoice', ['data' => $invoice->sendInvoiceData($request->all())]);
$data = $invoice->sendInvoiceData($request->all());
$data['url'] = $invoice->invoicePdfUrl;

return $markdown->render('emails.send.invoice', ['data' => $data]);
}
}
25 changes: 25 additions & 0 deletions app/Http/Controllers/V1/Admin/Modules/ApiTokenController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Crater\Http\Controllers\V1\Admin\Modules;

use Crater\Http\Controllers\Controller;
use Crater\Space\ModuleInstaller;
use Illuminate\Http\Request;

class ApiTokenController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request)
{
$this->authorize('manage modules');

$response = ModuleInstaller::checkToken($request->api_token);

return $response;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Crater\Http\Controllers\V1\Admin\Modules;

use Crater\Http\Controllers\Controller;
use Crater\Space\ModuleInstaller;
use Illuminate\Http\Request;

class CompleteModuleInstallationController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request)
{
$this->authorize('manage modules');

$response = ModuleInstaller::complete($request->module, $request->version);

return response()->json([
'success' => $response
]);
}
}
27 changes: 27 additions & 0 deletions app/Http/Controllers/V1/Admin/Modules/CopyModuleController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Crater\Http\Controllers\V1\Admin\Modules;

use Crater\Http\Controllers\Controller;
use Crater\Space\ModuleInstaller;
use Illuminate\Http\Request;

class CopyModuleController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request)
{
$this->authorize('manage modules');

$response = ModuleInstaller::copyFiles($request->module, $request->path);

return response()->json([
'success' => $response
]);
}
}
32 changes: 32 additions & 0 deletions app/Http/Controllers/V1/Admin/Modules/DisableModuleController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Crater\Http\Controllers\V1\Admin\Modules;

use Crater\Events\ModuleDisabledEvent;
use Crater\Http\Controllers\Controller;
use Crater\Models\Module as ModelsModule;
use Illuminate\Http\Request;
use Nwidart\Modules\Facades\Module;

class DisableModuleController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request, string $module)
{
$this->authorize('manage modules');

$module = ModelsModule::where('name', $module)->first();
$module->update(['enabled' => false]);
$installedModule = Module::find($module->name);
$installedModule->disable();

ModuleDisabledEvent::dispatch($module);

return response()->json(['success' => true]);
}
}
Loading

0 comments on commit bdea879

Please sign in to comment.