81 lines
1.6 KiB
PHP
81 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Profile;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ProfileController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show()
|
|
{
|
|
$profile = Profile::where('user_id', Auth::id())->first();
|
|
return response()->json($profile);
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(string $id)
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request)
|
|
{
|
|
$validated = $request->validate([
|
|
'nama' => ['required', 'string', 'max:255'],
|
|
'email' => ['required', 'email'],
|
|
'telepon' => ['nullable', 'string'],
|
|
'alamat' => ['nullable', 'string'],
|
|
'kk' => ['nullable', 'string'],
|
|
'ktp' => ['nullable', 'string']
|
|
]);
|
|
|
|
$profile = Profile::where('user_id', Auth::id())->first();
|
|
$profile->update($validated);
|
|
|
|
return response()->json($profile);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(string $id)
|
|
{
|
|
//
|
|
}
|
|
}
|