title: Store data in DataBase using ANGULARJS in Laravel4
body: <p>I am trying to insert data into the DataBase using ANGULARJS in Laravel4. But the data is not going into the DataBase. No error is showing here. Here I have also included foreach loop in php for displaying the data.</p>
  
  <p>Here is view page(*.php)</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
          &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body ng-app="myApp" ng-controller="myCtrl"&gt;
  
  &lt;h2&gt;Calculator&lt;/h2&gt;
  &lt;form action="calculative_page" method="post"&gt;
  a: &lt;input type="number" ng-model="a" name="a"&gt;
  b: &lt;input type="number" ng-model="b" name="b"&gt;
  &lt;button ng-click="addFunc()"&gt;Sum&lt;/button&gt;
  &lt;b&gt;Summation : {{sum}}&lt;/b&gt;
  
  &lt;?php
  if(isset($select))
  {
      foreach ($select as $sel) { ?&gt;
      &lt;input type="text" value="&lt;?php echo $sel-&gt;addition ?&gt;"&gt;&lt;/br&gt;
  &lt;?php }} ?&gt;
  
  &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;
  c: &lt;input type="number" ng-model="c" name="c"&gt;
  d: &lt;input type="number" ng-model="d" name="d"&gt;
  &lt;button ng-click="subFunc()"&gt;Sub&lt;/button&gt;
  &lt;b&gt;Subtraction: {{sub}}&lt;/b&gt;
  
  
  &lt;?php
  if(isset($select))
  {
      foreach ($select as $sel) { ?&gt;
      &lt;input type="text" value="&lt;?php echo $sel-&gt;subtraction ?&gt;"&gt;&lt;/br&gt;
  &lt;?php }} ?&gt;
  
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;script&gt;
  var app = angular.module('myApp', []);
  app.controller('myCtrl', function($scope,$http) {
      $scope.sum = 0;
      $scope.addFunc = function() {
          $scope.sum = $scope.a+$scope.b;
          $scope.a = $_POST['a'];
          $scope.b = $_POST['b'];
          }
      }
  
      $scope.sub = 0;
      $scope.subFunc = function() {
          $scope.sub=$scope.c-$scope.d;
          $scope.c = $_POST['c'];
          $scope.d = $_POST['d'];
      }
  });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is controller</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use App\Http\Requests;
  use Illuminate\Http\Request;
  use DB;
  use Session;
  use Redirect;
  
  class NewController extends Controller
  {
      /**
       * Create a new controller instance.
       *
       * @return void
       */
      public function __construct()
      {
          $this-&gt;middleware('auth');
      }
  public function calculative_function(Request $request)
      {
        echo $a_value = $request-&gt;a;
        echo $b_value = $request-&gt;b;
        echo $c_value = $request-&gt;c;
        echo $d_value = $request-&gt;d;
        if($a_value)
        {
          $calc = DB::table('calculation')-&gt;insert(['a' =&gt; $a_value, 'b' =&gt; $b_value,'addition'=&gt;$a_value+$b_value]);
          return redirect('homework')-&gt;with('status','Done..!');
        }
        else
        {
          $calc = DB::table('calculation')-&gt;insert(['c' =&gt; $c_value, 'd' =&gt; $d_value,'subtraction'=&gt;$c_value-$d_value]);
          return view('homework');
        }
  
      }
  
      public function homework_function(Request $request)
      {
        $select = DB::select('select addition, subtraction from calculation');
        return view('homework',['select' =&gt; $select]);
        //return view('homework');
      }
  </code></pre>
  
  <p>And here is <code>route.php</code></p>
  
  <pre><code>Route::get('/homework', 'NewController@homework_function');
  
  Route::get('/calculative_page', 'NewController@calculative_function');
  </code></pre>