JE WOONG PARK has worked as a System Engineer for both Kakao Corp and Daum Communications, beginning in 2003.
<?php
namespace App\Http\Controllers;
use App\Models\User;
use App\Models\UserProfile;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$users = User::with('profile')->get();
return view('users.index', compact('users'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('users.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$request->validate([
'name' => 'required',
'email' => 'required|unique:users',
'password' => 'required|min:6',
'phone' => 'required',
'address' => 'required',
'gender' => 'required',
]);
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
$profile = UserProfile::create([
'user_id' => $user->id,
'phone' => $request->phone,
'address' => $request->address,
'gender' => $request->gender,
]);
return redirect()->route('users.index')->with('success', 'User created successfully');
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
Sign up to view 0 direct reports
Get started