From 66c3c381b13662059c2309d369a0be3c7d666073 Mon Sep 17 00:00:00 2001 From: Austin Stierler Date: Tue, 12 Jan 2016 20:05:10 -0800 Subject: [PATCH] Support for Laravel 5.2 in userResponsible() call (and backward compatible). Also gracefully return false if no class found/doesn't exist, vs. throwing a PHP error about class name --- src/Venturecraft/Revisionable/Revision.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Venturecraft/Revisionable/Revision.php b/src/Venturecraft/Revisionable/Revision.php index ea6b443e..98d429ef 100644 --- a/src/Venturecraft/Revisionable/Revision.php +++ b/src/Venturecraft/Revisionable/Revision.php @@ -194,6 +194,7 @@ private function getValue($which = 'new') */ public function userResponsible() { + if (empty($this->user_id)) { return false; } if (class_exists($class = '\Cartalyst\Sentry\Facades\Laravel\Sentry') || class_exists($class = '\Cartalyst\Sentinel\Laravel\Facades\Sentinel') ) { @@ -201,6 +202,15 @@ public function userResponsible() } else { $user_model = app('config')->get('auth.model'); + if (empty($user_model)) { + $user_model = app('config')->get('auth.providers.users.model'); + if (empty($user_model)) { + return false; + } + } + if (!class_exists($user_model)) { + return false; + } return $user_model::find($this->user_id); } }