jessegall/laravel-non-null-collection-cast

Cast as a collection that is never null

v1.0.1 2023-08-23 19:15 UTC

This package is auto-updated.

Last update: 2024-10-23 21:57:59 UTC


README

Simple cast for Laravel Eloquent models that allows you to cast a field to a non-null collection.

Installation

composer require jessegall/laravel-non-null-collection-cast

Usage

use Illuminate\Database\Eloquent\Model;
use JesseGall\Laravel\Database\Casts\AsNonNullCollection;

class MyModel extends Model {

    protected $casts = [
        'my_field' => AsNonNullCollection::class,
    ];
    
}