Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Laravel 5.0 #53

Closed
jufy opened this issue Sep 24, 2014 · 16 comments
Closed

Laravel 5.0 #53

jufy opened this issue Sep 24, 2014 · 16 comments
Assignees
Milestone

Comments

@jufy
Copy link

jufy commented Sep 24, 2014

Please add support for Laravel 5.0 :)

@dimsav
Copy link
Owner

dimsav commented Sep 24, 2014

Comming soon. Stay tuned!

@plmarcelo
Copy link
Contributor

Hello Dimitious,

When are you planning to release it? Just to know, because have a project that I'm migrating to v5.0, and this is one of the packages that I'm waiting for. If there is something that can help, just let me know it.

Thank you and best regards,
Pedro

@dimsav
Copy link
Owner

dimsav commented Sep 29, 2014

Hello folks,

I created a laravel 5 branch of this package. Can you try it and tell me how it works?

@plmarcelo
Copy link
Contributor

Hi,

Right now I'm testing it, but I'm dealing with an error "Trait 'Dimsav\Translatable\Translatable' not found". But I keep trying, because I just imported a little portion of my project and maybe is my fault the error.

Thank you and Best Regards,
Pedro

@plmarcelo
Copy link
Contributor

Sorry,

As I installed it from git, had to add the package path to autoload. Now continue testing it.

Best Regards and thank you
Pedro

@dimsav
Copy link
Owner

dimsav commented Sep 29, 2014

Thanks for the info. I will check the autoloading issue and keep you up to date

@plmarcelo
Copy link
Contributor

Hello,

For me it is working very well. I was having another issue, but was related to my key field name that is language_id. But I overwrited it in the model and everything now works fine.

Best regards and thank you

@dimsav
Copy link
Owner

dimsav commented Sep 30, 2014

@plmarcelo thanks for the feedback.

@nWidart please write here if you have any issues with L5.

@nWidart
Copy link
Contributor

nWidart commented Sep 30, 2014

For what I've tested until now:

  • The getters work fine $model->property

  • The mass assignment setters do not work. Ie:

    $model->create([
       'fr' => ['name' => 'Grèce'],
       'en' => ['name' => 'Greek'],
    ]);
    

    I had to loop over the properties in the different languages.

@plmarcelo
Copy link
Contributor

Hi, I did this and it worked fine for me:

$data = array(
    'show_order' => 4,
    'en'  => array('label' => 'Category 4'),
    'es'  => array('label' => 'Categoría 4'),
);

$category = FaqCategory::create($data);

Maybe, you have a required field on main table and you are not filling it. Could be?

@nWidart
Copy link
Contributor

nWidart commented Sep 30, 2014

Hm I don't think so. I'll give it another shot tonight and give a heads up here.

@nWidart
Copy link
Contributor

nWidart commented Sep 30, 2014

This is my raw data:
screen shot 2014-09-30 at 08 24 29 pm

Now with this, doing $category->update($data) returns preg_replace(): Parameter mismatch, pattern is a string while replacement is an array .
Same with Category::create($data).

My Category model:

<?php namespace Modules\Blog\Entities;

use Dimsav\Translatable\Translatable;
use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    use Translatable;

    public $translatedAttributes = ['name', 'slug'];
    protected $fillable = ['name', 'slug'];

    public function posts()
    {
        return $this->belongsToMany('Post');
    }
}

My Category translation model:

<?php namespace Modules\Blog\Entities;

use Illuminate\Database\Eloquent\Model;

class CategoryTranslation extends Model
{
    public $timestamps = false;
    protected $fillable = ['name', 'slug'];
}

@plmarcelo
Copy link
Contributor

You should be having any other problem, I reproduced your models and it works fine for me. What are you tables fields?

My Models

<?php namespace Gnikoob\Models;

use Dimsav\Translatable\Translatable;
use Illuminate\Database\Eloquent\Model;

/*
Table fields
id INT(11) NOT NULL AUTO_INCREMENT,
*/
class Category extends Model {

    use Translatable;

    public $translatedAttributes = ['name', 'slug'];
    protected $fillable = ['name', 'slug'];

    public $timestamps = false;
}

Translation model:

<?php namespace Gnikoob\Models;

use Illuminate\Database\Eloquent\Model;

/*
Table fields
category_id INT(11) NOT NULL,
locale CHAR(2) NOT NULL,
name VARCHAR(100) NOT NULL,
slug VARCHAR(100) NOT NULL,
*/
class CategoryTranslation extends Model {

    protected $fillable = ['name', 'slug'];

    public $timestamps = false;

}

Route file for testing:

Route::get('/', function ()
{
    $data = [
        '_method' => 'PUT',
        '_token'  => 'lkasndnfakjsdhnfklaksdmnfaisubdnflajnsdf',
        'en'      => ['name' => 'Category 2', 'slug' => 'category_2'],
        'es'      => ['name' => 'Categoría 2', 'slug' => 'categoria_2'],
    ];

    $category = \Gnikoob\Models\Category::create($data);

    return $category->translate('en')->name . '(' . $category->translate('en')->slug . ')'; // Category 4
});

The result was this:
Category 2(category_2)

@nWidart
Copy link
Contributor

nWidart commented Oct 1, 2014

Oh, that's weird...
My DB structure looks like this:

Table categories
id INT(10) PRI NOT NULL
created at TIMESTAMP
updated at TIMESTAMP
Table category_translations
id INT(10) PRI NOT NULL
name VARCHAR(255) NOT NULL
slug VARCHAR(255) NOT NULL
category_id INT(10) PRI NOT NULL
locale VARCHAR(255) NOT NULL

@dimsav
Copy link
Owner

dimsav commented Oct 1, 2014

The issue sounds to be related to #38. Can you please compare your mysql versions?

@dimsav dimsav added this to the version 5 milestone Oct 8, 2014
@dimsav dimsav self-assigned this Oct 9, 2014
@dimsav
Copy link
Owner

dimsav commented Nov 6, 2014

Laravel 5 is now supported in the development branch. If you have any problems please create a new issue.

@dimsav dimsav closed this as completed Nov 6, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants