Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching related data with Model's find operation. #4

Closed
ish1301 opened this issue Jan 31, 2013 · 3 comments
Closed

Fetching related data with Model's find operation. #4

ish1301 opened this issue Jan 31, 2013 · 3 comments
Milestone

Comments

@ish1301
Copy link

ish1301 commented Jan 31, 2013

Your extension works great, except fetching related model's data on find operations.

So I changed your behavior a little to fetch related data, please checkout my commit.
ish1301@6b42cf1

@zoghal
Copy link
Owner

zoghal commented Feb 1, 2013

thanks dear,
I did not understand your changes.
If possible, please explain with an example.

@ish1301
Copy link
Author

ish1301 commented Mar 16, 2013

My apologies zoghal, I took too much time to respond.

This code will check relationships like hasMany, belongsTo or hasOne and tries to fetch translated data for the find operation on current model.

e.g.

// Menu model
class Menu extends AppModel {
    public $hasMany = 'Link';
    public $actsAs = array('MultiTranslate' => array('name'));

// Link model
class Link extends AppModel {
    public $actsAs = array('MultiTranslate' => array('name'));

// Menu Controller
class MenuController extends AppController {
    public function index($id) {
        $menu = $this->Menu->findById($id);
    }

Without above commit code $menu

$menu = array('Menu' => array(
    'id' => '1',
    'name' => 'User Menu'
), 'Link' => array(
    0 => array(
         'id' => '1'
    ),
    1 => array(
         'id' => '2'
    )
));

With above commit code $menu

$menu = array('Menu' => array(
    'id' => '1',
    'name' => 'User Menu'
), 'Link' => array(
    0 => array(
         'id' => '1',
         'name' => 'Sign In'
    ),
    1 => array(
         'id' => '2'
         'name' => 'Register Now'
    )
));

@zoghal
Copy link
Owner

zoghal commented Dec 20, 2013

@ish1301 hi,I'm starting work on a new version. Please in Milestone 2.5 announce everything that is needed to be added in the new version.

@zoghal zoghal closed this as completed Dec 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants