-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
160 changed files
with
47,950 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
|
||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.