๐Ÿ‹๏ธ
Lift for Laravel
View on GitHub
  • ๐Ÿ‹๏ธLift for Laravel
  • ๐Ÿš€Getting Started
    • Installation
    • Changelog
  • ๐Ÿ› ๏ธAttributes
    • Cast
    • Column
    • Config
    • DB
    • Events
    • Fillable
    • Hidden
    • Ignore Properties
    • Immutable
    • Primary Key
    • Relationships
    • Validation
    • Watch
  • ๐ŸงชMethods
    • castAndCreate
    • castAndFill
    • castAndSet
    • castAndUpdate
    • createValidationMessages
    • createValidationRules
    • customColumns
    • defaultValues
    • immutableProperties
    • updateValidationMessages
    • updateValidationRules
    • validationMessages
    • validationRules
    • watchedProperties
  • ๐Ÿค–Commands
    • lift:migration
Powered by GitBook
On this page

Was this helpful?

  1. Attributes

DB

The DB class attribute allows you to customize the database connection, table and timestamps of your model. If you don't set any of the attribute parameters, the default values will be used.

use Illuminate\Database\Eloquent\Model;
use WendellAdriel\Lift\Attributes\DB;
use WendellAdriel\Lift\Attributes\Fillable;
use WendellAdriel\Lift\Attributes\PrimaryKey;
use WendellAdriel\Lift\Attributes\Rules;
use WendellAdriel\Lift\Lift;

#[DB(connection: 'mysql', table: 'custom_products_table', timestamps: false)]
final class Product extends Model
{
    use Lift;

    #[PrimaryKey(type: 'string', incrementing: false)]
    public string $uuid;

    #[Rules(['required', 'string'], ['required' => 'The Product name can not be empty'])]
    #[Fillable]
    public string $name;
}
PreviousConfigNextEvents

Last updated 1 year ago

Was this helpful?

๐Ÿ› ๏ธ