Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Currently im in the process of architecturing an application based on Laravel-4 and AngularJS

I do not want to create a single page application.

Is it ok to structure the application along the follwoing lines:

EventsController

  • Get() returns a laravel view
  • index() returns json array of events
  • show() returns json event object
  • Store() saves a json event object

and generally all the controllers will act in this way, having a get method that serves a laravel blade view and is then manipulated via AngularJS and its partials. Is this best practice?

share|improve this question

1 Answer

The plan

Use laravel to create the routes and let laravel create the views. You only need to create different view templates, which hold references to your angular controllers.

PagesController

What you could do is create routes for pages, which renders the views. So you could have a PagesController which can do this

EventsController

Then use angular to call for the data and have a EventsController for that. In the EventsController you could add your CRUD, which calls a Event model.

Then this will be the way the traffic get's called

The Model needs to return data. The Controller then will return json, with http status codes.

Mini example

Underneath is a way how I do this with flash messages when logging in.

return Response::json(array('flash' => 'Invalid username or password'), 500);

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.