2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2019-04-24 02:22:02 +02:00
|
|
|
use App\Models\InvoiceInvitation;
|
|
|
|
use App\Models\QuoteInvitation;
|
|
|
|
use App\Models\RecurringInvoiceInvitation;
|
2019-04-03 03:17:21 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2018-10-15 07:00:48 +02:00
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
2019-04-03 03:17:21 +02:00
|
|
|
use Illuminate\Support\Facades\Route;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
class RouteServiceProvider extends ServiceProvider
|
|
|
|
{
|
2019-04-03 03:17:21 +02:00
|
|
|
use MakesHash;
|
2018-10-04 19:10:43 +02:00
|
|
|
/**
|
|
|
|
* This namespace is applied to your controller routes.
|
|
|
|
*
|
|
|
|
* In addition, it is set as the URL generator's root namespace.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $namespace = 'App\Http\Controllers';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define your route model bindings, pattern filters, etc.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
|
|
|
|
parent::boot();
|
2018-11-12 08:52:20 +01:00
|
|
|
|
|
|
|
Route::bind('client', function ($value) {
|
2019-04-02 08:36:49 +02:00
|
|
|
$client = \App\Models\Client::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2019-04-02 08:43:17 +02:00
|
|
|
// $client->with('contacts', 'primary_contact','country');
|
2018-11-22 12:12:41 +01:00
|
|
|
return $client;
|
2018-11-12 08:52:20 +01:00
|
|
|
});
|
2018-11-20 05:36:56 +01:00
|
|
|
|
|
|
|
Route::bind('invoice', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\Invoice::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('payment', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\Payment::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('product', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\Product::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('company', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\Company::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('account', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\Account::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('client_contact', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\ClientContact::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('expense', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\Expense::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
2019-04-24 02:22:02 +02:00
|
|
|
Route::bind('invoice_invitation', function ($value) {
|
|
|
|
return \App\Models\InvoiceInvitation::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('recurring_invoice_invitation', function ($value) {
|
|
|
|
return \App\Models\RecurringInvoiceInvitation::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('quote_invitation', function ($value) {
|
|
|
|
return \App\Models\QuoteInvitation::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('task', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\Task::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('tax_rate', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\TaxRate::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
Route::bind('proposal', function ($value) {
|
2019-04-02 08:43:17 +02:00
|
|
|
return \App\Models\Proposal::where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
2018-11-20 05:36:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the routes for the application.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function map()
|
|
|
|
{
|
|
|
|
$this->mapApiRoutes();
|
|
|
|
|
|
|
|
$this->mapWebRoutes();
|
|
|
|
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the "web" routes for the application.
|
|
|
|
*
|
|
|
|
* These routes all receive session state, CSRF protection, etc.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function mapWebRoutes()
|
|
|
|
{
|
|
|
|
Route::middleware('web')
|
|
|
|
->namespace($this->namespace)
|
|
|
|
->group(base_path('routes/web.php'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the "api" routes for the application.
|
|
|
|
*
|
|
|
|
* These routes are typically stateless.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function mapApiRoutes()
|
|
|
|
{
|
2019-04-02 08:36:49 +02:00
|
|
|
Route::prefix('')
|
2018-10-04 19:10:43 +02:00
|
|
|
->middleware('api')
|
|
|
|
->namespace($this->namespace)
|
|
|
|
->group(base_path('routes/api.php'));
|
|
|
|
}
|
2019-03-27 05:50:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|