Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), Barang::$rules, Barang::$pesan);
     if ($validator->fails()) {
         return response()->Json(array('errors' => $validator->errors()->toArray()));
     } else {
         Barang::create($request->all());
         $barang = Barang::where('jumlahBarang', '<', 20)->get()->toArray();
         event(new BarangRegistrationEvent($barang));
     }
 }
Exemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $fill = $request->all();
     $asd = Barang::where('nama', $fill['nama'])->firstOrFail();
     if (is_numeric($fill['kuantitas']) && !$asd) {
         Barang::create($fill);
         //dd($fill);
         return redirect()->action('BarangController@index');
     } else {
         return redirect()->back()->withErrors(['Kuantitas bukan angka atau barang sudah ada']);
     }
 }
Exemplo n.º 3
0
 public function getKodeBarang(Request $request)
 {
     $id = $request->input('idBarang');
     $barang = Barang::where('idBarang', '=', $id)->get();
     return $barang;
 }
Exemplo n.º 4
0
 public function apiBarang(Request $request)
 {
     $kode = $request->input('kode');
     $barang = Barang::where('kodeBarang', '=', $kode)->get();
     return response()->json($barang);
 }