Remove links to multidatabaseuserprovider

This commit is contained in:
David Bomba 2019-08-14 15:40:22 +10:00
parent 434d4a46d7
commit dc65ede956
8 changed files with 78 additions and 35 deletions

View File

@ -59,28 +59,7 @@ class InvoiceController extends Controller
} }
$builder->addAction(); $data['html'] = $builder;
$builder->addCheckbox();
/**todo this is redundant, but keep in case we want to build this serverside*/
$html = $builder->columns([
['data' => 'checkbox', 'name' => 'checkbox', 'title' => '', 'searchable' => false, 'orderable' => false],
['data' => 'invoice_number', 'name' => 'invoice_number', 'title' => trans('texts.invoice_number'), 'visible'=> true],
['data' => 'invoice_date', 'name' => 'invoice_date', 'title' => trans('texts.invoice_date'), 'visible'=> true],
['data' => 'amount', 'name' => 'amount', 'title' => trans('texts.total'), 'visible'=> true],
['data' => 'balance', 'name' => 'balance', 'title' => trans('texts.balance'), 'visible'=> true],
['data' => 'due_date', 'name' => 'due_date', 'title' => trans('texts.due_date'), 'visible'=> true],
['data' => 'status', 'name' => 'status', 'title' => trans('texts.status'), 'visible'=> true],
['data' => 'action', 'name' => 'action', 'title' => '', 'searchable' => false, 'orderable' => false],
]);
$builder->ajax([
'url' => route('client.invoices.index'),
'type' => 'GET',
'data' => 'function(d) { d.key = "value"; }',
]);
$data['html'] = $html;
return view('portal.default.invoices.index', $data); return view('portal.default.invoices.index', $data);
@ -100,13 +79,28 @@ class InvoiceController extends Controller
} }
/** /**
* Perform bulk actions on the list view * Pay one or more invoices
* *
* @return Collection * @return View
*/ */
public function bulk() public function payment()
{ {
$transformed_ids = $this->transformKeys(request()->input('hashed_ids'));
$invoices = Invoice::whereIn('id', $transformed_ids)
->whereClientId(auth()->user()->client->id)
->get()
->filter(function ($invoice){
return $invoice->isPayable();
});
$data = [
'invoices' => $invoices,
];
return view('portal.default.invoices.payment', $data);
} }

View File

