Collections on Data

Posted 2 years ago by toneee

Hi All,

Im after some help as I am a little confused on the best way to do something and think I have been looking at it so long that has caused more problems :)

So essentially I want to store some data in an array (Havent put in the DB as I dont think its worth it as it will stay pretty much static, but I dont want to hard code it as it will be used in various places and may change at a later date.)

I have created this:


namespace App\Http\Utilities;

 * Account Detail class
class accountDetail

    protected static $accountdetails = [
            'user' => ['name' => 'user',
                       'color' => 'green',
            'manager' => ['name' => 'manager',
                          'color' => 'blue',
            'admin' => ['name' => 'admin',
                        'color' => 'red',

    public static function all()
        return static::$accountdetails;

so I call:

$accountdetails = accountDetail::all();

and it works fine, it gives me an array of all the details, but I want to be able to do things like ->first() and other collection methods, but for the life of me I cant work out how to change it so it work, or to be fair if this is a crap way to handle information like that?

Any help or critique is appreciated!

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.