Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Sairahcaz committed Feb 1, 2023
1 parent 92f427d commit d8e17ea
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Latest Version on Packagist](https://img.shields.io/packagist/v/laracraft-tech/laravel-useful-traits.svg?style=flat-square)](https://packagist.org/packages/laracraft-tech/laravel-useful-traits)
[![Tests](https://github.com/laracraft-tech/laravel-useful-traits/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/laracraft-tech/laravel-useful-traits/actions/workflows/run-tests.yml)
[![Check & fix styling](https://github.com/laracraft-tech/laravel-useful-traits/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/laracraft-tech/laravel-useful-traits/actions/workflows/fix
[![Check & fix styling](https://github.com/laracraft-tech/laravel-useful-traits/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/laracraft-tech/laravel-useful-traits/actions/workflows/fix-php-code-style-issues.yml)
[![License](https://img.shields.io/packagist/l/laracraft-tech/laravel-useful-traits.svg?style=flat-square)](https://packagist.org/packages/laracraft-tech/laravel-useful-traits)
<!--[![Total Downloads](https://img.shields.io/packagist/dt/laracraft-tech/laravel-useful-traits.svg?style=flat-square)](https://packagist.org/packages/laracraft-tech/laravel-useful-traits)-->

Expand All @@ -18,9 +18,43 @@ composer require laracraft-tech/laravel-useful-traits

## Usage

### `EnumToArray`

```php
$laravelUsefulTraits = new LaracraftTech\LaravelUsefulTraits();
echo $laravelUsefulTraits->echoPhrase('Hello, LaracraftTech!');
use LaracraftTech\LaravelUsefulTraits\Enums\EnumToArray;

enum PaymentType: int
{
use EnumToArray;

case Pending = 1;
case Failed = 2;
case Success = 3;
}

PaymentType::names(); // return ['Pending', 'Failed', 'Success']
PaymentType::values(); // return [1, 2, 3]
PaymentType::array(); // return ['Pending' => 1, 'Failed' => 2, 'Success' => 3]
```

### `ScopeSelectAllBut`

```php
DB::table('scope_test_table')->insert([
'foo' => 'foo',
'bar' => 'bar',
'quz' => 'quz',
]);

$class = new class extends Model
{
use ScopeSelectAllBut;

protected $table = 'scope_test_table';
};

$class::query()->selectAllBut(['foo'])->first()->toArray();
// return ['bar' => 'bar', 'quz' => 'quz']
```

## Testing
Expand Down

0 comments on commit d8e17ea

Please sign in to comment.