public function bahagian($id) { if (Request::ajax()) { $bahagian = Bahagian::find($id); $bahagian->delete(); return $bahagian->nama; } }
$penempatan = Penempatan::orderBy('id', 'ASC')->get(); foreach ($penempatan as $tempat) { echo "<option value='" . $tempat->id . "'>" . $tempat->nama . "</option>"; } ?> </select> </div> </div> <div class="form-group"> <label class="control-label" for="selectError">Bahagian</label> <div class="controls"> <select id="bahagian" name="bahagian" data-rel="chosen" class="form-control"> <option selected value="0">Bahagian</option> <?php $bahagian = Bahagian::orderBy('id', 'ASC')->get(); foreach ($bahagian as $tempat) { echo "<option value='" . $tempat->id . "'>" . $tempat->nama . "</option>"; } ?> </select> </div> </div> <div class="control-group"> <label class="control-label" for="selectError">Cawangan</label> <div class="controls"> <div id="results"></div> </div> </div> <br /> <div class="form-group">
@extends('layouts.admin') @section('content') <meta name="_token" content="{{ csrf_token() }}"/> <div class="box-content"> <form method="post" action="#" id="frm"> <div class="form-group"> <label class="control-label" for="bahagian">Nama Cawangan</label> <select name="bahagian" id="bahagian" data-rel="chosen" class="form-control"> <option>Bahagian</option> <?php $bahagian = Bahagian::all(); ?> @foreach($bahagian as $bhgn) <option value="{{ $bhgn->id }}">{{ $bhgn->nama }}</option> @endforeach </select> </div> <div class="form-group"> <label class="control-label" for="cawangan">Nama Cawangan</label> <input type="text" class="form-control" name="cawangan" id="cawangan" placeholder="Nama Cawangan" size="25" maxlength="255" autofocus> </div> <button type="submit" class="btn btn-default">Daftar Cawangan</button> {{ Form::token() }} </form> </div>
public function daftarBahagianPost() { if (Request::ajax()) { $data = Input::all(); $bahagian = new Bahagian(); $bahagian->nama = strtoupper($data['input']); if ($bahagian->save()) { return 1; } else { return 0; } } }