Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Too few arguments to function App\Http\Controllers\Auth\register_sawmill::create(), 0 passed and exactly 1 expected

someone help me to fix this.

What I have tried:

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

class register_sawmill extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    { 
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
        // return view('auth/register');
          return User::create([
            'name' => $data['name'],
            'sname' => $data['sname'],
            'KRAPIN' => $data['KRAPIN'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }
}
Posted
Updated 10-Apr-19 1:27am
Comments
MadMyche 10-Apr-19 6:54am    
Show the code that is calling this, that appears to be where the problem lies
harristars 10-Apr-19 7:02am    
i have fixed

Some 'other' code (you didn't show it) is trying to make a parameterless call to the create method.
If such a code is under your control then change it in order to pass a valid parameter.
On the other hand, if such a code is NOT under your control, then you have to provide (also) a parameterless create method in your class.
 
Share this answer
 
Answered only to remove from unanswered list: solved by OP.
Quote:
harristars 21 mins ago

i have fixed
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900