Commit c5d1f3ff by jhon

Inventori-> Daftar Request

parent 5a06f618
......@@ -8,6 +8,11 @@ use App\Http\Requests;
use App\Barang;
use App\RequestBarang;
use App\DataRequest;
class InventoriController extends Controller
{
public function ListBarang()
......@@ -84,8 +89,82 @@ class InventoriController extends Controller
//----------------------------List Request----------------------//
public function ListRequest()
{
return view('adminlte::inventori.ListRequest.index');
$request_barangs = RequestBarang::all();
return view('adminlte::inventori.ListRequest.index', compact('request_barangs'));
}
public function editRequest($id)
{
$request_barangs = RequestBarang::where('id', $id)->first();
return view('adminlte::inventori.ListRequest.edit')->with('request_barangs', $request_barangs);
}
//----------------------------Data Request----------------------//
public function DataRequest()
{
$data_requests = DataRequest::all();
return view('adminlte::inventori.DataRequest.index', compact('data_requests'));
}
public function createDataRequest()
{
return view('adminlte::inventori.DataRequest.createDataRequest');
}
public function storeDataRequest(Request $request)
{
$this->validate($request, [
'nama_barang' => 'required',
'kategori' => 'required',
'harga' => 'required',
]);
$data_requests = new DataRequest();
$data_requests->nama_barang = $request['nama_barang'];
$data_requests->kategori = $request['kategori'];
$data_requests->harga = $request['harga'];
$data_requests->save();
return redirect('DataRequest');
}
public function editDataRequest($id)
{
$data_requests = DataRequest::where('id', $id)->first();
return view('adminlte::inventori.DataRequest.editDataRequest')->with('data_requests', $data_requests);
}
public function updateDataRequest(Request $request, $id)
{
$this->validate($request, [
'nama_barang' => 'required',
'kategori' => 'required',
'harga' => 'required',
]);
$data_requests = DataRequest::findOrFail($id);
$data_requests->nama_barang = $request->nama_barang;
$data_requests->kategori = $request->kategori;
$data_requests->harga = $request->harga;
$data_requests->save();
return redirect('DataRequest');
}
public function destroyDataRequest($id)
{
$data_requests = DataRequest::find($id);
$data_requests->delete();
return redirect('DataRequest');
}
}
\ No newline at end of file
@extends('adminlte::layouts.app')
@section('htmlheader_title')
Create
@endsection
@section('contentheader_title')
Page Create List Barang
@endsection
@section('main-content')
<div class="container">
<div class="col-md-8 col-md-offset-2">
<div class="panel-body">
<form class="form-horizontal" action="{{ url('storeDataRequest') }}" method="POST">
{!! csrf_field() !!}
<div class="form-group{{ $errors->has('nama_barang') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Nama Barang</label>
<div class="col-md-6">
<input type="text" class="form-control" name="nama_barang" value="{{ old('nama_barang') }}" >
@if ($errors->has('nama_barang'))
<span class="help-block">
<strong>{{ $errors->first('nama_barang') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('kategori') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Kategori</label>
<div class="col-md-6">
<select name="kategori" class="form-control">
<option value="makanan">Makanan</option>
<option value="minuman">Minuman</option>
<option value="alat tulis">Alat Tulis</option>
<option value="alat mandi">Alat Mandi</option>
</select>
@if ($errors->has('kategori'))
<span class="help-block">
<strong>{{ $errors->first('kategori') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('harga') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Harga</label>
<div class="col-md-6">
<input type="text" class="form-control" name="harga" value="{{ old('harga') }}" >
@if ($errors->has('harga'))
<span class="help-block">
<strong>{{ $errors->first('harga') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button type="submit" class="btn btn-primary">
Tambah
</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
\ No newline at end of file
@extends('adminlte::layouts.app')
@section('htmlheader_title')
Edit
@endsection
@section('contentheader_title')
Page Edit Request
@endsection
@section('main-content')
<div class="container">
<div class="col-md-8 col-md-offset-2">
<div class="panel-body">
<form class="form-horizontal" action="{{ url('updateDataRequest', $data_requests->id) }}" method="POST">
{!! csrf_field() !!}
<div class="form-group{{ $errors->has('nama_barang') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Nama Barang</label>
<div class="col-md-6">
<input type="text" class="form-control" name="nama_barang" value="{{ $data_requests->nama_barang}}" >
@if ($errors->has('nama_barang'))
<span class="help-block">
<strong>{{ $errors->first('nama_barang') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('kategori') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label" value="{{ $data_requests->kategori }}">Kategori</label>
<div class="col-md-6">
<select name="kategori" class="form-control">
<option value="makanan">Makanan</option>
<option value="minuman">Minuman</option>
<option value="alat tulis">Alat Tulis</option>
<option value="alat mandi">Alat Mandi</option>
</select>
@if ($errors->has('kategori'))
<span class="help-block">
<strong>{{ $errors->first('kategori') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('harga') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">harga</label>
<div class="col-md-6">
<input type="text" class="form-control" name="harga" value="{{ $data_requests->harga }}" >
@if ($errors->has('harga'))
<span class="help-block">
<strong>{{ $errors->first('harga') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Simpan
</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
\ No newline at end of file
@extends('adminlte::layouts.app')
@section('htmlheader_title')
{{ trans('adminlte_lang::message.home') }}
@endsection
@section('contentheader_title')
<center>Data Request</center>
@endsection
@section('main-content')
<table class="table table-striped">
<thead>
<tr>
<th>Nama Barang</th>
<th>Kategori</th>
<th>Harga</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach($data_requests as $dataRequest)
<tr>
<td>{{$dataRequest->nama_barang}}</td>
<td>{{$dataRequest->kategori}}</td>
<td>{{$dataRequest->harga}}</td>
<td>
<a href="{{ url('/editDataRequest', $dataRequest->id) }}" type="submit" button type="button" class="btn btn-warning">Edit</a>
<a href="{{ url('/deleteDataRequest', $dataRequest->id) }}" class="btn btn-warning">Delete</a>
</td>
</tr>
@endforeach
</tbody>
</table>
<a href="{{ url('/createDataRequest') }}" button type="button" class="btn btn-info">Create</a></button>
@endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment