404 error while trying to submit form in laravel












0















Am trying to submit a form for calls to my database using laravel eloquent but each time I try, it always shoots up a 404 error.



Here is my web.php



Route::get('/calls/newCall', 'CallsController@newCall');
Route::get('/calls/addNewCall', 'CallsController@create');
Route::resource('new_calls', 'CallsController');


This is my CallsController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use Appnew_calls;

class CallsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return IlluminateHttpResponse
*/
public function viewCall($id){ // the id in the url

$new_calls = new_calls::find($id);

return view('calls.viewCall')->with('new_calls', $new_calls);
}

/**
* Show the form for creating a new resource.
*
* @return IlluminateHttpResponse
*/
public function create()
{
return view('calls.addNewCall');
}

/**
* Store a newly created resource in storage.
*
* @param IlluminateHttpRequest $request
* @return IlluminateHttpResponse
*/
public function store(Request $request)
{
// validate data
$this->validate($request, array(
'terminal_id'=> 'required',
'terminal_name'=> 'required',
));

// store in the database
$call = new new_calls;
$call->terminal_id = $request->terminal_id;
$call->terminal_name = $request->terminal_name;

$call->save();

//redirect
return redirect()->route('new_calls.show', $call->id);
}

/**
* Display the specified resource.
*
* @param int $id
* @return IlluminateHttpResponse
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return IlluminateHttpResponse
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param IlluminateHttpRequest $request
* @param int $id
* @return IlluminateHttpResponse
*/
public function update(Request $request, $id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return IlluminateHttpResponse
*/
public function destroy($id)
{
//
}
}


This is my form



<form action="CallController@new_calls.store" method="post">
@csrf
<div class="col-md-6">
<div class="input-group" style="width: 100%;">
<label for="terminal_id">{{ __('Terminal ID') }}</label><br>
<input type="text" name="terminal_id" id="terminal_id" class="form-control" placeholder="Enter the Terminal ID" style="padding: 20px;" required>
</div>
</div>
<div class="col-md-6">
<div class="input-group col-md-12" style="width: 100%;">
<label for="terminal_name">{{ __('Terminal name') }}</label><br>
<input type="text" name="terminal_name" id="terminal_name" class="form-control" placeholder="Enter Terminal Name" style="padding: 20px;" required>
</div>
</div>

<button type="submit" class="btn-primary" style="padding: 10px; font-size: 16px; border: 0;">{{ __('Submit') }}</button>
</form>









