app/Http/Controllers/Dashboard/UsersEmpController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $data = $this->validate(
            request(),
            [
                'user_img' => 'image|mimes:jpg,jpeg,png,gif,bmp',
                'employee_id' => 'required',
                'role_id' => 'required',
                'email' => 'required|email|unique:users',
                'password' => 'required|min:6|confirmed',
                'password_confirmation' => 'required',
            ]
        );
        $employee = Employee::find($request->employee_id);
        $request_data['employee_id'] = $employee->id;
        $request_data['name'] = $employee->emp_name;
        $request_data['national_num'] = $employee->national_num;
        $request_data['adress'] = $employee->adress;
        $request_data['phone'] = $employee->phone;
        $request_data['user_img'] = $employee->emp_img;
        $request_data['role_id_fk'] = '3';
        $request_data['email'] = $request->email;
        $request_data['password'] = Hash::make($request->password);
        dd($request_data);
        if (request()->hasFile('user_img')) {
            $file = $request->file('user_img');
            $name =$file->hashName();
            $request->file('user_img')->move(public_path('uploads/images/user_images'),$name);
            $request_data['user_img'] = $name;
        }
        dd($request_data);
        $user = User::create($request_data);
        if ($request->role_id == 1) {
            $user->attachRole('super_admin');
        } else if ($request->role_id == 2) {
            $user->attachRole('admin');
        }
        if ($request->permission) {
            $user->syncPermissions($request->permission);
        }
		session()->flash('success', "تم الاضافة بنجاح");
        return redirect('admin/usersemps');
    }
public function store ( Request $ request ) { $ data = $ this -> validate ( request ( ) , [ 'user_img' => 'image|mimes:jpg,jpeg,png,gif,bmp' , 'employee_id' => 'required' , 'role_id' => 'required' , 'email' => 'required|email|unique:users' , 'password' => 'required|min:6|confirmed' , 'password_confirmation' => 'required' , ] ) ; $ employee = Employee :: find ( $ request -> employee_id ) ; $ request_data [ 'employee_id' ] = $ employee -> id ; $ request_data [ 'name' ] = $ employee -> emp_name ; $ request_data [ 'national_num' ] = $ employee -> national_num ; $ request_data [ 'adress' ] = $ employee -> adress ; $ request_data [ 'phone' ] = $ employee -> phone ; $ request_data [ 'user_img' ] = $ employee -> emp_img ; $ request_data [ 'role_id_fk' ] = '3' ; $ request_data [ 'email' ] = $ request -> email ; $ request_data [ 'password' ] = Hash :: make ( $ request -> password ) ; if ( request ( ) -> hasFile ( 'user_img' ) ) { $ file = $ request -> file ( 'user_img' ) ; $ name = $ file -> hashName ( ) ; $ request -> file ( 'user_img' ) -> move ( public_path ( 'uploads/images/user_images' ) , $ name ) ; $ request_data [ 'user_img' ] = $ name ; } $ user = User :: create ( $ request_data ) ; if ( $ request -> role_id == 1 ) { $ user -> attachRole ( 'super_admin' ) ; } else if ( $ request -> role_id == 2 ) { $ user -> attachRole ( 'admin' ) ; } if ( $ request -> permission ) { $ user -> syncPermissions ( $ request -> permission ) ; } session ( ) -> flash ( 'success' , " تم الاضافة بنجاح"); return redirect ( 'admin/usersemps' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//echo ((in_array('update_pages',$request->permission)?'checked':'')); //dd($request->all()); // //dd($request_data); //dd($request_data);