src/Models/Repository/CategoryRepository.php
public function update(Category $category, array $data)
    {
        if (Session::has('multi_language_enabled')) {
            $languageId = $data['language_id'];
            $languaModel = Language::find($languageId);
            
            if ($languaModel->is_default) {
                return $category->update($data);
            } else {
                $category->update(Arr::only($data, ['parent_id']));

                $translatedModel = $category
                    ->translations()
                    ->whereLanguageId($languageId)
                    ->first();
                if (null === $translatedModel) {
                    return CategoryTranslation::create(
                        array_merge($data, ['category_id' => $category->id])
                    );
                } else {
                    $translatedModel->update(
                        $data,
                        $category->getTranslatedAttributes()
                    );

                    return $translatedModel;
                }

            }
        } else {
            return $category->update($data);
        }
    }
public function update(Category $category, array $data)
    {
        if (Session::has('multi_language_enabled')) {
            $languageId = $data['language_id'];
            $languaModel = Language::find($languageId);
            
            if ($languaModel->is_default) {
                return $category->update($data);
            } else {
                $category->update(Arr::only($data, ['parent_id']));

                $translatedModel = $category
                    ->translations()
                    ->whereLanguageId($languageId)
                    ->first();
                if (null === $translatedModel) {
                    return CategoryTranslation::create(
                        array_merge($data, ['category_id' => $category->id])
                    );
                } else {
                    $translatedModel->update(
                        $data,
                        $category->getTranslatedAttributes()
                    );

                    return $translatedModel;
                }

            }
        } else {
            return $category->update($data);
        }
    }
public function update ( Category $ category , array $ data ) { if ( Session :: has ( 'multi_language_enabled' ) ) { $ languageId = $ data [ 'language_id' ] ; $ languaModel = Language :: find ( $ languageId ) ; if ( $ languaModel -> is_default ) { return $ category -> update ( $ data ) ; } else { $ category -> update ( Arr :: only ( $ data , [ 'parent_id' ] ) ) ; $ translatedModel = $ category -> translations ( ) -> whereLanguageId ( $ languageId ) -> first ( ) ; if ( null === $ translatedModel ) { return CategoryTranslation :: create ( array_merge ( $ data , [ 'category_id' => $ category -> id ] ) ) ; } else { $ translatedModel -> update ( $ data , $ category -> getTranslatedAttributes ( ) ) ; return $ translatedModel ; } } } else { return $ category -> update ( $ data ) ; } }
Update a Category

@param \AvoRed\Framework\Models\Database\Categoy $category
@param array $data
@return \AvoRed\Framework\Models\Database\Categoy
Update a Category