added admin/portal/signed route macros
This commit is contained in:
parent
2b07442260
commit
231f45c262
@ -139,14 +139,14 @@ abstract class PaymentController extends BaseController
|
|||||||
|
|
||||||
public function getNotifyUrl($invoice)
|
public function getNotifyUrl($invoice)
|
||||||
{
|
{
|
||||||
return route('portal.invoices.' . $this->alias . '.notify', $invoice->id);
|
return route('portal.' . $this->alias . '.invoices.notify', $invoice->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getModuleUrl($invoice, $suffix)
|
public function getModuleUrl($invoice, $suffix)
|
||||||
{
|
{
|
||||||
return $this->user
|
return $this->user
|
||||||
? route('portal.invoices.' . $this->alias . '.' . $suffix, $invoice->id)
|
? route('portal.' . $this->alias . '.invoices.' . $suffix, $invoice->id)
|
||||||
: URL::signedRoute('signed.invoices.' . $this->alias . '.' . $suffix, [$invoice->id, 'company_id' => $invoice->company_id]);
|
: URL::signedRoute('signed.' . $this->alias . '.invoices.' . $suffix, [$invoice->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLogger()
|
public function getLogger()
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::group([
|
/**
|
||||||
'middleware' => 'admin',
|
* 'admin' middleware and '$ALIAS$' prefix applied to all routes (including names)
|
||||||
'as' => '$ALIAS$.',
|
*
|
||||||
'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers'
|
* @see \App\Providers\Route::register
|
||||||
], function () {
|
*/
|
||||||
Route::prefix('$ALIAS$')->group(function() {
|
|
||||||
// Route::get('/', 'Main@index');
|
Route::admin('$ALIAS$', function () {
|
||||||
});
|
Route::get('/', 'Main@index');
|
||||||
});
|
});
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::group([
|
/**
|
||||||
'prefix' => 'portal',
|
* 'portal' middleware and 'portal/$ALIAS$' prefix applied to all routes (including names)
|
||||||
'middleware' => 'portal',
|
*
|
||||||
'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers'
|
* @see \App\Providers\Route::register
|
||||||
], function () {
|
*/
|
||||||
// Route::get('invoices/{invoice}/$ALIAS$', 'Main@show')->name('portal.invoices.$ALIAS$.show');
|
|
||||||
// Route::post('invoices/{invoice}/$ALIAS$/confirm', 'Main@confirm')->name('portal.invoices.$ALIAS$.confirm');
|
Route::portal('$ALIAS$', function () {
|
||||||
|
// Route::get('invoices/{invoice}', 'Main@show')->name('invoices.show');
|
||||||
|
// Route::post('invoices/{invoice}/confirm', 'Main@confirm')->name('invoices.confirm');
|
||||||
});
|
});
|
||||||
|
@ -108,7 +108,7 @@ class Invoices extends Controller
|
|||||||
public function signed(Document $invoice)
|
public function signed(Document $invoice)
|
||||||
{
|
{
|
||||||
if (empty($invoice)) {
|
if (empty($invoice)) {
|
||||||
redirect()->route('login');
|
return redirect()->route('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
$payment_actions = [];
|
$payment_actions = [];
|
||||||
@ -119,7 +119,7 @@ class Invoices extends Controller
|
|||||||
$codes = explode('.', $payment_method_key);
|
$codes = explode('.', $payment_method_key);
|
||||||
|
|
||||||
if (!isset($payment_actions[$codes[0]])) {
|
if (!isset($payment_actions[$codes[0]])) {
|
||||||
$payment_actions[$codes[0]] = URL::signedRoute('signed.invoices.' . $codes[0] . '.show', [$invoice->id]);
|
$payment_actions[$codes[0]] = URL::signedRoute('signed.' . $codes[0] . '.invoices.show', [$invoice->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,73 @@ class Route extends Provider
|
|||||||
*/
|
*/
|
||||||
protected $namespace = 'App\Http\Controllers';
|
protected $namespace = 'App\Http\Controllers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
parent::register();
|
||||||
|
|
||||||
|
Facade::macro('module', function ($alias, $routes, $attrs) {
|
||||||
|
$attributes = [
|
||||||
|
'middleware' => $attrs['middleware'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isset($attrs['namespace'])) {
|
||||||
|
// null means don't add
|
||||||
|
if (!is_null($attrs['namespace'])) {
|
||||||
|
$attributes['namespace'] = $attrs['namespace'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$attributes['namespace'] = 'Modules\\' . module($alias)->getStudlyName() . '\Http\Controllers';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($attrs['prefix'])) {
|
||||||
|
// null means don't add
|
||||||
|
if (!is_null($attrs['prefix'])) {
|
||||||
|
$attributes['prefix'] = '{company_id}/' . $attrs['prefix'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$attributes['prefix'] = '{company_id}/' . $alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($attrs['as'])) {
|
||||||
|
// null means don't add
|
||||||
|
if (!is_null($attrs['as'])) {
|
||||||
|
$attributes['as'] = $attrs['as'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$attributes['as'] = $alias . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return Facade::group($attributes, $routes);
|
||||||
|
});
|
||||||
|
|
||||||
|
Facade::macro('admin', function ($alias, $routes, $attributes = []) {
|
||||||
|
return Facade::module($alias, $routes, array_merge([
|
||||||
|
'middleware' => 'admin',
|
||||||
|
], $attributes));
|
||||||
|
});
|
||||||
|
|
||||||
|
Facade::macro('portal', function ($alias, $routes, $attributes = []) {
|
||||||
|
return Facade::module($alias, $routes, array_merge([
|
||||||
|
'middleware' => 'portal',
|
||||||
|
'prefix' => 'portal/' . $alias,
|
||||||
|
'as' => 'portal.' . $alias . '.',
|
||||||
|
], $attributes));
|
||||||
|
});
|
||||||
|
|
||||||
|
Facade::macro('signed', function ($alias, $routes, $attributes = []) {
|
||||||
|
return Facade::module($alias, $routes, array_merge([
|
||||||
|
'middleware' => 'signed',
|
||||||
|
'prefix' => 'signed/' . $alias,
|
||||||
|
'as' => 'signed.' . $alias . '.',
|
||||||
|
], $attributes));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the routes for the application.
|
* Define the routes for the application.
|
||||||
*
|
*
|
||||||
|
2
resources/assets/js/views/portal/invoices.js
vendored
2
resources/assets/js/views/portal/invoices.js
vendored
@ -55,7 +55,7 @@ const app = new Vue({
|
|||||||
|
|
||||||
let method = payment_method.split('.');
|
let method = payment_method.split('.');
|
||||||
|
|
||||||
let path = url + '/portal/invoices/' + this.form.document_id + '/' + method[0];
|
let path = url + '/portal/' + method[0] + '/invoices/' + this.form.document_id;
|
||||||
|
|
||||||
this.method_show_html = Vue.component('payment-method-confirm', function (resolve, reject) {
|
this.method_show_html = Vue.component('payment-method-confirm', function (resolve, reject) {
|
||||||
resolve({
|
resolve({
|
||||||
|
@ -27,8 +27,6 @@ abstract class FeatureTestCase extends TestCase
|
|||||||
|
|
||||||
// Disable debugbar
|
// Disable debugbar
|
||||||
config(['debugbar.enabled', false]);
|
config(['debugbar.enabled', false]);
|
||||||
|
|
||||||
app('url')->defaults(['company_id' => $this->company->id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,10 +44,10 @@ abstract class FeatureTestCase extends TestCase
|
|||||||
|
|
||||||
if ($company) {
|
if ($company) {
|
||||||
$company->makeCurrent();
|
$company->makeCurrent();
|
||||||
|
|
||||||
app('url')->defaults(['company_id' => $company->id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app('url')->defaults(['company_id' => company_id()]);
|
||||||
|
|
||||||
return $this->actingAs($user);
|
return $this->actingAs($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user