{"id":18370001,"url":"https://github.com/statamic/custom-publish-forms-eloquent","last_synced_at":"2025-04-06T18:32:49.957Z","repository":{"id":146133526,"uuid":"136958505","full_name":"statamic/custom-publish-forms-eloquent","owner":"statamic","description":"An example of using Custom Publish forms powered by Eloquent.","archived":false,"fork":false,"pushed_at":"2018-06-11T21:53:32.000Z","size":4682,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-22T04:41:27.451Z","etag":null,"topics":["database","eloquent","laravel","statamic","statamic-addon","statamic-v2"],"latest_commit_sha":null,"homepage":"https://statamic.com/blog/custom-publish-forms","language":"HTML","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/statamic.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-11T17:23:06.000Z","updated_at":"2024-01-04T01:50:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"471f401d-bc38-41fe-b722-0173afe633a4","html_url":"https://github.com/statamic/custom-publish-forms-eloquent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statamic%2Fcustom-publish-forms-eloquent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statamic%2Fcustom-publish-forms-eloquent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statamic%2Fcustom-publish-forms-eloquent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statamic%2Fcustom-publish-forms-eloquent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statamic","download_url":"https://codeload.github.com/statamic/custom-publish-forms-eloquent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247531427,"owners_count":20953961,"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":["database","eloquent","laravel","statamic","statamic-addon","statamic-v2"],"created_at":"2024-11-05T23:35:04.626Z","updated_at":"2025-04-06T18:32:49.946Z","avatar_url":"https://github.com/statamic.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Custom Publish Forms + Eloquent\n\u003e An example of using [Custom Publish forms](https://docs.statamic.com/addons/publish-forms#main) powered by Eloquent models in a Statamic addon.\n\n## Set up the database\n\nCreate a database and add the credentials to your `.env` file.\n\n```\nDB_HOST=localhost\nDB_DATABASE=statamic-eloquent\nDB_USERNAME=root\nDB_PASSWORD=\n```\n\nYou would then create your migrations, like any Laravel install.\n[We have included one in this repo](site/database/migrations/2018_05_31_200716_create_products_table.php).\n\n```\nphp please migrate\n```\n\n\n## Sidebar Navigation\n\nWe have a [Listener file](site/addons/Products/ProductsListener.php) that takes care of adding an item to the navigation. Click the `Products` item in the sidebar to view the listing.\n\n\n## Fieldset\n\nWhen creating or editing a product, the publish component will be rendered according to the provided [product fieldset](site/settings/fieldsets/product.yaml).\n\nTo add more fields, you should create a migration (or update the original one) to add the columns to the table, and also add fields to the fieldset so they are rendered on the publish page.\n\n\n## Validation\n\nThis repo assumes you want to use validation defined as in the fieldset.\n\nIf you want, you may bypass that entirely and write your own validator. Be aware that the fields will be submitted in a nested `fields` array. You will need to do something like this:\n\n``` php\nValidator::make($request-\u003eall(), [\n    'fields.title' =\u003e 'required'\n]);\n```\n\n\n## Front-end\n\nThe `/products` route is a [page](site/content/pages/6.products/index.md) that loads a [template](site/themes/redwood/templates/products/index.html) containing a [simple custom tag](site/addons/Products/ProductsTags.php#L9-L14).\n\nThe `/products/{slug}` route is a [wildcard route](site/settings/routes.yaml#L24) that loads a [template](site/themes/redwood/templates/products/product.html) with another [simple custom tag](site/addons/Products/ProductsTags.php#L16-L21).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatamic%2Fcustom-publish-forms-eloquent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatamic%2Fcustom-publish-forms-eloquent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatamic%2Fcustom-publish-forms-eloquent/lists"}