Support the ongoing development of Laravel.io →
Eloquent Validation

I have a User class that extends a Base class which extends Ardent. I'm toying with the idea of using Confide 4.0 for general user management, but when I add the ConfideUser trait to my User class, everything blows up:

Declaration of MyProject\User::save() should be compatible with LaravelBook\Ardent\Ardent::save(array $rules = Array, array $customMessages = Array, array $options = Array, Closure $beforeSave = NULL, Closure $afterSave = NULL)

If I switch my User class so that extends Eloquent, everything works fine. If my User class was extending a ConfideUser class, I could simply override the save() method with my own implementation. But since ConfideUser is now a trait, I have no idea how to override the save() method to make it compatible with Ardent, or if it is even possible. Any suggestions?

Last updated 3 years ago.
0

I've had the same problem and solved it following instructions found here: http://stackoverflow.com/a/11939306 My user model now looks like this:

<?php
use LaravelBook\Ardent\Ardent;
use Zizaco\Confide\ConfideUser;
use Zizaco\Confide\ConfideUserInterface;
use Zizaco\Entrust\HasRole;

class User extends Ardent implements ConfideUserInterface
{
    use ConfideUser{
        save as confideSave;
    }
    use HasRole;
    
    public function save(array $rules = Array(), array $customMessages = Array(), array $options = Array(), Closure $beforeSave = NULL, Closure $afterSave = NULL){
        return $this->confideSave();
    }
}

Note: I haven't done a lot of testing, but my seeder used to fail - not it works.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

benharold benharold Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.