/** * Run the migrations. * * @return void */ public function up() { Schema::create('mata_uangs', function (Blueprint $table) { $table->string('simbol'); $table->string('nama'); $table->string('negara'); $table->primary('simbol'); }); MataUang::create(['simbol' => 'IDR', 'nama' => 'Rupiah', 'negara' => 'Indonesia']); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $req = Request::only('simbol', 'nama', 'negara'); $v = Validator::make($req, ['simbol' => 'required', 'nama' => 'required', 'negara' => 'required']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } MataUang::create($req); return redirect('currency'); }