main

filamentphp/demo

Last updated at: 29/12/2023 09:42

OrderAddress.php

TLDR

This file defines the OrderAddress model class for the Shop namespace in the Demo Projects project. The model represents an order address and includes a relationship method named addressable().

Classes

OrderAddress

The OrderAddress class extends the Model class and has the HasFactory trait. It represents an order address in the Shop namespace. The class includes a protected property $table which specifies the database table name as 'shop_order_addresses'. The class also includes a relationship method named addressable() which returns a MorphTo instance.

<?php

namespace App\Models\Shop;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;

class OrderAddress extends Model
{
    use HasFactory;

    protected $table = 'shop_order_addresses';

    public function addressable(): MorphTo
    {
        return $this->morphTo();
    }
}