diff --git a/.gitignore b/.gitignore index e0d0d37..7ad3382 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ composer.phar composer.lock .DS_Store -Thumbs.db \ No newline at end of file +Thumbs.db +.idea/ diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index bb3579e..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1387294279480 - 1387294279480 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/database/migrations/2013_12_17_154848_create_todos_table.php b/app/database/migrations/2013_12_17_154848_create_todos_table.php new file mode 100644 index 0000000..941bb41 --- /dev/null +++ b/app/database/migrations/2013_12_17_154848_create_todos_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->text('body'); + $table->boolean('completed'); + $table->timestamps(); + }); + } + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('todos'); + } + +} diff --git a/app/models/Todo.php b/app/models/Todo.php new file mode 100644 index 0000000..34a6a0b --- /dev/null +++ b/app/models/Todo.php @@ -0,0 +1,10 @@ + + + + + Angular Training + + + + + +

+ Todos + ({{ remaining() }} remaining) +

+ + + + + +
+ + +
+ + + + + diff --git a/public/js/main.js b/public/js/main.js new file mode 100644 index 0000000..8c80f3f --- /dev/null +++ b/public/js/main.js @@ -0,0 +1,28 @@ +function TodosController($scope, $http) { + + $http.get('/todos').success(function(todos) { + $scope.todos = todos; + }); + + $scope.remaining = function() { + var count = 0; + + angular.forEach($scope.todos, function(todo) { + count += todo.completed ? 0 : 1; + }); + + return count; + } + + $scope.addTodo = function() { + var todo = { + body: $scope.newTodoText, + completed: false + }; + + $scope.todos.push(todo); + + $http.post('todos', todo); + }; + +}