6

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?

Dan
  • 6,008
  • 7
  • 40
  • 41
totymedli
  • 29,531
  • 22
  • 131
  • 165

1 Answers1

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