Please any One help me out to solve the problem. I really stuck into this logic I don't even understand how to implement such kind of Logic.
This is my following code.
Role Table
id role_name
1 Admin
1 Driver
3 Customer
4 Employee
This is my Registration function
public function store(Request $request)
{
//
$validator = Validator::make($request->all(), [
'name' => 'required',
'phone' => 'required',
'role_id'=>'required',
'email' => 'required|email',
'password' => 'required',
'c_password' => 'required|same:password'
]);
if ($validator->fails()) {
return response()->json(['error'=>$validator->errors()], 401);
}
$input = $request->all();
$input['password'] = bcrypt($input['password']);
$image = $request->file('photo');
$new_name = '/images/'.'_'.date('d-m-Y-H-i-s') . '.' . $image->getClientOriginalName();
// $new_name = '/images/'.$image.'_'.date('d-m-Y-H-i-s');
$image->move(public_path('images'), $new_name);
$input['photo']=$new_name;
$input['created_by']=Auth::user()->id;
$input['updated_by']=Auth::user()->id;
$user = User::create($input);
$success['token'] = $user->createToken('MyApp')-> accessToken;
$success['name'] = $user->name;
return response()->json(['success'=>$success], $this-> successStatus);
}
Can anyone please help me out to solve this problem? I don't have any idea how will i do this
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2WBXmWz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire