Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {!! Form::open(array('route' => ['createoffice', $id], 'class' => 'form')) !!}
- <div class="container">
- <div class="form-group">
- {!! Form::label('Office Name') !!}
- {!! Form::text('officename', null, array('required',
- 'class'=>'form-control',
- 'placeholder'=>'Office Name')) !!}
- </div>
- <div class="form-group">
- {!! Form::label('Office Floor') !!}
- <div class="form-group">
- {!! Form::label('Office Floor') !!}
- {!! Form::select('floor', ['Basement', '1st floor', '2nd floor', '3rd floor', '4th floor'], ['class' => 'form-control']) !!}
- </div>
- <div class="form-group">
- {!! Form::submit('Create Office',
- array('class'=>'btn btn-primary')) !!}
- <a href="{{ url('building/' . $id) }}" class="btn btn-info">
- <span class="glyphicon glyphicon-arrow-left"></span> Back
- </a>
- </div>
- {!! Form::close() !!}
- class OfficeController extends Controller
- {
- public function index()
- {
- $search = Request::get('search');
- $offices = Office::where('name','LIKE','%'.$search.'%')->get();
- return view('search',compact('offices','search'));
- }
- public function create($id)
- {
- return view('createoffice')->with('id', $id);
- }
- public function store(Request $request, $id)
- {
- $office = new Office();
- $office->name =$request->officename;
- $office->floor = $request->floor;
- $office->building_id = $id;
- $office->save();
- Session::flash('building_flash', 'Created successfully!');
- return redirect()->route('building', $id);
- }
- public function show($id)
- {
- $office = Office::find($id);
- $building = Building::where('id', '=', $office->building_id)->firstOrFail();
- return view('office',['building' => $building, 'office' => $office]);
- }
- public function edit($id, $office_id) {
- $office = Office::find($office_id);
- return view('editoffice', compact('office', 'id'));
- }
- public function update(Request $request, $id, $office_id)
- {
- $office = Office::find($office_id);
- $office->name = $request->officename;
- $office->floor = $request->floor;
- $office->update();
- Session::flash('building_flash', 'Updated successfully!');
- return redirect()->route('building', $id);
- }
- public function destroy($office_id)
- {
- $office = Office::find($office_id);
- $office->delete();
- Session::flash('building_flash_delete', 'Deleted successfully!');
- return redirect()->back();
- }
- }
Add Comment
Please, Sign In to add comment