GithubHelp home page GithubHelp logo

jobmetric / laravel-url Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 27 KB

It is a package for slug storage management in each model that you can use in your Laravel projects.

License: MIT License

PHP 100.00%
laravel laravel-package package slug slugable

laravel-url's Introduction

Contributors Forks Stargazers MIT License LinkedIn

Url And Slug for laravel Model

It is a package for url and slug storage management in each model that you can use in your Laravel projects.

Install via composer

Run the following command to pull in the latest version:

composer require jobmetric/laravel-url

Documentation

Undergoing continuous enhancements, this package evolves each day, integrating an array of diverse features. It stands as an indispensable asset for enthusiasts of Laravel, offering a seamless way to harmonize their projects with url database models.

In this package, you can employ it seamlessly with any model requiring database url.

Now, let's delve into the core functionality.

Before doing anything, you must migrate after installing the package by composer.

php artisan migrate

Meet the HasUrl class, meticulously designed for integration into your model. This class automates essential tasks, ensuring a streamlined process for:

In the first step, you need to connect this class to your main model.

use JobMetric\Url\HasUrl;

class Product extends Model
{
    use HasUrl;
}

How is it used?

Storing a url

You can now use the HasUrl class to store urls for your model. The following example shows how to create a new product by saving a url:

$product = new Product();
$product->name = 'Product 1';
$product->save();

$product->dispatchUrl('slug', 'product');

In this example, the dispatchUrl method is used to store an url for the product model. The first parameter is the value of the url, and the second parameter is the type of url.

Retrieving a url

You can retrieve a url for a model using the getUrl method. The following example shows how to retrieve a url for a product:

$product = Product::find(1);
$product->getUrl();

or you can use the following code to get the url of the product:

$product = Product::find(1);
$product->url;

In this example, we retrieved a product from the database and then retrieved the url for the product using the getUrl method.

Forget a url

You can forget a url for a model using the forgetUrl method. The following example shows how to forget a url for a product:

$product = Product::find(1);
$product->forgetUrl('product');

In this example, we retrieved a product from the database and then forgot the url for the product using the forgetUrl method. The parameter is the type of url.

Contributing

Thank you for considering contributing to the Laravel Url! The contribution guide can be found in the CONTRIBUTING.md.

License

The MIT License (MIT). Please see License File for more information.

laravel-url's People

Contributors

majidmohammadian avatar

Stargazers

 avatar Job Metric avatar

Watchers

 avatar Job Metric avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.