rinvex / laravel-support

Rinvex common support helpers, contracts, and traits required by various Rinvex packages. Validator functionality, and basic controller included out-of-the-box.
https://rinvex.com
MIT License
73 stars 70 forks source link

Update HasTranslations.php #37

Closed altynbek07 closed 3 years ago

altynbek07 commented 4 years ago

This method allow merge translatable property from extend class. It works like mergeCasts or mergeFillable methods. Example:

<?php

namespace App\Models;

use Rinvex\Categories\Models\Category as BaseCategory;

class Category extends BaseCategory
{
    /**
     * Create a new Eloquent model instance.
     *
     * @param array $attributes
     */
    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $this->mergeFillable([
            'meta_title',
            'meta_description',
            'is_active',
            'is_menu',
        ]);

        $this->mergeCasts([
            'is_active' => 'boolean',
            'is_menu' => 'boolean',
        ]);

        $this->mergeTranslatable([
            'meta_title',
            'meta_description',
        ]);
    }
}
codeclimate[bot] commented 4 years ago

Code Climate has analyzed commit cb5a4bcc and detected 0 issues on this pull request.

View more on Code Climate.

Omranic commented 3 years ago

Thank you @altynbek07, that's a good one. Merged!