mardi 17 avril 2018

How to slove this error in laravel "Name and email address are required if not a client"

I'm getting an error as "Name and email address are required if not a client" while running the below mentioned code.

Find below the Controller Code:

class UserController extends Controller
{

public function insertform(){
    return view('test');
    }

    public function create(){
        $user=Whmcs::AddClient([
            'firstname' => Input::get('firstname'),
            'lastname' => Input::get('lastname'),
            'email' => Input::get('email'),
            'address1' => Input::get('address1'),
            'city' => Input::get('city'),
            'state' => Input::get('state'),
            'postcode' => Input::get('postcode'),
            'country' => Input::get('country'),
            'phonenumber' => Input::get('phonenumber'),
            'password2' => Input::get('password2'),

        ]);
        return $user;
    }
 }

Find below the route code:

Route::get('insert', 'UserController@insertform');
Route::post('create', 'UserController@create')->name('user.create');

The blade file is given below

<div id="content" class="app-content" role="main">
<div class="app-content-body ">


<div class="bg-light lter b-b wrapper-md">
<h1 class="m-n font-thin h3">Sign up</h1>
</div>
<div class="wrapper-md" ng-controller="FormDemoCtrl">
<div class="row">

<div class="col-sm-12">
  <div class="panel panel-default">
    <div class="panel-heading font-bold">create an account</div>
    <div class="panel-body">
      <form class="bs-example form-horizontal" action=" 
  " method="post">
      <input type = "hidden" name = "_token" value = "<?php echo 
   csrf_token(); ?>">
        <div class="form-group">
          <label class="col-lg-2 control-label">firstname</label>
          <div class="col-lg-6">
            <input type="text" class="form-control" name="firstname" 
            placeholder="Name">

          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-2 control-label">lastname</label>
          <div class="col-lg-6">
            <input type="text" class="form-control" name="lastname" 
             placeholder="Name">

          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-2 control-label">Email</label>
          <div class="col-lg-6">
            <input type="email" class="form-control" name="email" 
            placeholder="Email">
          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-2 control-label">address1</label>
          <div class="col-lg-6">
            <input type="text" class="form-control" name="address1" 
           placeholder="Subject">
          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-2 control-label">city</label>
          <div class="col-lg-6">
            <select class="form-control" name="city">
            <option value="-- Select --">-- Select --</option>
                <option value="Coimbatore">Coimbatore</option>
                <option value="Chennai">Chennai</option>
            </select>

          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-2 control-label">state</label>
          <div class="col-lg-6">
            <select class="form-control" name="state">
            <option value="-- Select --">-- Select --</option>
            <option value="Tamilnadu">Tamilnadu</option>
            <option value="Andhra">Andhra</option>
            <option value="Karnataka">Karnataka</option></select>
          </div>
        </div>

         <div class="form-group">
          <label class="col-lg-2 control-label">country</label>
          <div class="col-lg-6">
            <select class="form-control" name="country">
            <option value="-- Select --">-- Select --</option>
            <option value="India">India</option>
            <option value="China">China</option>
            <option value="Australia">Australia</option></select>
          </div>
        </div>

        <div class="form-group">
          <label class="col-lg-2 control-label">postcode</label>
          <div class="col-lg-6">
            <input type="text" class="form-control" name="postcode" 
 placeholder="postcode">
          </div>
        </div>

  <div class="form-group">
          <label class="col-lg-2 control-label">phonenumber</label>
          <div class="col-lg-6">
            <input type="text" class="form-control" name="phonenumber" 
            placeholder="phonenumber">
          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-2 control-label">password</label>
          <div class="col-lg-6">
            <input type="password" class="form-control" name="password2" 
            placeholder="password">
          </div>
        </div>
        <div class="form-group">
          <div class="col-lg-offset-2 col-lg-10">
            <button type="submit" class="btn btn-sm btn- 
            success">Login</button>
          </div>
        </div>

      </form>
    </div>
  </div>
 </div>
</div>


</div>

When I run the above code I'm getting an error as below:

{"result":"error","message":"Name and email address are required if not a client"}

suggest me a solution to solve this and post the data in laravel.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire