<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\cabe;
use App\ubi;
use App\news;
use App\tomat;
use App\andaliman;
use App\jagung;
use App\kentang;
use App\kacang;
use App\beli;
use App\pesan;
use App\informasi;

use Illuminate\Support\Facades\Input;
use App\Http\Requests;
use App\Http\Requests\informasi\StoreRequest;
use App\Http\Requests\informasi\UpdateRequest;
use Image;

class InformasiController extends Controller
{
    public function index()
    {
        $informasis = informasi::all();
        return view('Admin.HalamanAdmin.news', compact('informasis'));
    }

    public function costinformasi()
    {
        $informasis = informasi::all();
        return view('Costumer.HalamanMonitoring.monitoringinformasi', compact('informasis'));
    }
    public function costcabe()
    {
        $cabes = cabe::all();
        return view('Costumer.MonitoringCabe.monitoringcabe', compact('cabes'));
    }
    public function costubi()
    {
        $ubis = ubi::all();
        return view('Costumer.MonitoringUbi.monitoringubi', compact('ubis'));
    }
    public function costtomat()
    {
        $tomats = tomat::all();
        return view('Costumer.HalamanTomat.index', compact('tomats'));
    }
    public function costandaliman()
    {
        $andalimans = andaliman::all();
        return view('Costumer.MonitoringAndaliman.index', compact('andalimans'));
    }
    public function costjagung()
    {
        $jagungs = jagung::all();
        return view('Costumer.HalamanJagung.index', compact('jagungs'));
    }
    public function costkentang()
    {
        $kentangs = kentang::all();
        return view('Costumer.MonitoringKentang.monitoringkentang', compact('kentangs'));
    }
    public function costkacang()
    {
        $kacangs = kacang::all();
        return view('Costumer.MonitoringKacang.index', compact('kacangs'));
    }



    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {

        $informasis = informasi::all();
        return view('Admin.HalamanAdmin.create_news', compact('informasis'));
        //return view('Costumer.HalamanMonitoring.beli');
    }

    public function siram()
    {
        return view('Admin.HalamanMonitoring.siram');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */

    public function store(Request $request)
    {
        $informasis = new informasi();
        $informasis->judul = $request->judul;
//        $belis->id_menu = $request->id_menu;
        $informasis->berita = $request->berita;
//        $belis->harga = $request->harga;

//        $belis->total_harga = $request->total_harga;
        $informasis->save();
        return redirect()->route('news.index')->with('alert-success', 'Data Berhasil Disimpan.');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $informasis = informasi::findOrFail($id);
        return view('Admin.HalamanAdmin.news', compact('informasis'));
    }



    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $informasis = informasi::findOrFail($id);
        return view('Admin.HalamanAdmin.edit', compact('informasis'));
    }



    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(UpdateRequest $request, $id)
    {

        $informasis = informasi::findOrFail($id);
        $informasis->judul = $request->judul;
        $informasis->berita = $request->berita;

        $informasis->save();
        return redirect()->route('news.index')->with('alert-success', 'Data Berhasil Diubah.');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $informasis = informasi::findOrFail($id);
        $informasis->delete();
        return redirect()->route('news.index')->with('alert-success', 'Data Berhasil Dihapus.');
    }
}
