How to retrieve siteid in custom controller?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
D-Cell
Posts: 23
Joined: 17 Dec 2018, 17:47

How to retrieve siteid in custom controller?

Post by D-Cell » 05 Feb 2019, 10:45

Hello! The question may sound silly, but how can i retrieve parameters like Aimeos "siteid" and "site" in controllers, which are not related to Aimeos?

For example i provide one of my cases - in my Laravel app there is a PostController. Some methods of this controller are used in admin panel to create/edit/delete posts. Other methods i use in frontend.

In admin panel, after creation of the new post i would like to redirect the user to the list of all posts list in admin panel.
Usually, to get this done, in my controllers i use something like this:

Code: Select all

public function store(Request $request)
    {
       ...
        Post::create($request->all());

        return redirect('/path/that/i/need')->with('success', 'Post created!');
    }
But now i need to have redirect like this:

Code: Select all

return redirect('/admin/{site}/jqadm/search/posts')->with('success', 'Post created!');
How can i retrieve "siteid" and "site" in my controllers, which are not related to Aimeos?
Thank you!

D-Cell
Posts: 23
Joined: 17 Dec 2018, 17:47

Re: How to retrieve siteid in custom controller?

Post by D-Cell » 05 Feb 2019, 19:36

I`m sorry, i forgot to provide my system info.
My Laravel version is 5.7.24, Aimeos version is 2019.01.1
System is Linux Fedora 29, PHP 7.2.13, Mariadb 10.2.19, Nginx.

User avatar
aimeos
Administrator
Posts: 7889
Joined: 01 Jan 1970, 00:00

Re: How to retrieve siteid in custom controller?

Post by aimeos » 06 Feb 2019, 10:57

The site code must be already part of the URL (e.g. /admin/{site}/jqadm/save/posts), then you can get it with

Code: Select all

$this->getView()->param( 'site' )
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply