A Laravel package for multilingual models

Overview

Introduction

Latest Version MIT License Offset Earth Larabelles

GitHub Workflow Status StyleCI Codecov Coverage Total Downloads GitBook

laravel-translatable socialcard

If you want to store translations of your models into the database, this package is for you.

This is a Laravel package for translatable models. Its goal is to remove the complexity in retrieving and storing multilingual model instances. With this package you write less code, as the translations are being fetched/saved when you fetch/save your instance.

The full documentation can be found at GitBook.

Installation

composer require astrotomic/laravel-translatable

Quick Example

Getting translated attributes

$post = Post::first();
echo $post->translate('en')->title; // My first post

App::setLocale('en');
echo $post->title; // My first post

App::setLocale('de');
echo $post->title; // Mein erster Post

Saving translated attributes

$post = Post::first();
echo $post->translate('en')->title; // My first post

$post->translate('en')->title = 'My cool post';
$post->save();

$post = Post::first();
echo $post->translate('en')->title; // My cool post

Filling multiple translations

$data = [
  'author' => 'Gummibeer',
  'en' => ['title' => 'My first post'],
  'fr' => ['title' => 'Mon premier post'],
];
$post = Post::create($data);

echo $post->translate('fr')->title; // Mon premier post

Tutorials

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details. You could also be interested in CODE OF CONDUCT.

Security

If you discover any security related issues, please check SECURITY for steps to report it.

Credits

Versions

Package Laravel PHP
v11.6 - v11.9 5.8.* / 6.* / 7.* / 8.* >=7.2
v11.4 - v11.5 5.6.* / 5.7.* / 5.8.* / 6.* >=7.1.3
v11.0 - v11.3 5.6.* / 5.7.* / 5.8.* >=7.1.3

Treeware

You're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees at offset.earth/treeware

Read more about Treeware at treeware.earth

