{"id":25452716,"url":"https://github.com/zymawy/arabify","last_synced_at":"2025-11-02T06:30:33.759Z","repository":{"id":51302984,"uuid":"170307559","full_name":"zymawy/arabify","owner":"zymawy","description":":closed_lock_with_key: A Wrapper Sluggable Traits, To Deal With Arabic Langauge","archived":false,"fork":false,"pushed_at":"2024-09-13T02:42:38.000Z","size":22,"stargazers_count":8,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-16T05:08:29.667Z","etag":null,"topics":["arabic","arabic-slug","laravel","laravel5","slug","sluggable","slugify"],"latest_commit_sha":null,"homepage":null,"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/zymawy.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}},"created_at":"2019-02-12T11:36:09.000Z","updated_at":"2024-08-05T15:48:47.000Z","dependencies_parsed_at":"2022-09-06T02:10:36.262Z","dependency_job_id":null,"html_url":"https://github.com/zymawy/arabify","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zymawy%2Farabify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zymawy%2Farabify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zymawy%2Farabify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zymawy%2Farabify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zymawy","download_url":"https://codeload.github.com/zymawy/arabify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239162064,"owners_count":19592339,"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":["arabic","arabic-slug","laravel","laravel5","slug","sluggable","slugify"],"created_at":"2025-02-17T23:41:24.359Z","updated_at":"2025-11-02T06:30:33.708Z","avatar_url":"https://github.com/zymawy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Generate slugs when saving Laravel Eloquent models\n| This Is Just A Wrapper [Package]('https://github.com/bpocallaghan/sluggable') To Support Arabic Languages Slug  \n\nProvides a HasSlug trait that will generate a unique slug when saving your Laravel Eloquent model. \n```php\n$model = new Article();\n$model-\u003ename = 'كيف اتعلم البرمجة';\n$model-\u003esave();\n\necho $model-\u003eslug; // ouputs \"كيف-اتعلم-البرمجة\"\n```\n\n## Installation\n\nUpdate your project's `composer.json` file.\n\n```bash\ncomposer require zymawy/arabify\n```\nYou may want to change the function you can do change it from the config\n\n```bash\nphp artisan vendor:publish --provider=\"Zymawy\\Arabify\\ArabifyServiceProvider\"\n```\n\n## Usage\n\nYour Eloquent models can use the `Zymawy\\Arabfiy\\HasSlug` trait and the `Zymawy\\Arabfiy\\SlugOptions` class.\n\nThe trait has a protected method `getSlugOptions()` that you can implement for customization. \n\nHere's an example:\n\n```php\nclass YourEloquentModel extends Model\n{\n    use HasSlug;\n    \n    /**\n     * This function is optional and only required\n     * when you want to override the default behaviour\n     */\n    protected function getSlugOptions()\n    {\n        return SlugOptions::create()\n            -\u003eslugSeperator('-')\n            -\u003egenerateSlugFrom('name')\n            -\u003esaveSlugTo('slug');\n    }\n}\n```\n\nIf you want to generate your slug from a relationship.\n\n```php\nclass YourEloquentModel extends Model\n{\n    use HasSlug;\n    \n    public function getNameAndFooAttribute()\n    {\n        $name = $this-\u003ename;\n        if ($this-\u003efoo) {\n            $name .= \" {$this-\u003efoo-\u003ename}\";\n        }\n\n        return $name;\n    }\n    \n    protected function getSlugOptions()\n    {\n        return SlugOptions::create()\n            -\u003egenerateSlugFrom('name_and_foo');\n    }\n}\n```\n\n## Config\n\nYou do not have to add the method in you model (the above will be used as default). It is only needed when you want to change the default behaviour.\n\nBy default it will generate a slug from the `name` and save to the `slug` column.\n\nIt will suffix a `-1` to make the slug unique. You can disable it by calling `makeSlugUnique(false)`.\n\nIt will use the `-` as a separator. You can change this by calling `slugSeperator('_')`.\n\nYou can use multiple fields as the source of the slug `generateSlugFrom(['firstname', 'lastname'])`.\n\nYou can also pass a `callable` function to `generateSlugFrom()`.\n\nHave a look [here for the options](https://github.com/zymawy/arabify/blob/master/src/SlugOptions.php) and available config functions.\n\n## Credits\n\n* **Ben-Piet O'Callaghan** - _Initial work_ - [bpocallaghan](https://github.com/bpocallaghan)\n* **Hamza Zymawy** - _contributor_ - [zymawy](https://github.com/zymawy)\n\nSee also the list of [contributors](https://github.com/zymawy/arabify/graphs/contributors) who participated in this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzymawy%2Farabify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzymawy%2Farabify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzymawy%2Farabify/lists"}