Skip to content

Commit

Permalink
Resolve issues with Voyager 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
classiebit-sumit committed Nov 2, 2019
1 parent ef46bb3 commit c1af437
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/Http/Controllers/Voyager/BookingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use TCG\Voyager\Http\Controllers\Traits\BreadRelationshipParser;
use Illuminate\Http\RedirectResponse;

use Auth;


class BookingsController extends VoyagerBaseController
{
Expand Down Expand Up @@ -90,7 +92,7 @@ public function index(Request $request)
}

// Use withTrashed() if model uses SoftDeletes and if toggle is selected
if ($model && in_array(SoftDeletes::class, class_uses($model)) && app('VoyagerAuth')->user()->can('delete', app($dataType->model_name))) {
if ($model && in_array(SoftDeletes::class, class_uses($model)) && Auth::user()->can('delete', app($dataType->model_name))) {
$usesSoftDeletes = true;

if ($request->get('showSoftDeleted')) {
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/Voyager/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use TCG\Voyager\Http\Controllers\Traits\BreadRelationshipParser;
use Illuminate\Http\RedirectResponse;

use Auth;

class ContactsController extends VoyagerBaseController
{
Expand Down Expand Up @@ -92,7 +93,7 @@ public function index(Request $request)
}

// Use withTrashed() if model uses SoftDeletes and if toggle is selected
if ($model && in_array(SoftDeletes::class, class_uses($model)) && app('VoyagerAuth')->user()->can('delete', app($dataType->model_name))) {
if ($model && in_array(SoftDeletes::class, class_uses($model)) && Auth::user()->can('delete', app($dataType->model_name))) {
$usesSoftDeletes = true;

if ($request->get('showSoftDeleted')) {
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/Voyager/EventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use TCG\Voyager\Http\Controllers\Traits\BreadRelationshipParser;
use Illuminate\Http\RedirectResponse;

use Auth;

class EventsController extends VoyagerBaseController
{
Expand Down Expand Up @@ -97,7 +98,7 @@ public function index(Request $request)
}

// Use withTrashed() if model uses SoftDeletes and if toggle is selected
if ($model && in_array(SoftDeletes::class, class_uses($model)) && app('VoyagerAuth')->user()->can('delete', app($dataType->model_name))) {
if ($model && in_array(SoftDeletes::class, class_uses($model)) && Auth::user()->can('delete', app($dataType->model_name))) {
$usesSoftDeletes = true;

if ($request->get('showSoftDeleted')) {
Expand Down
4 changes: 3 additions & 1 deletion src/Http/Controllers/Voyager/VoyagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

use TCG\Voyager\Http\Controllers\VoyagerController as BaseVoyagerController;

use Auth;

class VoyagerController extends BaseVoyagerController
{
public function index()
Expand All @@ -14,7 +16,7 @@ public function index()

public function logout()
{
app('VoyagerAuth')->logout();
Auth::logout();

return redirect(config('eventmie.route.prefix').'/'.config('eventmie.route.admin_prefix'));
}
Expand Down
9 changes: 5 additions & 4 deletions src/Http/Controllers/Voyager/VoyagerUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

use TCG\Voyager\Http\Controllers\VoyagerUserController as BaseVoyagerUserController;

use Auth;

class VoyagerUserController extends BaseVoyagerUserController
{
// POST BR(E)AD
Expand All @@ -24,11 +26,10 @@ public function update(Request $request, $id)
->send();
}

if (app('VoyagerAuth')->user()->getKey() == $id) {
if (Auth::user()->getKey() == $id) {
$request->merge([
'role_id' => app('VoyagerAuth')->user()->role_id,
'user_belongsto_role_relationship' => app('VoyagerAuth')->user()->role_id,
'user_belongstomany_role_relationship' => app('VoyagerAuth')->user()->roles->pluck('id')->toArray(),
'role_id' => Auth::user()->role_id,
'user_belongstomany_role_relationship' => Auth::user()->roles->pluck('id')->toArray(),
]);
}

Expand Down
6 changes: 4 additions & 2 deletions src/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Traits\Translatable;

use Auth;

class Page extends Model
{
use Translatable;
Expand All @@ -28,8 +30,8 @@ class Page extends Model
public function save(array $options = [])
{
// If no author has been assigned, assign the current user's id as the author of the post
if (!$this->author_id && app('VoyagerAuth')->user()) {
$this->author_id = app('VoyagerAuth')->user()->getKey();
if (!$this->author_id && Auth::user()) {
$this->author_id = Auth::user()->getKey();
}

parent::save();
Expand Down

0 comments on commit c1af437

Please sign in to comment.