{"id":19261313,"url":"https://github.com/joelshepherd/create-with","last_synced_at":"2025-04-21T17:30:39.015Z","repository":{"id":57000746,"uuid":"96261176","full_name":"joelshepherd/create-with","owner":"joelshepherd","description":"Easily add common unique identity fields to Laravel models.","archived":false,"fork":false,"pushed_at":"2018-02-28T13:13:30.000Z","size":18,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T12:21:06.847Z","etag":null,"topics":["laravel","laravel-model","slug","trait","uuid"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joelshepherd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-05T00:23:04.000Z","updated_at":"2020-08-31T11:17:12.000Z","dependencies_parsed_at":"2022-08-21T11:40:45.468Z","dependency_job_id":null,"html_url":"https://github.com/joelshepherd/create-with","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelshepherd%2Fcreate-with","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelshepherd%2Fcreate-with/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelshepherd%2Fcreate-with/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelshepherd%2Fcreate-with/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelshepherd","download_url":"https://codeload.github.com/joelshepherd/create-with/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250100185,"owners_count":21374892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["laravel","laravel-model","slug","trait","uuid"],"created_at":"2024-11-09T19:26:03.798Z","updated_at":"2025-04-21T17:30:38.768Z","avatar_url":"https://github.com/joelshepherd.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create With - Laravel Models\nA simple package that provides traits to add common indentity fields to Laravel\nmodels when they are created. \n\nThis package is designed to work out of the box with just the traits. No other\nconfiguration is needed.\n\n## Installation\n**Dependencies**\n- PHP 7\n- Laravel 5.*\n\n**Composer**\n```\ncomposer require joelshepherd/create-with\n```\n\n## Usage\nSimply add the trait to your model that provides your desired field. If the\nfield is not empty and is unique in the database, it will be left unchanged.\n\n### Create with UUID\nAdds an unique UUID to the model.\n\n**Default options**\n- `getUuidField()` returns `uuid`\n\n```php\n\u003c?php\nuse JoelShepherd\\CreateWith;\n\nclass Example extends Model\n{\n    use CreateWith\\Uuid;\n}\n```\n\n```php\n\u003c?php\n\n$example = Example::create();\n$example-\u003euuid; // 123e4567-e89b-12d3-a456-426655440000\n```\n\n### Create with slug\nAdds an unique slug to the model. This can optionally be based on a text string\n(like a title field on the model) and appended with a random slug if required\nfor uniqueness.\n\n**Default options**\n- `getSlugField()` returns `slug`\n- `getSlugBaseText()` returns `null`\n- `getSlugRandomLength()` returns `7`\n\n```php\n\u003c?php\nuse JoelShepherd\\CreateWith;\n\nclass Example extends Model\n{\n    use CreateWith\\Slug;\n\n    // Optionally set the base string to build the slug from\n    protected function getSlugBaseText()\n    {\n        return $this-\u003etitle;\n    }\n}\n```\n\n```php\n\u003c?php\n\n// Creates a unique slug from the base text\n$example = Example::create([\n    'title' =\u003e 'This is a title'\n]);\n$example-\u003eslug; // this-is-a-title\n\n// Uniqueness is retained even with the same base text\n$example2 = Example::create([\n    'title' =\u003e 'This is a title'\n]);\n$example2-\u003eslug; // this-is-a-title-7iw90lj\n```\n\n### Create with IP address\nAdds the requester's IP address to the model.\n\n**Default options**\n- `getIpAddressField()` returns `ip_address`\n\n```php\n\u003c?php\nuse JoelShepherd\\CreateWith\\WithIpAddress;\n\nclass Example extends Model\n{\n    use CreateWith\\IpAddress;\n}\n```\n\n```php\n\u003c?php\n\n$example = Example::create();\n$example-\u003eip_address; // 127.0.0.1\n```\n\n## Contributing\nSubmitting issues and pull requests for bugs, features and feature requests are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelshepherd%2Fcreate-with","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelshepherd%2Fcreate-with","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelshepherd%2Fcreate-with/lists"}