{"id":37012100,"url":"https://github.com/remzikocak/laravel-options","last_synced_at":"2026-01-14T01:03:03.025Z","repository":{"id":39904149,"uuid":"257946378","full_name":"remzikocak/laravel-options","owner":"remzikocak","description":"Database Options/Settings Package for Laravel 9/10/11/12","archived":false,"fork":false,"pushed_at":"2025-03-18T17:19:51.000Z","size":755,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-23T00:51:15.308Z","etag":null,"topics":["laravel","laravel-options","options","php"],"latest_commit_sha":null,"homepage":"https://remzikocak.com","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/remzikocak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2020-04-22T15:44:16.000Z","updated_at":"2025-04-29T12:54:08.000Z","dependencies_parsed_at":"2024-01-21T14:43:37.196Z","dependency_job_id":"41a5dfbf-f392-4f1b-bb27-0f4dd92d4933","html_url":"https://github.com/remzikocak/laravel-options","commit_stats":{"total_commits":39,"total_committers":4,"mean_commits":9.75,"dds":0.2564102564102564,"last_synced_commit":"ad9432b5a100a09600acd6ff053f504091a5439b"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/remzikocak/laravel-options","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remzikocak%2Flaravel-options","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remzikocak%2Flaravel-options/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remzikocak%2Flaravel-options/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remzikocak%2Flaravel-options/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remzikocak","download_url":"https://codeload.github.com/remzikocak/laravel-options/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remzikocak%2Flaravel-options/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","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":["laravel","laravel-options","options","php"],"created_at":"2026-01-14T01:03:02.407Z","updated_at":"2026-01-14T01:03:02.961Z","avatar_url":"https://github.com/remzikocak.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"/laravel-options.png\" alt=\"Laravel Options\"\u003e\u003c/p\u003e\n\n# Laravel Options Package\n\nThis Package will help you to dynamically add Option fields to your Backend Panel.\n\n## Installation\nYou can install the package via composer:\n\n``` bash\ncomposer require remzikocak/laravel-options\n```\n\nThe Package will automatically register the Service Provider and Facade.\nAfterwards, you need to publish and migrate:\n\n``` bash\nphp artisan vendor:publish --provider=\"RKocak\\Options\\OptionsServiceProvider\"\nphp artisan migrate\n```\n\nThis will create the migration files and options.php file in your config folder.\n\n## Usage\nFirst of all, you need to create a Optiongroup and an Option.\n\n``` php\nuse RKocak\\Options\\Models\\Optiongroup;\nuse RKocak\\Options\\Models\\Option;\n\nOptiongroup::create([\n    'label'         =\u003e 'My Optiongroup',\n    'description'   =\u003e 'Optiongroup description', // can be null\n    'display_order' =\u003e 1,\n]);\n\nOption::create([\n    'name'          =\u003e 'myOption' // should be unique\n    'label'         =\u003e 'My Option',\n    'description'   =\u003e 'My awesome Option',\n    'value'         =\u003e 'Option value',\n    'type'          =\u003e 'text',\n]);\n```\n\nOption groups and options have a many-to-many relationship. Groups can have many options, and options can belong to many groups. Understanding this relationship is essential for displaying them in your backend panel.\n\nFor assignment, use the following:\n``` php\n$group = Optiongroup::find(1);\n$option = Option::find(1);\n\n// Assign option to a group\n$group-\u003eoptions()-\u003eattach($option);\n\n// or..\n$option-\u003egroups()-\u003eattach($group);\n```\n\n## Getting options\nTo retrieve the computed value, use the ``` getValue() ``` method from the Option Model.\n\n``` php\n$option-\u003egetValue();\n\n// This will be the \"raw\" value that is stored in the database\n$option-\u003evalue\n```\n\nA better and more performant option is to utilize the ```Options``` Facade.\nThis will cache the options when you only require a key =\u003e value store.\n\nYou can use it as following:\n\n``` php \nOptions::get('optionName');\n\n// You can pass a second parameter as default value\nOptions::get('optionName', null);\n\n// or use the helper function\noptions('optionName', null);\n```\n\nCheck if option with the given name exists\n``` php\nOptions::has('optionName');\n```\n\nWhile the cache usually refreshes automatically, if you need to do it manually, use the following method.\n\n``` php\nOptions::getLoader()-\u003erebuildCache();\n```\n\n## Adding custom Types\nTo add your custom type, you need to create a class that extends ``` RKocak\\Options\\Type```\n\nExample:\n``` php\n\u003c?php\n\nnamespace App;\n\nuse RKocak\\Options\\Models\\Option;\nuse RKocak\\Options\\Type;\n\nclass MyType extends Type\n{\n\n    /**\n     * @return string\n     */\n    public static function getName(): string\n    {\n        return 'my_type';\n    }\n\n    /**\n     * @param Option $option\n     * @return string\n     */\n    public function render(Option $option): string\n    {\n        return '\u003cdiv\u003e\n                    \u003cinput type=\"text\" name=\"options['. htmlspecialchars($option-\u003ename) .']\" id=\"options['. htmlspecialchars($option-\u003ename) .']\" value=\"'. htmlspecialchars($option-\u003egetValue()) .'\" class=\"\"/\u003e\n                \u003c/div\u003e';\n    }\n\n    /**\n     * Store the new value\n     *\n     * @param $newValue\n     * @param $oldValue\n     * @return mixed\n     */\n    public function store($newValue, $oldValue)\n    {\n        return $newValue;\n    }\n\n    /**\n     * Cast value\n     *\n     * @param $value\n     * @return mixed|string\n     */\n    public function cast($value)\n    {\n        return (string) $value;\n    }\n\n}\n```\n\nthen add the class in configuration file to the types array.\nAfter that you can use it like all other types.\n\n## Rendering HTML for Edit Form\nRendering options is straightforward with a few pre-added \"Types.\"\n\n``` php\n$option = Option::first();\n\n$html = $option-\u003erenderEditHTML();\n\n// ..or\n$html = $option-\u003etoHtml();\n\n// Alternatively, you can use the model instance directly in your Blade views:\n{{ $option }}\n```\n\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremzikocak%2Flaravel-options","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremzikocak%2Flaravel-options","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremzikocak%2Flaravel-options/lists"}