
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Input;

use Collective\Html\HtmlServiceProvider;

use App\SuratMasuk;

use Session;

class SuratMasukController extends Controller
{
	
	public function store($data)
	{
		// validate
		// read more on validation at http://laravel.com/docs/validation
		// $rules = array(
			// 'jenis_surat_id'       => 'required',
			// 'created_by'      => 'required',
			// 'created_at' => 'required',
			// 'status' => 'required|numeric'
		// );
		// $validator = Validator::make(Input::all(), $rules);

		// process the login
		// if ($validator->fails()) {
			// return Redirect::to('nerds/create')
				// ->withErrors($validator)
				// ->withInput(Input::except('password'));
		// } else {
			// store
			$suratmasuk = new SuratMasuk;
			$suratmasuk->jenis_surat_id = $data['jenis_surat_id'];
			$suratmasuk->surat_id = $data['surat_id'];
			$suratmasuk->created_by  = $data['created_by'];
			$suratmasuk->created_at = $data['created_at'];
			$suratmasuk->status_id = $data['status_id'];
			$suratmasuk->save();
			
			//Session::flash('message', 'Successfully created surat!');
			return response()->json(array('success' => true, 'last_insert_id' => $suratmasuk->id), 200);
		
	}
}
