This controller handles all actions related to Status Labels for the Snipe-IT Asset Management application.
More...
This controller handles all actions related to Status Labels for the Snipe-IT Asset Management application.
- Version
- v1.0
Definition at line 23 of file StatuslabelsController.php.
App\Http\Controllers\StatuslabelsController::getCreate |
( |
| ) |
|
Statuslabel create.
- Returns
- View
Definition at line 43 of file StatuslabelsController.php.
46 $statuslabel =
new Statuslabel;
47 $use_statuslabel_type = $statuslabel->getStatuslabelType();
50 return View::make(
'statuslabels/edit', compact(
'statuslabel_types',
'statuslabel'))->with(
'use_statuslabel_type', $use_statuslabel_type);
App\Http\Controllers\StatuslabelsController::getDatatable |
( |
| ) |
|
Definition at line 210 of file StatuslabelsController.php.
212 $statuslabels = Statuslabel::select(array(
'id',
'name',
'deployable',
'pending',
'archived'))
213 ->whereNull(
'deleted_at');
215 if (Input::has(
'search')) {
216 $statuslabels = $statuslabels->TextSearch(e(Input::get(
'search')));
219 if (Input::has(
'offset')) {
220 $offset = e(Input::get(
'offset'));
225 if (Input::has(
'limit')) {
226 $limit = e(Input::get(
'limit'));
231 $allowed_columns = [
'id',
'name'];
232 $order = Input::get(
'order') ===
'asc' ?
'asc' :
'desc';
233 $sort = in_array(Input::get(
'sort'), $allowed_columns) ? Input::get(
'sort') :
'created_at';
235 $statuslabels->orderBy($sort, $order);
237 $statuslabelsCount = $statuslabels->count();
238 $statuslabels = $statuslabels->skip($offset)->take($limit)->get();
242 foreach ($statuslabels as $statuslabel) {
244 if ($statuslabel->deployable == 1) {
245 $label_type = trans(
'admin/statuslabels/table.deployable');
246 } elseif ($statuslabel->pending == 1) {
247 $label_type = trans(
'admin/statuslabels/table.pending');
248 } elseif ($statuslabel->archived == 1) {
249 $label_type = trans(
'admin/statuslabels/table.archived');
251 $label_type = trans(
'admin/statuslabels/table.undeployable');
254 $actions =
'<a href="'.route(
'update/statuslabel', $statuslabel->id).
'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route(
'delete/statuslabel', $statuslabel->id).
'" data-content="'.trans(
'admin/statuslabels/message.delete.confirm').
'" data-title="'.trans(
'general.delete').
' '.htmlspecialchars($statuslabel->name).
'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
257 'id' => e($statuslabel->id),
258 'type' => e($label_type),
259 'name' => e($statuslabel->name),
260 'actions' => $actions
264 $data = array(
'total' => $statuslabelsCount,
'rows' => $rows);
App\Http\Controllers\StatuslabelsController::getDelete |
( |
|
$statuslabelId | ) |
|
Delete the given Statuslabel.
- Parameters
-
- Returns
- Redirect
Definition at line 184 of file StatuslabelsController.php.
187 if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
189 return Redirect::to(
'admin/settings/statuslabels')->with(
'error', trans(
'admin/statuslabels/message.not_found'));
193 if ($statuslabel->has_assets() > 0) {
196 return Redirect::to(
'admin/settings/statuslabels')->with(
'error', trans(
'admin/statuslabels/message.assoc_users'));
199 $statuslabel->delete();
202 return Redirect::to(
'admin/settings/statuslabels')->with(
'success', trans(
'admin/statuslabels/message.delete.success'));
App\Http\Controllers\StatuslabelsController::getEdit |
( |
|
$statuslabelId = null | ) |
|
Statuslabel update.
- Parameters
-
- Returns
- View
Definition at line 124 of file StatuslabelsController.php.
127 if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
129 return Redirect::to(
'admin/settings/statuslabels')->with(
'error', trans(
'admin/statuslabels/message.does_not_exist'));
132 $use_statuslabel_type = $statuslabel->getStatuslabelType();
134 $statuslabel_types = array(
'' => trans(
'admin/hardware/form.select_statustype')) + array(
'undeployable' => trans(
'admin/hardware/general.undeployable')) + array(
'pending' => trans(
'admin/hardware/general.pending')) + array(
'archived' => trans(
'admin/hardware/general.archived')) + array(
'deployable' => trans(
'admin/hardware/general.deployable'));
136 return View::make(
'statuslabels/edit', compact(
'statuslabel',
'statuslabel_types'))->with(
'use_statuslabel_type', $use_statuslabel_type);
App\Http\Controllers\StatuslabelsController::getIndex |
( |
| ) |
|
Show a list of all the statuslabels.
- Returns
- View
Definition at line 31 of file StatuslabelsController.php.
34 return View::make(
'statuslabels/index', compact(
'statuslabels'));
App\Http\Controllers\StatuslabelsController::postCreate |
( |
| ) |
|
Statuslabel create form processing.
- Returns
- Redirect
Definition at line 59 of file StatuslabelsController.php.
63 $statuslabel =
new Statuslabel();
67 $statuslabel->name = e(Input::get(
'name'));
68 $statuslabel->user_id = Auth::user()->id;
69 $statuslabel->notes = e(Input::get(
'notes'));
70 $statuslabel->deployable = $statustype[
'deployable'];
71 $statuslabel->pending = $statustype[
'pending'];
72 $statuslabel->archived = $statustype[
'archived'];
76 if ($statuslabel->save()) {
78 return Redirect::to(
"admin/settings/statuslabels")->with(
'success', trans(
'admin/statuslabels/message.create.success'));
81 return Redirect::back()->withInput()->withErrors($statuslabel->getErrors());
static getStatuslabelTypesForDB($type)
App\Http\Controllers\StatuslabelsController::postEdit |
( |
|
$statuslabelId = null | ) |
|
Statuslabel update form processing page.
- Parameters
-
- Returns
- Redirect
Definition at line 146 of file StatuslabelsController.php.
149 if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
151 return Redirect::to(
'admin/settings/statuslabels')->with(
'error', trans(
'admin/statuslabels/message.does_not_exist'));
157 $statuslabel->name = e(Input::get(
'name'));
158 $statuslabel->notes = e(Input::get(
'notes'));
159 $statuslabel->deployable = $statustype[
'deployable'];
160 $statuslabel->pending = $statustype[
'pending'];
161 $statuslabel->archived = $statustype[
'archived'];
165 if ($statuslabel->save()) {
167 return Redirect::to(
"admin/settings/statuslabels/")->with(
'success', trans(
'admin/statuslabels/message.update.success'));
169 return Redirect::back()->withInput()->withErrors($statuslabel->getErrors());
174 return Redirect::to(
"admin/settings/statuslabels/$statuslabelId/edit")->with(
'error', trans(
'admin/statuslabels/message.update.error'));
static getStatuslabelTypesForDB($type)
App\Http\Controllers\StatuslabelsController::store |
( |
| ) |
|
Definition at line 85 of file StatuslabelsController.php.
89 $statuslabel =
new Statuslabel();
93 if ($statuslabel->validate($new)) {
96 $statuslabel->name = e(Input::get(
'name'));
97 $statuslabel->user_id = Auth::user()->id;
98 $statuslabel->notes =
'';
99 $statuslabel->deployable = $statustype[
'deployable'];
100 $statuslabel->pending = $statustype[
'pending'];
101 $statuslabel->archived = $statustype[
'archived'];
104 if ($statuslabel->save()) {
106 return JsonResponse::create($statuslabel);
108 return JsonResponse::create([
"error" =>
"Couldn't save Statuslabel"], 500);
112 $errors = $statuslabel->getErrors();
113 return JsonResponse::create([
"error" =>
"Failed validation: ".print_r($errors->all(
'<li>:message</li>'),
true)], 500);
static getStatuslabelTypesForDB($type)
The documentation for this class was generated from the following file: