GitHub Repository


Definition & Principles

Read from the Porto SAP Documentation (#Models).


Folder Structure

 - App
    - Containers
        - {container-name}
            - Models
                - User.php
                - UserId.php
                - ...

Code Sample


namespace App\Containers\Demo\Models;

use App\Ship\Parents\Models\Model;

class Demo extends Model
    protected $table = 'demos';

    protected $fillable = [

    protected $hidden = [

    protected $casts = [
        'total_credits'     => 'float',

    protected $dates = [

    public function user()
        return $this->belongsTo(\App\Containes\User\Models\User::class);

Notice the Demo Model has a relationship with User Model, which lives in another Container.


The casts attribute can be used to parse any of the model’s attributes to a specific type. In the code sample below we can cast total_credits to float.

More information about the applicable cast-types can be found in the laravel eloquent-mutators documentation.

You can place any dates inside of the $dates to parse those automatically.