Support the ongoing development of Laravel.io →
posted 8 years ago
Eloquent
Last updated 1 year ago.
0

There's no need to override find. Create a custom method. Your current method is just calling itself recursively, which is why you are getting the endless loop.

I'm not sure what you're trying to achieve though. Maybe explain to us why you're trying to do this, and we can help you better. :)

0

Thanks. Yes, that's what I finally realised and made it like this.

    public static function find($key)
    {
        $obj = Salary::where('id', $key)->limit(1);

        if ($obj->count() == 0)
            throw new \Exception('No records where found.');

        $salary = $obj->first();

        if ( $salary->organization != Auth::user()->organization )
            throw new \Exception('You do not have permission to this organizatio.');

        return $salary;
    }
0

Sign in to participate in this thread!

Eventy

Your banner here too?

emilmoe emilmoe Joined 23 Oct 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.

© 2024 Laravel.io - All rights reserved.