@ -195,6 +195,11 @@ class Invoice extends BaseModel
$this->last_viewed = Carbon::now()->format('Y-m-d H:i'); $this->last_viewed = Carbon::now()->format('Y-m-d H:i');
} }
public function isPayable()
{
return ($this->status === Invoice::STATUS_UNPAID || $this->status === Invoice::STATUS_OVERDUE);
}
public static function badgeForStatus(int $status) public static function badgeForStatus(int $status)
{ {
switch ($status) { switch ($status) {

View File

@ -61,7 +61,7 @@ class AuthServiceProvider extends ServiceProvider
public function boot() public function boot()
{ {
$this->registerPolicies(); $this->registerPolicies();
/*
Auth::provider('users', function ($app, array $config) { Auth::provider('users', function ($app, array $config) {
return new MultiDatabaseUserProvider($this->app['hash'], $config['model']); return new MultiDatabaseUserProvider($this->app['hash'], $config['model']);
}); });
@ -70,7 +70,7 @@ class AuthServiceProvider extends ServiceProvider
return new MultiDatabaseUserProvider($this->app['hash'], $config['model']); return new MultiDatabaseUserProvider($this->app['hash'], $config['model']);
}); });
*/
Gate::define('view-list', function ($user, $entity) { Gate::define('view-list', function ($user, $entity) {
$entity = strtolower(class_basename($entity)); $entity = strtolower(class_basename($entity));

View File

@ -73,11 +73,14 @@ return [
'providers' => [ 'providers' => [
'users' => [ 'users' => [
'driver' => env('USER_AUTH_PROVIDER', 'eloquent'), 'driver' => 'eloquent',
//'driver' => env('USER_AUTH_PROVIDER', 'eloquent'),
'model' => App\Models\User::class, 'model' => App\Models\User::class,
], ],
'contacts' => [ 'contacts' => [
'driver' => env('CONTACT_AUTH_PROVIDER', 'eloquent'), 'driver' => 'eloquent',
// 'driver' => env('CONTACT_AUTH_PROVIDER', 'eloquent'),
'model' => App\Models\ClientContact::class, 'model' => App\Models\ClientContact::class,
], ],

View File

@ -7,7 +7,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Invoice::class, function (Faker $faker) { $factory->define(App\Models\Invoice::class, function (Faker $faker) {
return [ return [
'status_id' => App\Models\Invoice::STATUS_SENT, 'status_id' => App\Models\Invoice::STATUS_SENT,
'invoice_number' => $faker->text(256), 'invoice_number' => $faker->uuid(),
'discount' => $faker->numberBetween(1,10), 'discount' => $faker->numberBetween(1,10),
'is_amount_discount' => $faker->boolean(), 'is_amount_discount' => $faker->boolean(),
'tax_name1' => 'GST', 'tax_name1' => 'GST',

View File

@ -20,7 +20,7 @@
<span class="sr-only">Toggle Dropdown</span> <span class="sr-only">Toggle Dropdown</span>
</button> </button>
<div class="dropdown-menu"> <div class="dropdown-menu">
<a class="dropdown-item" id="download_invoices" href="#">{{ctrans('texts.download')}}</a> <a class="dropdown-item" id="download_invoices">{{ctrans('texts.download_pdf')}}</a>
</div> </div>
</div> </div>
@ -149,11 +149,30 @@ $(document).ready(function() {
$(this).closest('table').find(':checkbox:not(:disabled)').prop('checked', this.checked); $(this).closest('table').find(':checkbox:not(:disabled)').prop('checked', this.checked);
}); });
$('.btn .btn-success .pay_invoices').click(function() { $('#pay_invoices').click(function() {
alert('pay');
$('#pay_invoices').addClass('disabled');
$('#pay_invoices_drop').addClass('disabled');
$('#download_invoices').addClass('disabled');
$.ajax({
url: "{{ route('client.invoices.payment')}}",
type: "post",
data: {
_token: '{{ csrf_token() }}',
hashed_ids: selected
},
success: function (response) {
// You will get response from your PHP page (what you echo or print)
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
}); });
$('.download_invoices').click(function() { $('#download_invoices').click(function() {
alert('download'); alert('download');
}); });

View File

@ -0,0 +1,21 @@
@extends('portal.default.layouts.master')
@section('header')
@stop
@section('body')
<main class="main">
<div class="container-fluid">
<div class="row" style="padding-top: 30px;">
</div>
</div>
</main>
</body>
@endsection
@push('scripts')
@endpush
@section('footer')
@endsection

View File

@ -15,7 +15,8 @@ Route::post('client/password/reset', 'Auth\ContactResetPasswordController@reset'
Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'client.'], function () { Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'client.'], function () {
Route::get('dashboard', 'ClientPortal\DashboardController@index')->name('dashboard'); // name = (dashboard. index / create / show / update / destroy / edit Route::get('dashboard', 'ClientPortal\DashboardController@index')->name('dashboard'); // name = (dashboard. index / create / show / update / destroy / edit
Route::get('invoices', 'ClientPortal\InvoiceController@index')->name('invoices.index'); // name = (dashboard. index / create / show / update / destroy / edit Route::get('invoices', 'ClientPortal\InvoiceController@index')->name('invoices.index');
Route::post('invoices', 'ClientPortal\InvoiceController@payment')->name('invoices.payment');
Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit'); Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit');
Route::put('profile/{client_contact}/edit', 'ClientPortal\ProfileController@update')->name('profile.update'); Route::put('profile/{client_contact}/edit', 'ClientPortal\ProfileController@update')->name('profile.update');
Route::put('profile/{client_contact}/edit_client', 'ClientPortal\ProfileController@updateClient')->name('profile.edit_client'); Route::put('profile/{client_contact}/edit_client', 'ClientPortal\ProfileController@updateClient')->name('profile.edit_client');