Skip to content

Instantly share code, notes, and snippets.

@uiaciel
Created October 13, 2022 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uiaciel/86447f3a8096b9a00524317eca717dc9 to your computer and use it in GitHub Desktop.
Save uiaciel/86447f3a8096b9a00524317eca717dc9 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use App\Models\Stok;
use Illuminate\Http\Request;
class StokController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$stoks = Stok::all();
return view('stoks.index', [
'stoks' => $stoks
]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('stoks.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$stok = new Stok;
$stok->nama = $request->nama;
$stok->kategori = $request->kategori;
$stok->supplier = $request->supplier;
$stok->kode = $request->kode;
$stok->qty = $request->qty;
$stok->save();
return redirect()->route('stok.index')
->with('success','Data created successfully.');
// $table->string('nama');
// $table->string('kategori');
// $table->string('supplier');
// $table->string('kode');
// $table->integer('qty');
}
/**
* Display the specified resource.
*
* @param \App\Models\Stok $stok
* @return \Illuminate\Http\Response
*/
public function show(Stok $stok)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Stok $stok
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$stok = Stok::find($id)->first();
return view('stoks.edit', [
'stok' => $stok,
]);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Stok $stok
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Stok $stok)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Stok $stok
* @return \Illuminate\Http\Response
*/
public function destroy(Stok $stok)
{
//
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment