2
\$\begingroup\$

I am writing an application with the repositories concept in php with laravel framework.
In my controller I have this method:

/**
 * Update the specified resource in storage.
 * PUT /locais/{id}
 *
 * @param int $id
 * @return Response
 */
public function update($id)
{
 $data = Input::all();
 $data['str_categories'] = implode(',', $data['categories']);
 $this->place->update($id, $data);
 return Redirect::route('locais.index');
}

I am concerned about this line in controller:
$data['str_categories'] = implode(',', $data['categories']);

This line can be in controller method? Or this is a responsibility of places repository?

asked Jul 29, 2015 at 15:29
\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Logic or data transformation should usually be moved out of the controller. Your places repository seems like a better choice for the implode. After all, one of the major purposes of repositories is to decouple data handling and storage as much as possible from other parts of the application, including controller.s

answered Jul 29, 2015 at 19:06
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.