In my models I use Ardent for self-validating but I have a model where I also need to use Sentry for authentication. So I need to extend Ardent and Sentry too, but I can't because there is no multiple inheritance in PHP. I tried to do it with traits, but traits can't extend. I hardly need both classes, is there a way I can use both of them?
Asked
Active
Viewed 632 times
6
-
Have you managed to use both Sentry & Ardent? – Javier Enríquez Jun 12 '14 at 20:13
-
@JavierEnríquez No. In the end we used only Sentry and made the validation in the regular way. One possible workaround is to find Sentry's vendor folder and make it extend Ardent. – totymedli Jun 12 '14 at 20:42
1 Answers
1
I think the best way to do this would be to copy the entire User model directly from the Sentry folder: e.g. src/Cartalyst/Sentry/Users/Eloquent/User.php
Copy that file to your models directory, then have it extend Ardent instead of Model since Ardent already extends Model.
This should work -- though there could be some complications or fixes needed to make it work, I'm doing something similar using Toddish/Verify instead of Sentry.

PatrickCurl
- 996
- 1
- 7
- 8
-
it throws error `Declaration of Cartalyst\Sentry\Users\Eloquent\User::validate() should be compatible with LaravelBook\Ardent\Ardent::validate(array $rules = Array, array $customMessages = Array)` – Muflix Sep 20 '13 at 17:28