{"id":36253611,"url":"https://github.com/thebatclaudio/eloquent-markdown","last_synced_at":"2026-05-09T21:03:23.046Z","repository":{"id":236760138,"uuid":"792520425","full_name":"thebatclaudio/eloquent-markdown","owner":"thebatclaudio","description":"Convert markdown files to Eloquent models in your Laravel application","archived":false,"fork":false,"pushed_at":"2025-02-25T11:13:34.000Z","size":36,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T19:35:53.508Z","etag":null,"topics":["eloquent","eloquent-markdown","laravel","markdown","yaml","yaml-frontmatter","yfm"],"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/thebatclaudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-04-26T21:02:20.000Z","updated_at":"2025-07-22T11:24:18.000Z","dependencies_parsed_at":"2025-02-25T10:22:35.573Z","dependency_job_id":"548d9fd1-3a21-40d9-a12c-db1fb484248e","html_url":"https://github.com/thebatclaudio/eloquent-markdown","commit_stats":null,"previous_names":["thebatclaudio/laravel-eloquent-markdown","thebatclaudio/eloquent-markdown"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/thebatclaudio/eloquent-markdown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebatclaudio%2Feloquent-markdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebatclaudio%2Feloquent-markdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebatclaudio%2Feloquent-markdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebatclaudio%2Feloquent-markdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thebatclaudio","download_url":"https://codeload.github.com/thebatclaudio/eloquent-markdown/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebatclaudio%2Feloquent-markdown/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28296941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T04:44:51.577Z","status":"ssl_error","status_checked_at":"2026-01-11T04:44:44.232Z","response_time":60,"last_error":"SSL_read: 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":["eloquent","eloquent-markdown","laravel","markdown","yaml","yaml-frontmatter","yfm"],"created_at":"2026-01-11T07:03:31.782Z","updated_at":"2026-05-09T21:03:23.035Z","avatar_url":"https://github.com/thebatclaudio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eloquent Markdown\n\n[![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/thebatclaudio/eloquent-markdown/LICENSE)\n[![Latest Stable Version](https://img.shields.io/packagist/v/thebatclaudio/eloquent-markdown.svg)](https://packagist.org/packages/thebatclaudio/eloquent-markdown)\n[![Total Downloads](https://img.shields.io/packagist/dt/thebatclaudio/eloquent-markdown)](https://packagist.org/packages/thebatclaudio/eloquent-markdown)\n[![StyleCI Status](https://styleci.io/repos/792520425/shield)](https://styleci.io/repos/792520425)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/thebatclaudio/laravel-eloquent-markdown/tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://img.shields.io/github/actions/workflow/status/thebatclaudio/laravel-eloquent-markdown/tests.yml?branch=main\u0026label=tests\u0026style=flat-square)\n\nEasily manage Markdown files with a YAML Front Matter section using Eloquent models in your Laravel application.\n\n## Compatibility\n\n| Package | PHP | Laravel |\n|---------|-----|---------|\n| `^2.0`  | `^8.3` | `^12.0`, `^13.0` |\n| `^1.0`  | `^8.2` | `^10.0`, `^11.0`, `^12.0`, `^13.0` |\n\n\u003e **Upgrading from v1 to v2?** v2 drops PHP 8.2 (security-only since Dec 2024) and Laravel 10/11 (EOL). No application code changes are required if you are already on PHP 8.3+ and Laravel 12+.\n\n## Installation\n\n1. **Install the package via Composer**:\n\n    ```bash\n    composer require thebatclaudio/eloquent-markdown\n    ```\n\n2. **Configure the filesystem disk**\n\n   By default, markdown files will be retrieved from `markdown` storage disk, so you need to define it in your `config/filesystems.php` file:\n\n    ```php\n    \u003c?php\n    \n    return [\n    \n        // ...\n    \n        'disks' =\u003e [\n            // Existing disks...\n    \n            'markdown' =\u003e [\n                'driver' =\u003e 'local',\n                'root' =\u003e storage_path('markdown'),\n            ],\n        ],\n       \n    ];\n    ```\n\n    or, if you want to use S3:\n\n    ```php\n    \u003c?php\n    \n    return [\n    \n        // ...\n    \n        'disks' =\u003e [\n            // Existing disks...\n    \n            'markdown' =\u003e [\n                'driver' =\u003e 's3',\n                'key' =\u003e env('AWS_ACCESS_KEY_ID'),\n                'secret' =\u003e env('AWS_SECRET_ACCESS_KEY'),\n                'region' =\u003e env('AWS_DEFAULT_REGION'),\n                'bucket' =\u003e env('AWS_BUCKET'),\n                'url' =\u003e env('AWS_URL'),\n                'endpoint' =\u003e env('AWS_ENDPOINT'),\n            ],\n        ],\n       \n    ];\n    ```   \n\n4. **Publish the configuration file (optional)**\n\n   Optionally you can publish the config file (`config/markdown.php`) to edit the default markdowns' disk with:\n\n    ```bash\n    php artisan vendor:publish --provider=\"TheBatClaudio\\EloquentMarkdown\\Providers\\EloquentMarkdownServiceProvider\" --tag=\"config\"\n    ```\n\n## Usage\n\nCreate a new model that extends `TheBatClaudio\\EloquentMarkdown\\Models\\MarkdownModel`:\n\n```php\nuse TheBatClaudio\\EloquentMarkdown\\Models\\MarkdownModel;\n\nclass Page extends MarkdownModel\n{\n}\n```\n\n### Get all markdown files\n\n```php\n$pages = Page::all();\n```\n\n### Get a markdown file by its id\n\nImagine to have a markdown file named `homepage.md` with the following content:\n\n```yaml\n---\nfirst_attribute: First attribute\nsecond_attribute: Second attribute\nthird_attribute: Third attribute\n---\nThe time has come. You know it. In your mind. In your heart. In your soul. You tried to hold me back. But you can't,\nBruce. You're weak. You're a shell. A rusty trap that cannot hold me. Let it go. Let me OUT.\n```\n\nYou will get the file as Eloquent model using the `find` method:\n```php\n$homepage = Page::find('homepage');\n```\n\nAnd you will find the following attributes:\n\n```php\necho $homepage-\u003eid; // homepage\necho $homepage-\u003efile_name; // homepage.md\necho $homepage-\u003efile_path; // { YOUR STORAGE PATH }/homepage.md\necho $homepage-\u003efirst_attribute; // First attribute\necho $homepage-\u003esecond_attribute; // Second attribute\necho $homepage-\u003ethird_attribute; // Third attribute\necho $homepage-\u003econtent; // The time has come. You know it [...]\n```\n\n### Update a markdown file\n\n```php\n$homepage = Page::find('homepage');\n\n$homepage-\u003eupdate([\n    'attribute' =\u003e 'new value'\n])\n\n// or\n$homepage-\u003eattribute = 'new value';\n$homepage-\u003esave();\n```\n\n### Delete a markdown file\n```php\n$homepage = Page::find('homepage');\n$homepage-\u003edelete();\n```\n\n### Create a markdown file\n\n```php\n$newHomepage = new Page();\n$newHomepage-\u003eid = 'homepage';\n$newHomepage-\u003etitle = 'Homepage';\n$newHomepage-\u003econtent = 'Content';\n$newHomepage-\u003esave();\n```\n\n### Using Markdown with dates (e.g. `YYYY-MM-DD-your-markdown.md`)\n\nCreate a new model that extends `TheBatClaudio\\EloquentMarkdown\\Models\\MarkdownModel` and uses `TheBatClaudio\\EloquentMarkdown\\Models\\Traits\\WithDate` trait:\n\n```php\nuse TheBatClaudio\\EloquentMarkdown\\Models\\MarkdownModel;\nuse TheBatClaudio\\EloquentMarkdown\\Models\\Traits\\WithDate;\n\nclass Article extends MarkdownModel\n{\n    use WithDate;\n}\n```\n\nYou will find two new attributes inside your model:\n- `date`: a Carbon instance with the date defined on your markdown file name (e.g. `2024-05-15` for `2024-05-15-your-markdown.md`)\n- `slug`: the slug of your markdown (e.g. `your-markdown` for `2024-05-15-your-markdown.md`)\n\n### Different path for different models\n\nYou can extend `getContentPath` inside your model to use different paths for different models:\n\n```php\nuse TheBatClaudio\\EloquentMarkdown\\Models\\MarkdownModel;\nuse TheBatClaudio\\EloquentMarkdown\\Models\\Traits\\WithDate;\n\nclass Article extends MarkdownModel\n{\n    use WithDate;\n\n    protected static function getContentPath(): string\n    {\n        return 'articles';\n    }\n}\n\nclass Page extends MarkdownModel\n{\n    protected static function getContentPath(): string\n    {\n        return 'pages';\n    }\n}\n```\n\n## Credits\n\n- [Claudio La Barbera](https://github.com/thebatclaudio)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebatclaudio%2Feloquent-markdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthebatclaudio%2Feloquent-markdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebatclaudio%2Feloquent-markdown/lists"}