Skip to content

Eloquent binary cast - mainly for Postgresql implementation.

License

Notifications You must be signed in to change notification settings

jBernavaPrah/eloquent-binary-cast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eloquent Binary Cast

The Eloquent Binary Cast.

When using the PostgreSQL dialectic, Eloquent treat the "bytea" column in the same manner as blob/text column. But this is incorrect on PostgreSQL. The value needs to be cast before pushed to the database.

If you are not using Postgresql, you don't need this cast class.

See those issues:

Prerequisites:

  • PostgreSQL 9.0 or later.
  • Eloquent 8 or later.

Install:

composer require jbernavaprah/eloquent-binary-cast

Use:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use JBernavaPrah\EloquentBinaryCast\BinaryCast;

class User extends Model
{
    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'binary_data' => BinaryCast::class,
    ];
}

See https://laravel.com/docs/8.x/eloquent-mutators#custom-casts for more details.

Tests:

composer test

Authors

About

Eloquent binary cast - mainly for Postgresql implementation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages