{"id":43266988,"url":"https://github.com/dottwatson/laravel-model-meta","last_synced_at":"2026-02-01T15:13:14.249Z","repository":{"id":56971455,"uuid":"472294105","full_name":"dottwatson/laravel-model-meta","owner":"dottwatson","description":"A clean and smart tool to add metadata support on your models","archived":false,"fork":false,"pushed_at":"2022-03-21T13:17:47.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-31T10:32:38.150Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dottwatson.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-21T10:48:05.000Z","updated_at":"2023-08-07T17:18:17.000Z","dependencies_parsed_at":"2022-08-21T10:51:00.445Z","dependency_job_id":null,"html_url":"https://github.com/dottwatson/laravel-model-meta","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dottwatson/laravel-model-meta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flaravel-model-meta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flaravel-model-meta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flaravel-model-meta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flaravel-model-meta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dottwatson","download_url":"https://codeload.github.com/dottwatson/laravel-model-meta/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flaravel-model-meta/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28980858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T13:38:33.235Z","status":"ssl_error","status_checked_at":"2026-02-01T13:38:32.912Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-01T15:13:13.720Z","updated_at":"2026-02-01T15:13:14.244Z","avatar_url":"https://github.com/dottwatson.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Model Meta\n## _Extend your models with unlimited meta attributes_\n\n[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)\n\nEasly add meta data to your model, without change any logic. This package can gives you the ability to extend your laravel model with a configurable set of meta data. Each meta will be automatically inserted,upadted or deleted, following your model modifications and lifecycle.\n\nMeta data will be treated exactly like attributes, so they can be cast, hidden, and have accessories and mutators available. You don't need to know any new syntax, as it is all manageable with the standard model conventions.\n\n### Installation\n```\ncomposer require dottwtson/laravel-model-meta\n```\nthen publish config files\n```\nphp artisan vendor:publish --tag=model-meta-config\n```\n##### File config/model-meta-types.php\nHere you can set all the available meta types. You can add any kind of meta type for all your needs\n```php\n\u003c?php\nreturn [\n    ...\n    // This is the identifier for the meta type\n    'int' =\u003e [\n        // This is the casting that will be applied on the query. %s will be replaced with the meta name\n        'database_casting' =\u003e 'CAST(%s.value AS UNSIGNED)', \n        // This is the model casting, according with laravale casting\n        'model_casting' =\u003e 'int'\n    ],\n    ...\n]\n```\n\nFill free to define all your own meta types\n\n#### config/model-meta.php\nHere you can define all the meta data available on your model.\n```php\n\u003c?php\nreturn [\n        ...\n    \\My\\Namespace\\ModelName::class =\u003e [\n        'mymeta' =\u003e ['type'=\u003e\\Dottwatson\\Meta::JSON,...],\n    ],\n    ...\n    \\My\\Namespace\\ModelName::class =\u003e [\n        'mymeta' =\u003e ['type'=\u003e'json',...], // the type is defined in model-meta-type\n        ...\n    ]\n]\n```\nYou can also assign a meta list directly on the model (see below).\n\n#### Implements meta on your existing model\n```php\n\u003c?php\n\nnamespace App\\Models;\n\n...\nuse Dottwatson\\ModelMeta\\ModelMeta;\n\nclass MyModel extends Model\n{\n    use ModelMeta;\n    ...\n    protected $tableMeta = 'mymodel_meta';\n\n   ...\n\n}\n\n```\n\nDefine meta directly on the model\n```php\n\u003c?php\n\nnamespace App\\Models;\n\n...\nuse Dottwatson\\ModelMeta\\ModelMeta;\n\nclass MyModel extends Model\n{\n    use ModelMeta;\n    ...\n    protected $tableMeta = 'mymodel_meta';\n\n   ...\n   \n   protected static function metaAttributes()\n   {\n       return [\n        'mymeta' =\u003e ['type'=\u003e'json',...], // the type is defined in model-meta-type\n       ];\n   }\n}\n\n```\n\nFor default, the meta data are relationed to the model primary key. For customize it on your needs add this in your model\n```php\n\u003c?php\n\nnamespace App\\Models;\n\n...\nuse Dottwatson\\ModelMeta\\ModelMeta;\n\nclass MyModel extends Model\n{\n   ...\n \n    public static function metaReference()\n    {\n        return 'my_column';\n    }\n    \n    ...\n\n}\n```\n\n### Commands\n```\nphp artisan make:model-meta MyModel [meta_table_name]\n```\nThis create a preset model under app\\Models, and if passed, creates also the table into database\n\n```\nphp artisan make:meta-table meta_table_name\n```\n\nThis creates a standalone meta table ready to be used in your model according with the ```$tableMeta``` property.\n\n### Queries\nNo modifications are required, No extra methods are implemented. \nIf you use the model builder,each meta will automatically be treated as if it were a column in your table.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdottwatson%2Flaravel-model-meta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdottwatson%2Flaravel-model-meta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdottwatson%2Flaravel-model-meta/lists"}