Official Laravel source
AttributeIlluminate\Database\Eloquent\Attributes\Table

#[Table]

In the Database / Eloquent group, #[Table] applies this configuration to the target Laravel element. It accepts 6 configuration parameters.

Available since

Laravel 13.0

Targets

class

Parameters

  • $name?string

    Defines the "name" value used by the attribute. Expected type: ?string.

  • $key?string

    Key used to resolve the value. Expected type: ?string.

  • $keyType?string

    Defines the "keyType" value used by the attribute. Expected type: ?string.

  • $incrementing?bool

    Defines the "incrementing" value used by the attribute. Expected type: ?bool.

  • $timestamps?bool

    Defines the "timestamps" value used by the attribute. Expected type: ?bool.

  • $dateFormat?string

    Defines the "dateFormat" value used by the attribute. Expected type: ?string.

Practical usage

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Attributes\Table;

#[Table('value', 'value', 'value', false, false, 'value')]
class Post extends Model
{
    // ...
}