Comments
  • orderByTranslation scope seems to ignore fallback locale

    orderByTranslation scope seems to ignore fallback locale

    Describe the bug orderByTranslation scope seems to ignore fallback locale.

    To Reproduce

    • Save model translation to 'fr'
    • List models in 'fr' using orderByTranslation: list is OK
    • Use app()->setLocale('en')
    • List models in 'en' using orderByTranslation: list is empty (assuming no model was ever translated to en)

    I'm supposed to write mostly in French, but some articles in English. As such, my main locale as well as my fallback_locale both are 'fr' in Laravel's config. In config/translatable.php, I set locale to null, use_fallback to true, use_property_fallback to true, and fallback_locale to null.

    Expected behavior In the absence of translation in English, I would expect orderByTranslation to return the expected list with the French translations available, instead of nothing at all (still assuming I have only French Translations in my database at the moment).

    Versions (please complete the following information)

    • PHP: 7.3.9
    • Database: MariaDB 10.3.17
    • Laravel: 6.1.0
    • Package: 11.5
    bug stale 
    opened by RichardDern 18
  • Trait for simplify validation by locale

    Trait for simplify validation by locale

    Create trait Astrotomic\Translatable\Traits\TranslatableFormRequest for simplify validation rules on FormRequest.

    class DummyFormRequest extends FormRequest
    {
        use TranslatableFormRequest;
        
        public function rules()
        {
            return [
                'name' => 'required',
            ];
        }
    
        public function translatableRules()
        {
            return [
                'title' => 'string',
            ];
        }
    }
    

    This trait generate rules for all available locales :

    • name : string
    • title : required|array
    • title.fr : string
    • title.en : string

    See the tests/TranslatableFormRequestTest.php for more details

    opened by FlYos 16
  • detect accept-language automatically

    detect accept-language automatically

    Hi, First I want to thank you for the nice library. I used to use spatie/laravel-translatable to handle translations of my models and now i moved to Astrotomic/laravel-translatable Everything works fine except that Astrotomic/laravel-translatable doesn't detect accept-language automatically. In the past, I was able to specify which translation i want to get by setting accept-language to the required translation so if i want to get english translation i would set accept-language: en and the package would return the results in that language. Now this doesn't work, the package now returns only the first translation available. How can i make it detect accept-language automatically?

    Thanks

    question 
    opened by Marmahan 15
  • SyncTranslations Method on Update

    SyncTranslations Method on Update

    Is there a method to Sync Translations on update?

    I have one form for all languages and I want to sync all translations when user make changes. Lets say in the new edit French fields were removed/cleared so in this case sync should remove French entry instead of saving null/blank.

    question stale 
    opened by buzzclue 14
  • Check and remove null translated fields from the input request and delete from model

    Check and remove null translated fields from the input request and delete from model

    Is your feature request related to a problem? Please describe. I identified a need that the translatable fields in a form should be nullable, but not save an empty string in the translations related table of the model, because if the locale is available it would return an empty string instead of the configured default from the model.

    When trying to save a request with request->all() the NULL values are not removed at all and the database fails to save.

    Describe the solution you'd like The elegant solution would be for the trait to check and remove NULL values from the input request array and also if there were NULL values in a locale translation, to also remove from the model itself.

    Describe alternatives you've considered For my application I developed a solution, that may point towards some good discussions and possible correct implementation of this in the package. I just don't have the skills to make a pull request of said feature myself, but I hope the following code may inspire you all:

    1. The Model using Translatable must set the default language for this to work
    namespace App\Models;
    
    use Illuminate\Database\Eloquent\Model;
    use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract;
    use Astrotomic\Translatable\Translatable;
    
    class LocalizedModel extends Model implements TranslatableContract
    {
    
        use Translatable;
    
        public function __construct(array $attributes = [])
        {
            parent::__construct($attributes);
    
            $lang = Language::find(1);
            $this->setDefaultLocale($lang->locale);
        }
    }
    
    1. Assuming Category extends LocalizedModel, the following is how I call my method from the Controller:
    $data = Category::findOrFail($id);
    $input = $this->removeEmptyTranslations($request->all(), $data);
    
    1. Assuming I have the locales available in my application in $this->locales I will always have the default locale setup in the model, and therefore the method removeEmptyTranslations does not consider the default locale for removing. The implemented logic is the following:
    /**
         * Remove Empty Translation fields from an input array and also delete
         * from a LocalizedModel instance
         *
         * The array is in the format:
         * "locale" =>  [
         *      "field" => "value"
         *  ]
         * @param array $input
         * @param LocalizedModel $model
         * @return array
         */
        public function removeEmptyTranslations(array $input, LocalizedModel $model = null)
        {
            $removed = [];
    
            foreach($this->locales as $locale) {
                if($locale->locale === $this->lang->locale) {
                    continue;
                }
    
                if(isset($input[$locale->locale])) {
                    $input[$locale->locale] = array_filter($input[$locale->locale]);
                    if(empty($input[$locale->locale])) {
                        $removed[] = $locale->locale;
                        unset($input[$locale->locale]);
                    }
                }
            }
    
            if($model) {
                $model->deleteTranslations($removed);
            }
    
            return $input;
        }
    

    Additional context How the form input looks like. It is a tabbed interface, that changes the input according to the locales provided Captura de Tela 2020-07-17 às 10 42 35

    question stale 
    opened by weidmaster 12
  • RuleFactory doesn't parse Rule::unique second parameter

    RuleFactory doesn't parse Rule::unique second parameter

    I am trying to validate with Rule::unique , if it doesn't replace different column argument.

    RuleFactory::make([
                '%name%' => [
                    'required',
                    Rule::unique('category_translation', '%name%')
                ],
            ])
    

    Output is:

    array:1 [▼
      "en.name" => array:2 [▼
        0 => "required"
        1 => Illuminate\Validation\Rules\Unique {#550 ▼
          #ignore: null
          #idColumn: "id"
          #table: "category_translation"
          #column: "%name%"
          #wheres: []
          #using: []
        }
      ]
    ]
    

    #column must be "en.name"

    bug stale 
    opened by kamranata 12
  • How to fetch all Model objects which are translated to a specific language?

    How to fetch all Model objects which are translated to a specific language?

    I'm using Twill CMS, which uses the previous version of this package to translate models. (dimsav/translatable), however it's read only.

    I have a multilingual website with a blog page that shows all my posts. However, if a blog post isn't translated (yet) to the current locale of the visitor, it just shows an empty post card without any content.

    So how do I fetch all Posts that are translated to the current locale? Let's say my current locale is Spanish, I'd like to only show posts that are translated in the spanish language.

    question stale 
    opened by amirakbulut 12
  • Not updating with Nova

    Not updating with Nova

    Describe the bug I am using this with Nova, but none of the translatable fields seem to be updating.

    To Reproduce Install Nova v3 Setup a model and resource that is translatable Create a new resource, and then try and update its fields Only non-translatable fields are updated without any error

    Expected behavior All fields are updated

    Versions (please complete the following information)

    • PHP: 7.4
    • Database: mysql
    • Laravel: 7.22
    • Package: Nova v3.8.2

    Exception None

    question 
    opened by u12206050 11
  • Fix deleting event

    Fix deleting event

    Deleted event will fire after delete the parent record and it will make error while deleting returned from MySQL so we should set deleting event to fire this script before deleting the parent record.

    opened by ahmedusama250 11
  • Translations are not loaded with Datatables in server-side mode

    Translations are not loaded with Datatables in server-side mode

    Picking up from #113 the problem is not with the select()at all, it is with the datatable when using server-side mode.

    When using server-side, we don't get the results from Eloquent, we let the datatable package make the queries and assemble the final result to send to the client-side, and that is why the translations are not loaded with the request.

    The following code will be the example:

     $datas = Generalsetting::orderBy('id');
            //--- Integrating This Collection Into Datatables
            return Datatables::of($datas)
                ->filterColumn('title', function ($query, $keyword) {
                    $query->whereTranslationLike('title', "%{$keyword}%", 'pt-br');
                })
                ->toJson(); //--- Returning Json Data To Client Side
    

    The filterColumn is needed because without it when performing a search in the datatable, it would try to search the vanilla field of title. So the problem is just that we need to copy such filter logic in every table ^^'

    One approach I can see is for Translatable package to notice that the model (Generalsetting in the example) does use the trait, or have the $translatedAttributes array, and modify the query to join the translated table so the field would be available in the query.

    Other approach would be for withTranslation() to make the query without using get() as well, thus making the query available.

    Another way that I can see this working is for the method listsTranslations() to accept an array of fields and return the query as well, so instead of doing like: Generalsetting::listsTranslations('title')->get() it would be just `Generalsetting::listsTranslations('title')' and we could chain the order and other eloquent calls, without getting the results right away, so the effect would be to only return the fields we care about in the particular table.

    I guess the bottom line is in the fact that every method needs to call get() and can't be used in chain with other Eloquent methods.

    question stale 
    opened by weidmaster 10
  • Scope translatedIn(?string $locale = null) returns the same value as Model::all()

    Scope translatedIn(?string $locale = null) returns the same value as Model::all()

    Tried both methods and gettings the same objects with all translations instead of given in scope arguments

    dd(Post::all(), Post::translatedIn('en')->get());
    
    question 
    opened by Nurzzzone 9
  • RuleFactory on AWS

    RuleFactory on AWS

    I use RulesFactory but on locally is work well on AWS don't work, this my rules:

    $update_rules = RuleFactory::make([ '%title%' => ['required_with:%html_content_logo%,%html_content1%,%html_content2%,%html_content3%,%html_content4%,%html_content5%', 'present', 'string', 'nullable'], '%html_content_logo%' => ['string', 'nullable'], '%html_content1%' => ['string', 'nullable'], '%html_content2%' => ['string', 'nullable'], '%html_content3%' => ['string', 'nullable'], '%html_content4%' => ['string', 'nullable'], '%html_content5%' => ['string', 'nullable'], ]);

    question 
    opened by Giovanni-Petrella 0
  • orderByTranslation gets ignored

    orderByTranslation gets ignored

    Hey guys, i have the problem that my orderByTranslation is getting ignored. I have the following:

        Cache::tags(['food', 'food-products'])->rememberForever('non-empty-products', function () {
            return Product::orderByTranslation('name', 'asc')->with(['places', 'brands', 'translations', 'product_images'])->withCount(['places', 'brands', 'translations', 'product_images'])->having('places_count', '>', 0)->orHaving('brands_count', '>', 0)->get();
        });
    

    Do you have an idea what cause it can have?

    Greets Talha

    opened by Konzeptcode 0
  • Bump actions/stale from 6.0.1 to 7.0.0

    Bump actions/stale from 6.0.1 to 7.0.0

    Bumps actions/stale from 6.0.1 to 7.0.0.

    Release notes

    Sourced from actions/stale's releases.

    v7.0.0

    ⚠️ This version contains breaking changes ⚠️

    What's Changed

    Breaking Changes

    • In this release we prevent this action from managing the stale label on items included in exempt-issue-labels and exempt-pr-labels
    • We decided that this is outside of the scope of this action, and to be left up to the maintainer

    New Contributors

    Full Changelog: https://github.com/actions/stale/compare/v6...v7.0.0

    Changelog

    Sourced from actions/stale's changelog.

    [7.0.0]

    :warning: Breaking change :warning:

    Commits
    • 6f05e42 draft release for v7.0.0 (#888)
    • eed91cb Update how stale handles exempt items (#874)
    • 10dc265 Merge pull request #880 from akv-platform/update-stale-repo
    • 9c1eb3f Update .md files and allign build-test.yml with the current test.yml
    • bc357bd Update .github/workflows/release-new-action-version.yml
    • 690ede5 Update .github/ISSUE_TEMPLATE/bug_report.md
    • afbcabf Merge branch 'main' into update-stale-repo
    • e364411 Update name of codeql.yml file
    • 627cef3 fix print outputs step (#859)
    • 975308f Merge pull request #876 from jongwooo/chore/use-cache-in-check-dist
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
  • Why data returned with astrotomic/laravel-translatable have invalid language?

    Why data returned with astrotomic/laravel-translatable have invalid language?

    On laravel 9 site I added astrotomic/laravel-translatable and getting set of data I see a bit different results I expected As I have 2 languages defined in config/translatable.php with default 'en' :

    'locales' => [
        'en',
        'fr',
    ...
        'locale' => 'en',
    ...
    

    I do request with 'fr' locale:

    $banners           = Banner
        ::translatedIn(app()->getLocale())
        ->get(function ($banner);
    

    I check logs :

                [id] => 5
                [text] => laravel library site
                [description] => laravel is a powerful php library
                ...
                [translations] => Array
                    (
                        [0] => Array
                            (
                                [id] => 13
                                [text] => laravel library site
                                [description] => laravel is a powerful php library
                                ...
                            )
    
                        [1] => Array
                            (
                                [id] => 15
                                [text] => site de la bibliothèque laravel
                                [description] => laravel est une puissante bibliothèque php
                                ...
                            )
    
                    )
    

    )

    Text in text, description fields(of banner, not translations] subarray...) are in ‘en’, not in 'fr', as I expected...

    In file app/Models/Banner.php I have :

    <?php
    
    namespace App\Models;
    
    use Illuminate\Database\Eloquent\Model;
    
    use Spatie\MediaLibrary\HasMedia;
    use Spatie\MediaLibrary\InteractsWithMedia;
    use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract;
    use Astrotomic\Translatable\Translatable;
    
    class Banner extends Model implements HasMedia, TranslatableContract
    {
        use InteractsWithMedia;
        use Translatable;
    
        protected $table = 'banners';
        protected $primaryKey = 'id';
        public $timestamps = false;
    
        protected $fillable = [/*'text', 'description',*/ 'url', 'active', 'ordering', 'banner_bgimage_id', 'updated_at'];
        public $translatedAttributes = ['text', 'description'];
    
            "laravel/framework": "^9.19",
            "astrotomic/laravel-translatable": "^11.11",
    

    and in app/Models/BannerTranslation.php :

    <?php
    namespace App\Models;
    
    use DB;
    use Illuminate\Database\Eloquent\Model;
    
    class BannerTranslation extends Model
    {
        public $timestamps = false;
        protected $fillable = ['text', 'description', 'updated_at'];
    }
    

    Seems I did not miss any config options, but what is wrong ?

    "astrotomic/laravel-translatable": "^11.11",
    "laravel/framework": "^9.19",
    

    Thanks in advance!

    question 
    opened by PetroGromovo 2
  • Bump actions/checkout from 3.1.0 to 3.2.0

    Bump actions/checkout from 3.1.0 to 3.2.0

    Bumps actions/checkout from 3.1.0 to 3.2.0.

    Release notes

    Sourced from actions/checkout's releases.

    v3.2.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3...v3.2.0

    Changelog

    Sourced from actions/checkout's changelog.

    Changelog

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
  • withTranslation's eager loading

    withTranslation's eager loading

    Describe the bug According to the docs, this is eager loading. Post::withTranslation()->get(); It actually is. But when do the foreach

                foreach ($rows as $key => $row) {            
                    echo '<pre>', print_r($row->translation->name, 1), "</pre>";
                }
    

    It does the sql query for every row. If 10 rows, it's 1 sql for my product table, 10 sql for product_relations table

    But if I use laravel's default's with() Product::with('translation')->get(); It's really eager loading.

    So, maybe there is something wrong with the function withTranslation() ?

    To Reproduce

            //$products = (new Product)->with('translation')->get();
            $products = (new Product)->withTranslation()->get();
            // echo '<pre>', print_r($products, 1), "</pre>"; // This is always eager loading.
            foreach ($products as $key => $row) {
                echo '<pre>', print_r($row->translation->name, 1), "</pre>"; // This depends.
            }
    
    documentation help wanted question hacktoberfest 
    opened by ronrun 1
Releases(v11.11.0)
  • v11.11.0(Oct 10, 2022)

    What's Changed

    • feat(github-actions): Dependabot Github Actions update check by @chrillep in https://github.com/Astrotomic/laravel-translatable/pull/289
    • Bump actions/cache from 2 to 3 by @dependabot in https://github.com/Astrotomic/laravel-translatable/pull/290
    • Bump codecov/codecov-action from 1 to 3 by @dependabot in https://github.com/Astrotomic/laravel-translatable/pull/291
    • Bump stefanzweifel/git-auto-commit-action from 4.0.0 to 4.15.0 by @dependabot in https://github.com/Astrotomic/laravel-translatable/pull/293
    • Bump actions/stale from 2.0.0 to 6.0.0 by @dependabot in https://github.com/Astrotomic/laravel-translatable/pull/294
    • Bump actions/checkout from 2 to 3 by @dependabot in https://github.com/Astrotomic/laravel-translatable/pull/295
    • Bump creyD/prettier_action from 3.0 to 4.2 by @dependabot in https://github.com/Astrotomic/laravel-translatable/pull/296
    • Bump actions/stale from 6.0.0 to 6.0.1 by @dependabot in https://github.com/Astrotomic/laravel-translatable/pull/299
    • Change relation() to use the new ofMany by @quintenbuis in https://github.com/Astrotomic/laravel-translatable/pull/297

    New Contributors

    • @chrillep made their first contribution in https://github.com/Astrotomic/laravel-translatable/pull/289
    • @dependabot made their first contribution in https://github.com/Astrotomic/laravel-translatable/pull/290
    • @quintenbuis made their first contribution in https://github.com/Astrotomic/laravel-translatable/pull/297

    Full Changelog: https://github.com/Astrotomic/laravel-translatable/compare/v11.10.0...v11.11.0

    Source code(tar.gz)
    Source code(zip)
  • v11.10.0(Feb 5, 2022)

  • v11.9.1(Nov 19, 2020)

  • v11.9.0(Sep 9, 2020)

  • v11.8.3(Jul 8, 2020)

  • v11.8.2(Jun 24, 2020)

  • v11.8.1(Apr 23, 2020)

  • v11.8.0(Mar 3, 2020)

  • 11.7.1(Feb 27, 2020)

  • v11.7.0(Jan 28, 2020)

  • v11.6.1(Nov 6, 2019)

  • v11.6.0(Nov 1, 2019)

  • v11.5.2(Oct 9, 2019)

  • v11.5.1(Sep 5, 2019)

  • v11.5.0(Sep 5, 2019)

  • v11.4.0(Sep 4, 2019)

  • v11.3.0(Aug 7, 2019)

  • v11.2.1(Aug 7, 2019)

  • v11.2.0(Aug 7, 2019)

  • v11.1.3(Aug 2, 2019)

  • v11.1.2(Jul 16, 2019)

  • v11.1.1(Jun 24, 2019)

  • v11.1.0(Jun 20, 2019)

    • Add missing dependencies illuminate/contracts and illuminate/database - #9
    • Add \Astrotomic\Translatable\Contracts\Translatable interface
    • Split \Astrotomic\Translatable\Translatable into multiple traits - but use them in the main one
    • Add translation relationship - #3
    • Flag methods, not defined in interface as @internal
    • Rename getRelationKey() to getTranslationRelationKey() to prevent conflicts - the original one is @deprecated and will be dropped in next major release
    • Update the where translation scopes to unify them and remove duplicated code - #2
    Source code(tar.gz)
    Source code(zip)
  • v11.0.0(Jun 18, 2019)

    • Add PHP7 type-hints #557
    • Move to Astrotomic #1 & #4

    migrate from dimsav to astrotomic

    1. upgrade to dimsav/laravel-translatable:v10.0.0
    2. run composer remove dimsav/laravel-translatable
    3. run composer require astrotomic/laravel-translatable
    4. replace Dimsav\ by Astrotomic\ in your whole project (namespace change)
    Source code(tar.gz)
    Source code(zip)
Owner
Astrotomic
We want to provide helpful, solid and easy to use open source packages. Most of them will be for Laravel - but sometimes also plain PHP.
Astrotomic
Searches for multilingual phrases in Laravel project and automatically generates language files for you.

Laravel Lang Generator Searches for multilingual phrases in a Laravel project and automatically generates language files for you. You can search for n

Gleb 5 Oct 19, 2022
Get estimated read time of an article. Similar to medium.com's "x min read". Multilingual including right-to-left written languages. Supports JSON, Array and String output.

Read Time Calculates the read time of an article. Output string e.g: x min read or 5 minutes read. Features Multilingual translations support. Static

Waqar Ahmed 8 Dec 9, 2022
Trait for multilingual resource file support

⚡ Usage This library supports MultilingualResourceTrait which can be used in PluginBase. Multilingual support of resource files is possible using this

PocketMine-MP projects of PresentKim 1 Jun 7, 2022
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.

Laravel-Mediable Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel. Features Filesystem-driven appro

Plank Design 654 Dec 30, 2022
The package lets you generate TypeScript interfaces from your Laravel models.

Laravel TypeScript The package lets you generate TypeScript interfaces from your Laravel models. Introduction Say you have a model which has several p

Boris Lepikhin 296 Dec 24, 2022
A Laravel package for attachment files to models

Laravel attachmentable package A package for attachment files to models Installation Run the command below to add this package: composer require larav

Laravel Iran Community 4 Jan 18, 2022
A package to implement repository pattern for laravel models

Laravel Model UUID A simple package to use Repository Pattern approach for laravel models . Repository pattern Repositories are classes or components

null 26 Dec 21, 2022
A Laravel package making a diagram of your models, relations and the ability to build them with it

Laravel Schematics This package allows you to make multiple diagrams of your Eloquent models and their relations. It will help building them providing

Maarten Tolhuijs 1.4k Dec 31, 2022
Laravel package to search through multiple Eloquent models.

Laravel package to search through multiple Eloquent models. Supports sorting, pagination, scoped queries, eager load relationships and searching through single or multiple columns.

Protone Media 845 Jan 1, 2023
This package allows you to easily work with NanoID in your Laravel models.

Laravel Model UUIDs Introduction Huge thanks to Micheal Dyrynda, whose work inspired me to create this package based on laravel-model-nanoid but uses

Parables Boltnoel 3 Jul 27, 2022
Package with small support traits and classes for the Laravel Eloquent models

Contains a set of traits for the eloquent model. In future can contain more set of classes/traits for the eloquent database.

Martin Kluska 3 Feb 10, 2022
This package gives Eloquent models the ability to manage their friendships.

Laravel 5 Friendships This package gives Eloquent models the ability to manage their friendships. You can easily design a Facebook like Friend System.

Alex Kyriakidis 690 Nov 27, 2022
A small package for adding UUIDs to Eloquent models.

A small package for adding UUIDs to Eloquent models. Installation You can install the package via composer: composer require ryangjchandler/laravel-uu

Ryan Chandler 40 Jun 5, 2022
An opinionated package to create slugs for Eloquent models

Generate slugs when saving Eloquent models This package provides a trait that will generate a unique slug when saving any Eloquent model. $model = new

Spatie 1.1k Jan 4, 2023
Kalibrant - a package that provides a simple way to manage your models settings

Introduction For your laravel 9.x applications, Kalibrant is a package that provides a simple way to manage your models settings. It is a simple way t

Starfolk 3 Jun 18, 2022
A package to generate YouTube-like IDs for Eloquent models

Laravel Hashids This package provides a trait that will generate hashids when saving any Eloquent model. Hashids Hashids is a small package to generat

Λгi 25 Aug 31, 2022
Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models.

Laravel Wrapper for PostgreSQL's Geo-Extension Postgis Features Work with geometry classes instead of arrays. $model->myPoint = new Point(1,2); //lat

Max 340 Jan 6, 2023
An Eloquent Way To Filter Laravel Models And Their Relationships

Eloquent Filter An Eloquent way to filter Eloquent Models and their relationships Introduction Lets say we want to return a list of users filtered by

Eric Tucker 1.5k Jan 7, 2023
Easy creation of slugs for your Eloquent models in Laravel

Eloquent-Sluggable Easy creation of slugs for your Eloquent models in Laravel. NOTE: These instructions are for the latest version of Laravel. If you

Colin Viebrock 3.6k Dec 30, 2022