Search
 
SCRIPT & CODE EXAMPLE
 

PHP

signup API in laravel

/**
 * API Register
 *
 * @param Request $request
 * @return IlluminateHttpJsonResponse
 */
public function register(Request $request)
{
    $rules = [
        'name' => 'unique:users|required',
        'email'    => 'unique:users|required',
        'password' => 'required',
    ];

    $input     = $request->only('name', 'email','password');
    $validator = Validator::make($input, $rules);

    if ($validator->fails()) {
        return response()->json(['success' => false, 'error' => $validator->messages()]);
    }
    $name = $request->name;
    $email    = $request->email;
    $password = $request->password;
    $user     = User::create(['name' => $name, 'email' => $email, 'password' => Hash::make($password)]);

}
Comment

PREVIOUS NEXT
Code Example
Php :: Program for factorial of a number in php 
Php :: Laravel - Send mail using mail class 
Php :: bind to class blade laravel 
Php :: session value not removed php 
Php :: laravel db raw count where 
Php :: php webserver 
Php :: object oriented programming php 
Php :: sort by number of views descending laravel 
Php :: laravel pagination with search filter 
Php :: change verify email template laravel 
Php :: how to go one folder back in __dir__ in php 
Php :: woocommerce view order details frontend with shortcode 
Php :: types of method in api 
Php :: flatten in array php 
Php :: laravel create table if not exists 
Php :: change or set post type wordpress 
Php :: laravel model where in 
Php :: laravel store blob image into database 
Php :: Invalid credentials. symfony 
Php :: laravel phpunit not run test 
Php :: php return multiple values 
Php :: strtotime php 
Php :: php rce command 
Php :: loginByUserID in conrete 
Php :: sqlstate[22023]: invalid parameter value: 
Php :: stripe php sdk constants 
Php :: laravel date format valdiate 
Php :: user order by role spatie laravel 
Php :: php pdo get id selected by href 
Php :: PHP - AJAX and MySQL 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =