0

I try to make registeration system for binary look like as picture enter image description here

here is registercontroller

 namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\User;
use App\Models\MemberExtra;
use Carbon\Carbon;
use Illuminate\Support\Facades\Session;
use Illuminate\Auth\Events\Registered;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    public function index()
    {
        return view('users.register');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6',
            'referrer_id' => 'required',
            'position' => 'required',
           
            'name' => 'required',
        ]);
    }

    protected function create(array $data)
    {

        $pin = substr(time(), 4);

        $ref_id = $data['referrer_id'];
        $poss = $data['position'];
        $posid =  getLastChildOfLR($ref_id,$poss);

       
        return User::create([
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'referrer_id' => $data['referrer_id'],
            'position' => $data['position'],
            
            'name' => $data['name'],
           
            'join_date' => Carbon::today(),
            
            'posid' => $posid,
           
        ]);
    }

    public function signup(Request $request)
    {
        $this->validator($request->all())->validate();
        event(new Registered($user = $this->create($request->all())));
        $this->guard()->login($user);
        MemberExtra::create([
           'user_id' => $user['id'],
           'left_paid' => 0,
           'right_paid' => 0,
           'left_free' => 0,
           'right_free' => 0,
           'left_bv' => 0,
           'right_bv' => 0,
        ]);
        updateMemberBelow($user['id'], 'FREE');
        return $this->registered($request, $user) ?: redirect()->route('users.register');
    }


   
}


modes

 protected $fillable = ['referrer_id', 'name', 'password',
    'position','join_date',
    'email','posid'
    ];

   protected $table ='member_extras';
    protected $fillable = [
        'user_id',
        'left_paid',
        'right_paid',
        'left_free',
        'right_free',
        'left_bv',
        'right_bv',
    ];

try to insert data into user and memberarea but nothing happen.

here is blade form

<h3>Add Users</h3>

<div class="row">

    <div class="col-md-12 col-sm-12 col-xs-12">

      
          <!-- Alert message (start) -->
        @if(Session::has('message'))
        <div class="alert {{ Session::get('alert-class') }}">
          <span style="color:green">{{ Session::get('message') }}</span>
        </div>
        @endif
       
             <form action="{{route('user.signup')}}" method="POST" id="subjectForm">

                {{csrf_field()}}
                
                <div class="col-md-6">
                            <label for="fullname">Referrer Name</label>
                            <input class="form-styling" type="text" value="{{old('ref_name')}}" id="ref_name" required placeholder=""/>
                            <div id="ref">

                            </div>
                            @if ($errors->has('referrer_id'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('referrer_id') }}</strong>
                                </span>
                            @endif
                        </div>

                        <div class="col-md-6">

                      <label for="Select Position">Select Position</label>
                      <select class="select_panel" id="position" name="position" required>
                       <option disabled selected>Select Position</option>
                       <option value="L">Left</option>
                       <option value="R">Right</option>
                       </select>
                      
                       <div id="ref_pos">

                       </div>
                       @if ($errors->has('position'))
                        <span class="help-block">
                        <strong>{{ $errors->first('position') }}</strong>
                        </span>
                         @endif
                        </div>

                        <div class="col-md-6">
                            <label for=" First Name">Name</label>
                            <input value="{{old('name')}}" class="form-styling" required type="text" name="name">
                            @if ($errors->has('name'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('name') }}</strong>
                                </span>
                            @endif
                        </div>
                        <div class="col-md-6">
                            <label for="email">Email</label>
                            <input  type="text" class="form-styling" required name="email" value="{{old('email')}}">
                            @if ($errors->has('email'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('email') }}</strong>
                                </span>
                            @endif
                        </div>

                        <div class="col-md-6">
                                <label>
                                    Password
                                </label>
                                <input required type="password"  class="form-styling"  name="password">
                                @if ($errors->has('password'))
                                    <span class="help-block">
                                                            <strong>{{ $errors->first('password') }}</strong>
                                                        </span>
                                @endif
                            </div>

                            <button type="submit" class="btn btn-primary">Register</button>
      
</form>


   <form action="{{route('login')}}" id="subjectForm">
       <button type="submit" class="btn btn-primary">Login</button>
   </form>
    </div>
</div>

here is migration

 */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('referrer_id');
            $table->string('position');
            $table->string('name')->unique();
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->integer('posid');
            $table->string('join_date');
            $table->rememberToken();
            $table->timestamps();
        });
    }


here is database

enter image description here

i inserted admindata manually to call admin username in referrer name when new user signs up. but it does not work. I copied all codes from binary mlm project source code (laravel 5.5 ver). How can correctly sign up new user as show in picture? it show referrer name match and you will join under - someone id. in my attempt, it does not work.

enter image description here

I am learning how build binary mlm website, i fail in registration phase,

enter image description here

Edited

I get the solution for referrer name and selection position but when click register buttom nothing happen post method not work .also not show any error when register . no data insert to database . Please check what wrong in controller codes

  • Hey, you are encouraged to type up as much code/logs as possible, instead of using screenshots. This helps readability – f.khantsis Oct 26 '21 at 06:47

1 Answers1

1

I see several mistakes that could be a problem, in blade:

1)

 <input class="form-styling" type="text" value="{{old('ref_name')}}" id="ref_name" required placeholder=""/>

there is no name="" parameter

  1. in migration you got $table->string('name')->unique(); Unique but in validation not 'name' => 'required', ,
  2. when you make mass assignment like here $this->validator($request->all())->validate(); event(new Registered($user = $this->create($request->all()))); you can read details here mass assignment , to do so you need to config model $fillable = [] or $guarded = [] parameters to do so, but I had such problem when I used fillable only and I could not do mass assignment anyway and than just used $guarded = [] and worked fine, so just try this as well.
  • get problem in referrer_id , need to insert referrer name, example ( admin ) , but not work, it show error , not allow to insert admin.it show require referrer_id .I dont understand how they link referrer_id and referrer name in same input place –  Oct 25 '21 at 14:29
  • this part ,I solved , but still not insert data into database. –  Oct 26 '21 at 13:59