{"id":17936997,"url":"https://github.com/tomschlick/laravel-linkable","last_synced_at":"2025-03-24T07:31:49.485Z","repository":{"id":48612922,"uuid":"68492905","full_name":"tomschlick/laravel-linkable","owner":"tomschlick","description":"URL binding for Laravel models","archived":false,"fork":false,"pushed_at":"2021-07-18T01:39:18.000Z","size":28,"stargazers_count":25,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T03:13:07.383Z","etag":null,"topics":["http","laravel","links","php","url"],"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/tomschlick.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":"2016-09-18T03:15:43.000Z","updated_at":"2023-11-02T22:01:01.000Z","dependencies_parsed_at":"2022-09-16T00:41:48.159Z","dependency_job_id":null,"html_url":"https://github.com/tomschlick/laravel-linkable","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomschlick%2Flaravel-linkable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomschlick%2Flaravel-linkable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomschlick%2Flaravel-linkable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomschlick%2Flaravel-linkable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomschlick","download_url":"https://codeload.github.com/tomschlick/laravel-linkable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245227460,"owners_count":20580886,"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":["http","laravel","links","php","url"],"created_at":"2024-10-28T22:05:46.824Z","updated_at":"2025-03-24T07:31:49.185Z","avatar_url":"https://github.com/tomschlick.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Linkable\n[![StyleCI](https://styleci.io/repos/68492905/shield)](https://styleci.io/repos/68492905) [![Build Status](https://travis-ci.org/tomschlick/laravel-linkable.svg)](https://travis-ci.org/tomschlick/laravel-linkable) [![Latest Stable Version](https://poser.pugx.org/tomschlick/laravel-linkable/v/stable)](https://packagist.org/packages/tomschlick/laravel-linkable) [![Total Downloads](https://poser.pugx.org/tomschlick/laravel-linkable/downloads)](https://packagist.org/packages/tomschlick/laravel-linkable) [![License](https://poser.pugx.org/tomschlick/laravel-linkable/license)](https://packagist.org/packages/tomschlick/laravel-linkable)\n--------\nLinkable allows you to bind named routes directly to your Eloquent models. It has been tested with Laravel 5.0 and above (although it may work on older versions as well).\n\nMaking calls to `route()` each time you need to generate a url can be cumbersome and makes your Blade files unreadable. Instead with Linkable, you can use this syntax to generate a url: \n```php\n    $model-\u003elink()\n```\n\nThat's it! Check out the full usage below.\n\n## Install via Composer\n```bash\n  composer require tomschlick/laravel-linkable\n```\n\n## Add to your model(s) and implement the interface\n```php\nclass User extends Model\n{\n    use TomSchlick\\Linkable\\Linkable;\n    \n    public function sublink(string $key, array $attr = []) : string\n    {\n        return route(\"users.$key\", [\n                'user_id' =\u003e $this-\u003eid, // 'user_id' is the name of the parameter in the users.* route group\n                ] + $attr);\n    }\n}\n```\n\n## Usage\n\n```php\n$model-\u003elink(); // Link for the resource (example: https://your-site.com/user/7)\n\n$model-\u003esublink('edit'); // SubLink for the resource (example: https://your-site.com/user/7/edit)\n    \n$model-\u003esublink('photos.show', ['photo_id' =\u003e 1234]); // SubLink for the resource (example: https://your-site.com/user/7/photos/1234)\n    \n$model-\u003eredirect(); // Generates a redirect response to the resource to use in a controller return statement.\n    \n$model-\u003esublinkRedirect('edit'); // Generates a redirect response to the resource's edit page to use in a controller return statement.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomschlick%2Flaravel-linkable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomschlick%2Flaravel-linkable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomschlick%2Flaravel-linkable/lists"}