All Projects → tomschlick → laravel-linkable

tomschlick / laravel-linkable

Licence: MIT license
URL binding for Laravel models

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-linkable

quill-magic-url
Automatically convert URLs to links in Quill
Stars: ✭ 86 (+290.91%)
Mutual labels:  url, links
ngx-linkifyjs
Angular V8 wrapper for linkifyjs - library for finding links in plain text and converting them to HTML <a> tags via linkifyjs
Stars: ✭ 40 (+81.82%)
Mutual labels:  url, links
Autolink Java
Java library to extract links (URLs, email addresses) from plain text; fast, small and smart
Stars: ✭ 157 (+613.64%)
Mutual labels:  url, links
seenreq
Generate an object for testing if a request is sent, request is Mikeal's request.
Stars: ✭ 42 (+90.91%)
Mutual labels:  url
immurl
🔗 A tiny immutable URL library, backed by the native whatwg URL.
Stars: ✭ 23 (+4.55%)
Mutual labels:  url
uri
A type to represent, query, and manipulate a Uniform Resource Identifier.
Stars: ✭ 16 (-27.27%)
Mutual labels:  url
Omeka-plugin-CleanUrl
Omeka plugin that allows to have clean, searchable and readable URL like https://example.com/my_collection/dc:identifier instead of https://example.com/items/show/internal_code.
Stars: ✭ 13 (-40.91%)
Mutual labels:  url
url-trailing-slash
Allows enforcing URL routes with or without trailing slash
Stars: ✭ 35 (+59.09%)
Mutual labels:  url
Links
A responsive webpage for putting all our links in. A substitute for linktree created using HTML, CSS and JS using custom admin dashboard.
Stars: ✭ 18 (-18.18%)
Mutual labels:  links
golgi
A composable routing library for Haxe.
Stars: ✭ 37 (+68.18%)
Mutual labels:  url
node-url-shortener
URL Shortener in Base58 using Node.js, Express, Sequelize, Mocha and Bootstrap
Stars: ✭ 21 (-4.55%)
Mutual labels:  url
deadlink
💀 Checks and fixes URLs in code and documentation.
Stars: ✭ 105 (+377.27%)
Mutual labels:  url
links-to-free-online-courses
📖 Free online courses resources.
Stars: ✭ 51 (+131.82%)
Mutual labels:  links
gravatar-url-generator
A fun and friendly generator of Gravatar urls.
Stars: ✭ 44 (+100%)
Mutual labels:  url
relateurl
Create a relative URL with options to minify.
Stars: ✭ 52 (+136.36%)
Mutual labels:  url
b23.wtf
Remove tracing parameters from b23.tv/*.
Stars: ✭ 85 (+286.36%)
Mutual labels:  url
Odyssey
A piece of software that shows a traceroute of a URL redirect path
Stars: ✭ 41 (+86.36%)
Mutual labels:  url
url
Build and parse URLs. Useful for HTTP and "routing" in single-page apps (SPAs)
Stars: ✭ 69 (+213.64%)
Mutual labels:  url
1c http
Подсистема 1С для работы с HTTP
Stars: ✭ 48 (+118.18%)
Mutual labels:  url
fleeg-platform
Fleeg is a free and open source platform to index and search pages.
Stars: ✭ 21 (-4.55%)
Mutual labels:  links

Laravel Linkable

StyleCI Build Status Latest Stable Version Total Downloads License

Linkable 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).

Making 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:

    $model->link()

That's it! Check out the full usage below.

Install via Composer

  composer require tomschlick/laravel-linkable

Add to your model(s) and implement the interface

class User extends Model
{
    use TomSchlick\Linkable\Linkable;
    
    public function sublink(string $key, array $attr = []) : string
    {
        return route("users.$key", [
                'user_id' => $this->id, // 'user_id' is the name of the parameter in the users.* route group
                ] + $attr);
    }
}

Usage

$model->link(); // Link for the resource (example: https://your-site.com/user/7)

$model->sublink('edit'); // SubLink for the resource (example: https://your-site.com/user/7/edit)
    
$model->sublink('photos.show', ['photo_id' => 1234]); // SubLink for the resource (example: https://your-site.com/user/7/photos/1234)
    
$model->redirect(); // Generates a redirect response to the resource to use in a controller return statement.
    
$model->sublinkRedirect('edit'); // Generates a redirect response to the resource's edit page to use in a controller return statement.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].