title: Laravel : How to create a controller that will the POST Request and save the user in the database?
body: <p>I have a problem with inserting Data into Database.</p>
  
  <p>All i have done till now is :</p>
  
  <p>Create a Model with Controller and Migration.</p>
  
  <p>So, now my files looks this way :</p>
  
  <p>UserController - Controller:</p>
  
  <pre><code>namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  
  class UserController extends Controller
  {
      /**
       * Display a listing of the resource.
       *
       * @return \Illuminate\Http\Response
       */
      public function index()
      {
          return response()-&gt;json([
              'name' =&gt; 'Abigail',
              'state' =&gt; 'CA'
          ]);
      }
  
      /**
       * Show the form for creating a new resource.
       *
       * @return \Illuminate\Http\Response
       */
      public function create()
      {
          $user = new User;
          $user-&gt;first_name = $request-&gt;first_name;
          $user-&gt;last_name = $request-&gt;last_name;
          $user-&gt;role = 'user';
          $user-&gt;slug = $userSlug;
          $user-&gt;save();
      }
  
  
      /**
       * Store a newly created resource in storage.
       *
       * @param  \Illuminate\Http\Request  $request
       * @return \Illuminate\Http\Response
       */
  </code></pre>
  
  <p>web.php - Routing:</p>
  
  <pre><code>&lt;?php
  
  Route::get('/', function () {
      return view('welcome');
  });
  
  Route::resource('users', 'UserController');
  Route::post('users', 'UserController@create');
  </code></pre>