Skip to content

Commit

Permalink
merge master into Rowaina
Browse files Browse the repository at this point in the history
  • Loading branch information
Rowaina committed Apr 26, 2018
2 parents 61ae5f7 + a1c86ae commit f43f530
Show file tree
Hide file tree
Showing 160 changed files with 47,950 additions and 53 deletions.
10 changes: 10 additions & 0 deletions app/CreateRoomsTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class CreateRoomsTable extends Model
{
//
}
59 changes: 56 additions & 3 deletions app/Http/Controllers/FloorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

use App\Http\Requests\FloorsStoreRequest;

use App\Http\Requests\FloorUpdateRequest;

use Yajra\Datatables\Datatables;

class FloorController extends Controller
{
//
Expand All @@ -20,11 +24,25 @@ public function index()
{
//retreive all floors
$floors= Floor::all();
return view('floors.index',[
'floors' => $floors
]);
// return view('floors.index',[
// 'floors' => $floors
// ]);

return view('floors.index');
}

public function getdata()
{

return Datatables::of(Floor::query())
->addColumn('action', function($query){
$ret = "<a href='floors/" . $query->id . "/edit' class='btn btn-xs btn-primary'><i class='glyphicon glyphicon-edit'></i> Edit</a>";
$ret .= "<button type='button' target='".$query->id."' class='delete btn-xs btn btn-danger' > DELETE </button>";
// $ret .= "<script>$('.delete').on('click',function(){console.log('here'); });</script>";
return $ret;
})->rawcolumns(['action']) ->make(true);

}
public function create()
{
return view('floors.create');
Expand All @@ -49,4 +67,39 @@ public function store(FloorsStoreRequest $request)

return redirect(route('floors.index'));
}

public function edit(request $request)
{

$floor = Floor::whereId($request->id)->first();



return view('floors.edit',[
'floor' => $floor,
]);
}

public function update(FloorUpdateRequest $request)
{


Floor::where('id', $request->id)->update(array(
'name' => $request->name,
));

return redirect(route('floors.index'));
}

public function delete($id)
{

Floor::find($id)->delete();
return json_encode([
"status"=> 1
]);
}



}
100 changes: 100 additions & 0 deletions app/Http/Controllers/RoomController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Room;

use App\Floor;

use Illuminate\Support\Facades\Auth;

use App\Http\Requests\RoomsStoreRequest;

use App\Http\Requests\RoomUpdateRequest;

use Yajra\Datatables\Datatables;


class RoomController extends Controller
{
//
public function index()
{
//retreive all floors
$rooms= Room::all();
return view('rooms.index',[
'rooms' => $rooms
]);
}

public function getdata()
{

return Datatables::of(Room::query())
->addColumn('action', function($query){
$ret = "<a href='rooms/" . $query->id . "/edit' class='btn btn-xs btn-primary'><i class='glyphicon glyphicon-edit'></i> Edit</a>";
$ret .= "<button type='button' target='".$query->id."' class='delete btn-xs btn btn-danger' > DELETE </button>";
// $ret .= "<script>$('.delete').on('click',function(){console.log('here'); });</script>";
return $ret;
})->rawcolumns(['action']) ->make(true);

}

public function create()
{
$floors= Floor::all();
return view('rooms.create',[
'floors' => $floors
]

);
}

public function store(RoomsStoreRequest $request)
{

Room::create([
'number' =>$request->number,
'capacity' => $request->capacity,
'price' => $request->price,
'floor_id' => $request->floor,
'created_by' => Auth::id(),
]);
return redirect(route('rooms.index'));
}

public function edit(request $request)
{
$floors= Floor::all();
$room = Room::whereId($request->id)->first();

return view('rooms.edit',[
'room' => $room,
'floors' => $floors,
]);
}

public function update(RoomUpdateRequest $request)
{


Room::where('id', $request->id)->update(array(
//'number' =>$request->number,
'capacity' => $request->capacity,
'price' => $request->price,
'floor_id' => $request->floor,
));

return redirect(route('rooms.index'));
}

public function delete($id)
{

Room::find($id)->delete();
return redirect(route('rooms.index'));
}

}
34 changes: 34 additions & 0 deletions app/Http/Requests/FloorUpdateRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

use App\Floor;

class FloorUpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
'name' => 'required|unique:floors,id|min:3',

];
}
}
2 changes: 0 additions & 2 deletions app/Http/Requests/FloorsStoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public function rules()
return [
//
'name' => 'required|min:3|unique:floors',
//'nbumber' => 'required',
//'created_by' => 'required',
];
}
}
35 changes: 35 additions & 0 deletions app/Http/Requests/RoomUpdateRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

use App\Floor;

class RoomUpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
'capacity'=> 'required|integer',
'price'=> 'required|integer',
'floor' => 'required|exists:floors,id'
];
}
}
34 changes: 34 additions & 0 deletions app/Http/Requests/RoomsStoreRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RoomsStoreRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
'number'=> 'required|min:4|unique:rooms',
'capacity'=> 'required|integer',
'price'=> 'required|integer',
'floor' => 'required|exists:floors,id'
];
}
}
21 changes: 19 additions & 2 deletions app/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,27 @@

use Illuminate\Database\Eloquent\Model;

use Cviebrock\EloquentSluggable\Sluggable;

use App\Floor;


class Room extends Model
{
public function user()
protected $fillable = [
'name',
'capacity',
'price',
'floor_id',
'number',
'created_by',

];

public function floor()
{
return $this->belongsToMany(User::class, 'reservations');
//User::class == 'App\User'
return $this->belongsTo(Floor::class);
}

}
53 changes: 53 additions & 0 deletions bower_components/datatables.net-dt/.bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "datatables.net-dt",
"description": "DataTables for jQuery ",
"main": [
"css/jquery.dataTables.css",
"images/sort_asc.png",
"images/sort_asc_disabled.png",
"images/sort_both.png",
"images/sort_desc.png",
"images/sort_desc_disabled.png"
],
"keywords": [
"filter",
"sort",
"DataTables",
"jQuery",
"table",
"DataTables"
],
"dependencies": {
"jquery": ">=1.7",
"datatables.net": ">=1.10.9"
},
"moduleType": [
"globals",
"amd",
"node"
],
"ignore": [
"composer.json",
"datatables.json",
"package.json"
],
"authors": [
{
"name": "SpryMedia Ltd",
"homepage": "https://datatables.net"
}
],
"homepage": "https://datatables.net",
"license": "MIT",
"version": "3.2.2",
"_release": "3.2.2",
"_resolution": {
"type": "version",
"tag": "3.2.2",
"commit": "6daa67243fec9e07cd85dffdce9380bc7c6e323b"
},
"_source": "https://github.com/DataTables/Dist-DataTables-DataTables.git",
"_target": "^3.2.2",
"_originalSource": "datatables.net-dt",
"_direct": true
}
Loading

0 comments on commit f43f530

Please sign in to comment.