PHPackages                             orbas/util - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. orbas/util

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

orbas/util
==========

a library for laravel

0.2.1(8y ago)71.9k11MITPHP

Since Aug 2Pushed 8y ago5 watchersCompare

[ Source](https://github.com/orbasteam/util)[ Packagist](https://packagist.org/packages/orbas/util)[ RSS](/packages/orbas-util/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (1)

Laravel Util
============

[](#laravel-util)

[![Build Status](https://camo.githubusercontent.com/ed4245223c2a8b273577166d0591e4621b375ac8e66e05af5c8a0f8a78409ab1/68747470733a2f2f7472617669732d63692e6f72672f6f726261737465616d2f7574696c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/orbasteam/util)[![StyleCI](https://camo.githubusercontent.com/161d76d4c1c8ea46bfc0e0b50f1485052443d215c147627efd046c526391c535/68747470733a2f2f7374796c6563692e696f2f7265706f732f39393031303838312f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/99010881)

Laravel Util provides some useful method, such like `enum` and `presenter`

Installation
------------

[](#installation)

To get the latest version, simply require the project using [Composer](https://getcomposer.org):

`$ composer require orbas/util`

and register the `Orbas\Util\ServiceProvider::class` service provider in your `config/app.php`

Enum
----

[](#enum)

A enum is a distinct type that consists of a set of named constants called the enumerator list.

You can use it in a easier way to make your own enum.

### Create a enum class

[](#create-a-enum-class)

`$ php artisan util:make:enum Gender`

That will create a class to `app/Enums/` folder

### Define the enum

[](#define-the-enum)

```
namespace App\Enums;

use Orbas\Util\Enum\Enumable;

class Gender implements Enumable
{
    /**
     *
     * @return array
     */
    public function create()
    {
        return ['female', 'male'];
    }
}
```

or you can define the key

```
namespace App\Enums;

use Orbas\Util\Enum\Enumable;

class Weekday implements Enumable
{
    /**
     *
     * @return array
     */
    public function create()
    {
        return [
            1 => 'Monday',
            2 => 'Tuesday',
            3 => 'Wednesday',
            4 => 'Thursday',
            5 => 'Friday',
            6 => 'Saturday',
            7 => 'Sunday'
        ];
    }
}
```

### Enjoy using it

[](#enjoy-using-it)

Generate a collection of gender

```
app('enum')->create('gender');
```

Get value from key

```
app('enum')->value(1, 'weekday'); // this will echo Monday
```

### Use Facade

[](#use-facade)

Add class aliases to the aliases array of `config/app.php`:

```
  'aliases' => [
    // ...
      'Enum' => \Orbas\Util\Facades\Enum::class,
    // ...
  ],
```

then you can use it like this

```
// equal to app('enum')->create('gender');
Enum::create('gender');
Enum::gender();
```

*More functionality will be released in the future.*

Presenter
---------

[](#presenter)

or you can call it view presenter. Sometimes you have some logic need to be performed before you put the data.

for example

```
{{ $user->first_name }} {{ $user->last_name }}
{{ $user->gender == 0 ? 'female' : 'male' }}
{{ Carbon\Carbon::parse($user->birthday->format('d/m/Y') }}
```

A presenter is a pattern that you can put the logic far from view and model. (keep model clean, and do what it should do.)

### Create a presenter class

[](#create-a-presenter-class)

`$ php artisan util:make:presenter User`

That will create a class to `app/Presenters` folder

### Edit your presenter logic

[](#edit-your-presenter-logic)

```
namespace App\Presenters;

use Orbas\Util\Presenter;

class User extends Presenter
{
    public function full_name()
    {
        return $this->attribute('first_name') . ' ' . $this->last_name;
    }

    public function birthday()
    {
        return Carbon\Carbon::parse($this->attribute('')
    }
}
```

### Put present trait to your model

[](#put-present-trait-to-your-model)

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use Orbas\Util\Traits\Presenter;

class User extends Model
{
    use Presenter;
}
```

### Usage

[](#usage)

```
$user = App\User::find(1);

$user->present()->full_name;

// or
$user->present('full_name');
```

### Multi-language with Enum

[](#multi-language-with-enum)

Presenter provides auto translation.

Put `enums.php` to `resources/lang/YOUR_LOCALE/enums.php`

```
// resources/lang/zh-TW/enums.php
return [
    'gender' => [    // enum name
        'female' => '女',    // enum key => translation word
        'male'   => '男'
    ]
];
```

Presenter will translate for you

```
$user = App\User::first();
$user->present('gender');
// or
$user->present()->gender;

//or given a enum name and locale
$user->present()->enum('gender', 'Gender', 'zh-TW');
```

License
-------

[](#license)

Laravel Util is licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

5

Last Release

3183d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86af9f28af1a6105513fe9097fad46ed41c9e5f1f440b3cbb506e44ed41fdb1d?d=identicon)[flash662](/maintainers/flash662)

---

Top Contributors

[![flash662](https://avatars.githubusercontent.com/u/9019939?v=4)](https://github.com/flash662 "flash662 (24 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/orbas-util/health.svg)

```
[![Health](https://phpackages.com/badges/orbas-util/health.svg)](https://phpackages.com/packages/orbas-util)
```

###  Alternatives

[nojimage/twitter-text-php

A library of PHP classes that provide auto-linking and extraction of usernames, lists, hashtags and URLs from tweets.

1241.9M7](/packages/nojimage-twitter-text-php)[drupol/composer-packages

Composer Packages is a Composer plugin for getting information about installed packages in your project.

32274.0k1](/packages/drupol-composer-packages)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