share|improve this question



























    0















    Am trying to submit a form for calls to my database using laravel eloquent but each time I try, it always shoots up a 404 error.



    Here is my web.php



    Route::get('/calls/newCall', 'CallsController@newCall');
    Route::get('/calls/addNewCall', 'CallsController@create');
    Route::resource('new_calls', 'CallsController');


    This is my CallsController



    <?php

    namespace AppHttpControllers;

    use IlluminateHttpRequest;
    use Appnew_calls;

    class CallsController extends Controller
    {
    /**
    * Display a listing of the resource.
    *
    * @return IlluminateHttpResponse
    */
    public function viewCall($id){ // the id in the url

    $new_calls = new_calls::find($id);

    return view('calls.viewCall')->with('new_calls', $new_calls);
    }

    /**
    * Show the form for creating a new resource.
    *
    * @return IlluminateHttpResponse
    */
    public function create()
    {
    return view('calls.addNewCall');
    }

    /**
    * Store a newly created resource in storage.
    *
    * @param IlluminateHttpRequest $request
    * @return IlluminateHttpResponse
    */
    public function store(Request $request)
    {
    // validate data
    $this->validate($request, array(
    'terminal_id'=> 'required',
    'terminal_name'=> 'required',
    ));

    // store in the database
    $call = new new_calls;
    $call->terminal_id = $request->terminal_id;
    $call->terminal_name = $request->terminal_name;

    $call->save();

    //redirect
    return redirect()->route('new_calls.show', $call->id);
    }

    /**
    * Display the specified resource.
    *
    * @param int $id
    * @return IlluminateHttpResponse
    */
    public function show($id)
    {
    //
    }

    /**
    * Show the form for editing the specified resource.
    *
    * @param int $id
    * @return IlluminateHttpResponse
    */
    public function edit($id)
    {
    //
    }

    /**
    * Update the specified resource in storage.
    *
    * @param IlluminateHttpRequest $request
    * @param int $id
    * @return IlluminateHttpResponse
    */
    public function update(Request $request, $id)
    {
    //
    }

    /**
    * Remove the specified resource from storage.
    *
    * @param int $id
    * @return IlluminateHttpResponse
    */
    public function destroy($id)
    {
    //
    }
    }


    This is my form



    <form action="CallController@new_calls.store" method="post">
    @csrf
    <div class="col-md-6">
    <div class="input-group" style="width: 100%;">
    <label for="terminal_id">{{ __('Terminal ID') }}</label><br>
    <input type="text" name="terminal_id" id="terminal_id" class="form-control" placeholder="Enter the Terminal ID" style="padding: 20px;" required>
    </div>
    </div>
    <div class="col-md-6">
    <div class="input-group col-md-12" style="width: 100%;">
    <label for="terminal_name">{{ __('Terminal name') }}</label><br>
    <input type="text" name="terminal_name" id="terminal_name" class="form-control" placeholder="Enter Terminal Name" style="padding: 20px;" required>
    </div>
    </div>

    <button type="submit" class="btn-primary" style="padding: 10px; font-size: 16px; border: 0;">{{ __('Submit') }}</button>
    </form>









    share|improve this question

























      0












      0








      0


      1






      Am trying to submit a form for calls to my database using laravel eloquent but each time I try, it always shoots up a 404 error.



      Here is my web.php



      Route::get('/calls/newCall', 'CallsController@newCall');
      Route::get('/calls/addNewCall', 'CallsController@create');
      Route::resource('new_calls', 'CallsController');


      This is my CallsController



      <?php

      namespace AppHttpControllers;

      use IlluminateHttpRequest;
      use Appnew_calls;

      class CallsController extends Controller
      {
      /**
      * Display a listing of the resource.
      *
      * @return IlluminateHttpResponse
      */
      public function viewCall($id){ // the id in the url

      $new_calls = new_calls::find($id);

      return view('calls.viewCall')->with('new_calls', $new_calls);
      }

      /**
      * Show the form for creating a new resource.
      *
      * @return IlluminateHttpResponse
      */
      public function create()
      {
      return view('calls.addNewCall');
      }

      /**
      * Store a newly created resource in storage.
      *
      * @param IlluminateHttpRequest $request
      * @return IlluminateHttpResponse
      */
      public function store(Request $request)
      {
      // validate data
      $this->validate($request, array(
      'terminal_id'=> 'required',
      'terminal_name'=> 'required',
      ));

      // store in the database
      $call = new new_calls;
      $call->terminal_id = $request->terminal_id;
      $call->terminal_name = $request->terminal_name;

      $call->save();

      //redirect
      return redirect()->route('new_calls.show', $call->id);
      }

      /**
      * Display the specified resource.
      *
      * @param int $id
      * @return IlluminateHttpResponse
      */
      public function show($id)
      {
      //
      }

      /**
      * Show the form for editing the specified resource.
      *
      * @param int $id
      * @return IlluminateHttpResponse
      */
      public function edit($id)
      {
      //
      }

      /**
      * Update the specified resource in storage.
      *
      * @param IlluminateHttpRequest $request
      * @param int $id
      * @return IlluminateHttpResponse
      */
      public function update(Request $request, $id)
      {
      //
      }

      /**
      * Remove the specified resource from storage.
      *
      * @param int $id
      * @return IlluminateHttpResponse
      */
      public function destroy($id)
      {
      //
      }
      }


      This is my form



      <form action="CallController@new_calls.store" method="post">
      @csrf
      <div class="col-md-6">
      <div class="input-group" style="width: 100%;">
      <label for="terminal_id">{{ __('Terminal ID') }}</label><br>
      <input type="text" name="terminal_id" id="terminal_id" class="form-control" placeholder="Enter the Terminal ID" style="padding: 20px;" required>
      </div>
      </div>
      <div class="col-md-6">
      <div class="input-group col-md-12" style="width: 100%;">
      <label for="terminal_name">{{ __('Terminal name') }}</label><br>
      <input type="text" name="terminal_name" id="terminal_name" class="form-control" placeholder="Enter Terminal Name" style="padding: 20px;" required>
      </div>
      </div>

      <button type="submit" class="btn-primary" style="padding: 10px; font-size: 16px; border: 0;">{{ __('Submit') }}</button>
      </form>









      share|improve this question














      Am trying to submit a form for calls to my database using laravel eloquent but each time I try, it always shoots up a 404 error.



      Here is my web.php



      Route::get('/calls/newCall', 'CallsController@newCall');
      Route::get('/calls/addNewCall', 'CallsController@create');
      Route::resource('new_calls', 'CallsController');


      This is my CallsController



      <?php

      namespace AppHttpControllers;

      use IlluminateHttpRequest;
      use Appnew_calls;

      class CallsController extends Controller
      {
      /**
      * Display a listing of the resource.
      *
      * @return IlluminateHttpResponse
      */
      public function viewCall($id){ // the id in the url

      $new_calls = new_calls::find($id);

      return view('calls.viewCall')->with('new_calls', $new_calls);
      }

      /**
      * Show the form for creating a new resource.
      *
      * @return IlluminateHttpResponse
      */
      public function create()
      {
      return view('calls.addNewCall');
      }

      /**
      * Store a newly created resource in storage.
      *
      * @param IlluminateHttpRequest $request
      * @return IlluminateHttpResponse
      */
      public function store(Request $request)
      {
      // validate data
      $this->validate($request, array(
      'terminal_id'=> 'required',
      'terminal_name'=> 'required',
      ));

      // store in the database
      $call = new new_calls;
      $call->terminal_id = $request->terminal_id;
      $call->terminal_name = $request->terminal_name;

      $call->save();

      //redirect
      return redirect()->route('new_calls.show', $call->id);
      }

      /**
      * Display the specified resource.
      *
      * @param int $id
      * @return IlluminateHttpResponse
      */
      public function show($id)
      {
      //
      }

      /**
      * Show the form for editing the specified resource.
      *
      * @param int $id
      * @return IlluminateHttpResponse
      */
      public function edit($id)
      {
      //
      }

      /**
      * Update the specified resource in storage.
      *
      * @param IlluminateHttpRequest $request
      * @param int $id
      * @return IlluminateHttpResponse
      */
      public function update(Request $request, $id)
      {
      //
      }

      /**
      * Remove the specified resource from storage.
      *
      * @param int $id
      * @return IlluminateHttpResponse
      */
      public function destroy($id)
      {
      //
      }
      }


      This is my form



      <form action="CallController@new_calls.store" method="post">
      @csrf
      <div class="col-md-6">
      <div class="input-group" style="width: 100%;">
      <label for="terminal_id">{{ __('Terminal ID') }}</label><br>
      <input type="text" name="terminal_id" id="terminal_id" class="form-control" placeholder="Enter the Terminal ID" style="padding: 20px;" required>
      </div>
      </div>
      <div class="col-md-6">
      <div class="input-group col-md-12" style="width: 100%;">
      <label for="terminal_name">{{ __('Terminal name') }}</label><br>
      <input type="text" name="terminal_name" id="terminal_name" class="form-control" placeholder="Enter Terminal Name" style="padding: 20px;" required>
      </div>
      </div>

      <button type="submit" class="btn-primary" style="padding: 10px; font-size: 16px; border: 0;">{{ __('Submit') }}</button>
      </form>






      php laravel






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 16:06









      AustinAustin

      2610




      2610
























          2 Answers
          2






          active

          oldest

          votes


















          1














          This is an HTML context where the form action is literally the URL you are trying to submit the form to. You aren't using the blade template syntax or calling any Laravel function in the form action assignment. You also aren't defining the route action correctly.



          You would either use the route name:



          route('new_calls.store');


          Or you would use the action:



          action('CallsController@store');


          You are using a combination of the two.



          Replace your form action correctly:



          <form action="{{ route('new_calls.store') }}" method="post">





          share|improve this answer


























          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:01



















          1














          Try this:



          <form action="{{ action('CallController@store') }}" method="post">


          Source: URLs For Controller Actions






          share|improve this answer
























          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:02











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284989%2f404-error-while-trying-to-submit-form-in-laravel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          This is an HTML context where the form action is literally the URL you are trying to submit the form to. You aren't using the blade template syntax or calling any Laravel function in the form action assignment. You also aren't defining the route action correctly.



          You would either use the route name:



          route('new_calls.store');


          Or you would use the action:



          action('CallsController@store');


          You are using a combination of the two.



          Replace your form action correctly:



          <form action="{{ route('new_calls.store') }}" method="post">





          share|improve this answer


























          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:01
















          1














          This is an HTML context where the form action is literally the URL you are trying to submit the form to. You aren't using the blade template syntax or calling any Laravel function in the form action assignment. You also aren't defining the route action correctly.



          You would either use the route name:



          route('new_calls.store');


          Or you would use the action:



          action('CallsController@store');


          You are using a combination of the two.



          Replace your form action correctly:



          <form action="{{ route('new_calls.store') }}" method="post">





          share|improve this answer


























          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:01














          1












          1








          1







          This is an HTML context where the form action is literally the URL you are trying to submit the form to. You aren't using the blade template syntax or calling any Laravel function in the form action assignment. You also aren't defining the route action correctly.



          You would either use the route name:



          route('new_calls.store');


          Or you would use the action:



          action('CallsController@store');


          You are using a combination of the two.



          Replace your form action correctly:



          <form action="{{ route('new_calls.store') }}" method="post">





          share|improve this answer















          This is an HTML context where the form action is literally the URL you are trying to submit the form to. You aren't using the blade template syntax or calling any Laravel function in the form action assignment. You also aren't defining the route action correctly.



          You would either use the route name:



          route('new_calls.store');


          Or you would use the action:



          action('CallsController@store');


          You are using a combination of the two.



          Replace your form action correctly:



          <form action="{{ route('new_calls.store') }}" method="post">






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 16:18

























          answered Nov 13 '18 at 16:11









          DevonDevon

          22.7k42746




          22.7k42746













          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:01



















          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:01

















          thanks for your response... the problem is now fixed

          – Austin
          Nov 14 '18 at 9:01





          thanks for your response... the problem is now fixed

          – Austin
          Nov 14 '18 at 9:01













          1














          Try this:



          <form action="{{ action('CallController@store') }}" method="post">


          Source: URLs For Controller Actions






          share|improve this answer
























          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:02
















          1














          Try this:



          <form action="{{ action('CallController@store') }}" method="post">


          Source: URLs For Controller Actions






          share|improve this answer
























          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:02














          1












          1








          1







          Try this:



          <form action="{{ action('CallController@store') }}" method="post">


          Source: URLs For Controller Actions






          share|improve this answer













          Try this:



          <form action="{{ action('CallController@store') }}" method="post">


          Source: URLs For Controller Actions







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 16:12









          Sand Of VegaSand Of Vega

          1,233518




          1,233518













          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:02



















          • thanks for your response... the problem is now fixed

            – Austin
            Nov 14 '18 at 9:02

















          thanks for your response... the problem is now fixed

          – Austin
          Nov 14 '18 at 9:02





          thanks for your response... the problem is now fixed

          – Austin
          Nov 14 '18 at 9:02


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284989%2f404-error-while-trying-to-submit-form-in-laravel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Lugert, Oklahoma