100 lines
2.6 KiB
PHP
100 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use App\Models\Masyarakat;
|
|
use App\Http\Requests\StoreMasyarakatRequest;
|
|
use App\Http\Requests\UpdateMasyarakatRequest;
|
|
use Illuminate\Support\Facades\Redirect;
|
|
use App\Models\User;
|
|
|
|
class MasyarakatController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('client-side.masyarakat.index');
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
$masyarakat = Masyarakat::where('user_id', Auth::user()->id)->first();
|
|
return view('client-side.masyarakat.profile', compact(['masyarakat']));
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\StoreMasyarakatRequest $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(StoreMasyarakatRequest $request)
|
|
{
|
|
$masyarakat = Masyarakat::where('user_id', $request->user_id)->first();
|
|
|
|
$masyarakat->jenis_kelamin = $request->jenis_kelamin;
|
|
$masyarakat->alamat = $request->alamat;
|
|
$masyarakat->tempat_lahir = $request->tempat_lahir;
|
|
$masyarakat->tanggal_lahir = $request->tanggal_lahir;
|
|
$masyarakat->nohp = $request->nohp;
|
|
$masyarakat->save();
|
|
|
|
return Redirect::route('masyarakat.create')->with('message', 'Berhasil memperbarui profil');
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\Models\Masyarakat $Masyarakat
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show(Masyarakat $Masyarakat)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\Models\Masyarakat $Masyarakat
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit(Masyarakat $Masyarakat)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\UpdateMasyarakatRequest $request
|
|
* @param \App\Models\Masyarakat $Masyarakat
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(UpdateMasyarakatRequest $request, Masyarakat $Masyarakat)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Models\Masyarakat $Masyarakat
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Masyarakat $Masyarakat)
|
|
{
|
|
//
|
|
}
|
|
}
|