This controller handles all actions related to Manufacturers for the Snipe-IT Asset Management application.
More...
|
| getIndex () |
| Returns a view that invokes the ajax tables which actually contains the content for the manufacturers listing, which is generated in getDatatable. More...
|
|
| getCreate () |
| Returns a view that displays a form to create a new manufacturer. More...
|
|
| postCreate () |
| Validates and stores the data for a new manufacturer. More...
|
|
| getEdit ($manufacturerId=null) |
| Returns a view that displays a form to edit a manufacturer. More...
|
|
| postEdit ($manufacturerId=null) |
| Validates and stores the updated manufacturer data. More...
|
|
| getDelete ($manufacturerId) |
| Deletes a manufacturer. More...
|
|
| getView ($manufacturerId=null) |
| Returns a view that invokes the ajax tables which actually contains the content for the manufacturers detail listing, which is generated in getDatatable. More...
|
|
| getDatatable () |
| Generates the JSON used to display the manufacturer listings. More...
|
|
| getDataView ($manufacturerId) |
| Generates the JSON used to display the manufacturer detail. More...
|
|
This controller handles all actions related to Manufacturers for the Snipe-IT Asset Management application.
- Version
- v1.0
Definition at line 20 of file ManufacturersController.php.
App\Http\Controllers\ManufacturersController::getCreate |
( |
| ) |
|
App\Http\Controllers\ManufacturersController::getDatatable |
( |
| ) |
|
Generates the JSON used to display the manufacturer listings.
- Author
- [A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- ManufacturersController::getIndex()
- Since
- [v1.0]
- Returns
- String JSON
Definition at line 196 of file ManufacturersController.php.
198 $manufacturers = Manufacturer::select(array(
'id',
'name'))->with(
'assets')
199 ->whereNull(
'deleted_at');
201 if (Input::has(
'search')) {
202 $manufacturers = $manufacturers->TextSearch(e(Input::get(
'search')));
205 if (Input::has(
'offset')) {
206 $offset = e(Input::get(
'offset'));
211 if (Input::has(
'limit')) {
212 $limit = e(Input::get(
'limit'));
217 $allowed_columns = [
'id',
'name'];
218 $order = Input::get(
'order') ===
'asc' ?
'asc' :
'desc';
219 $sort = in_array(Input::get(
'sort'), $allowed_columns) ? Input::get(
'sort') :
'created_at';
221 $manufacturers->orderBy($sort, $order);
223 $manufacturersCount = $manufacturers->count();
224 $manufacturers = $manufacturers->skip($offset)->take($limit)->get();
228 foreach ($manufacturers as $manufacturer) {
229 $actions =
'<a href="'.route(
'update/manufacturer', $manufacturer->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/manufacturer', $manufacturer->id).
'" data-content="'.trans(
'admin/manufacturers/message.delete.confirm').
'" data-title="'.trans(
'general.delete').
' '.htmlspecialchars($manufacturer->name).
'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
232 'id' => $manufacturer->id,
233 'name' => (
string)link_to(
'admin/settings/manufacturers/'.$manufacturer->id.
'/view', e($manufacturer->name)),
234 'assets' => $manufacturer->assets->count(),
235 'actions' => $actions
239 $data = array(
'total' => $manufacturersCount,
'rows' => $rows);
App\Http\Controllers\ManufacturersController::getDataView |
( |
|
$manufacturerId | ) |
|
Generates the JSON used to display the manufacturer detail.
This JSON returns data on all of the assets with the specified manufacturer ID number.
- Author
- [A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- ManufacturersController::getView()
- Parameters
-
- Since
- [v1.0]
- Returns
- String JSON
Definition at line 257 of file ManufacturersController.php.
260 $manufacturer = Manufacturer::with(
'assets.company')->find($manufacturerId);
261 $manufacturer_assets = $manufacturer->assets;
263 if (Input::has(
'search')) {
264 $manufacturer_assets = $manufacturer_assets->TextSearch(e(Input::get(
'search')));
267 if (Input::has(
'offset')) {
268 $offset = e(Input::get(
'offset'));
273 if (Input::has(
'limit')) {
274 $limit = e(Input::get(
'limit'));
279 $order = Input::get(
'order') ===
'asc' ?
'asc' :
'desc';
281 $allowed_columns = [
'id',
'name',
'serial',
'asset_tag'];
282 $sort = in_array(Input::get(
'sort'), $allowed_columns) ? Input::get(
'sort') :
'created_at';
283 $count = $manufacturer_assets->count();
287 foreach ($manufacturer_assets as $asset) {
290 if ($asset->deleted_at==
'') {
291 $actions =
'<div style=" white-space: nowrap;"><a href="'.route(
'clone/hardware', $asset->id).
'" class="btn btn-info btn-sm" title="Clone asset"><i class="fa fa-files-o"></i></a> <a href="'.route(
'update/hardware', $asset->id).
'" class="btn btn-warning btn-sm"><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/hardware', $asset->id).
'" data-content="'.trans(
'admin/hardware/message.delete.confirm').
'" data-title="'.trans(
'general.delete').
' '.htmlspecialchars($asset->asset_tag).
'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
292 } elseif ($asset->deleted_at!=
'') {
293 $actions =
'<a href="'.route(
'restore/hardware', $asset->id).
'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
296 if ($asset->assetstatus) {
297 if ($asset->assetstatus->deployable != 0) {
298 if (($asset->assigned_to !=
'') && ($asset->assigned_to > 0)) {
299 $inout =
'<a href="'.route(
'checkin/hardware', $asset->id).
'" class="btn btn-primary btn-sm">'.trans(
'general.checkin').
'</a>';
301 $inout =
'<a href="'.route(
'checkout/hardware', $asset->id).
'" class="btn btn-info btn-sm">'.trans(
'general.checkout').
'</a>';
308 'name' => (
string)link_to(
'/hardware/'.$asset->id.
'/view', e($asset->showAssetName())),
309 'model' => e($asset->model->name),
310 'asset_tag' => e($asset->asset_tag),
311 'serial' => e($asset->serial),
312 'assigned_to' => ($asset->assigneduser) ? (
string)link_to(
'/admin/users/'.$asset->assigneduser->id.
'/view', e($asset->assigneduser->fullName())):
'',
313 'actions' => $actions,
314 'companyName' => e(Company::getName($asset)),
318 $row[
'change'] = $inout;
324 $data = array(
'total' => $count,
'rows' => $rows);
App\Http\Controllers\ManufacturersController::getDelete |
( |
|
$manufacturerId | ) |
|
Deletes a manufacturer.
- Author
- [A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- Parameters
-
- Since
- [v1.0]
- Returns
- View
Definition at line 135 of file ManufacturersController.php.
138 if (is_null($manufacturer = Manufacturer::find($manufacturerId))) {
140 return Redirect::to(
'admin/settings/manufacturers')->with(
'error', trans(
'admin/manufacturers/message.not_found'));
143 if ($manufacturer->has_models() > 0) {
146 return Redirect::to(
'admin/settings/manufacturers')->with(
'error', trans(
'admin/manufacturers/message.assoc_users'));
150 $manufacturer->delete();
153 return Redirect::to(
'admin/settings/manufacturers')->with(
'success', trans(
'admin/manufacturers/message.delete.success'));
App\Http\Controllers\ManufacturersController::getEdit |
( |
|
$manufacturerId = null | ) |
|
Returns a view that displays a form to edit a manufacturer.
- Author
- [A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- ManufacturersController::postEdit()
- Parameters
-
- Since
- [v1.0]
- Returns
- View
Definition at line 83 of file ManufacturersController.php.
86 if (is_null($manufacturer = Manufacturer::find($manufacturerId))) {
88 return Redirect::to(
'admin/settings/manufacturers')->with(
'error', trans(
'admin/manufacturers/message.does_not_exist'));
92 return View::make(
'manufacturers/edit', compact(
'manufacturer'));
App\Http\Controllers\ManufacturersController::getIndex |
( |
| ) |
|
App\Http\Controllers\ManufacturersController::getView |
( |
|
$manufacturerId = null | ) |
|
Returns a view that invokes the ajax tables which actually contains the content for the manufacturers detail listing, which is generated in getDatatable.
This data contains a listing of all assets that belong to that manufacturer.
- Author
- [A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- ManufacturersController::getDataView()
- Parameters
-
- Since
- [v1.0]
- Returns
- View
Definition at line 171 of file ManufacturersController.php.
173 $manufacturer = Manufacturer::find($manufacturerId);
175 if (isset($manufacturer->id)) {
176 return View::make(
'manufacturers/view', compact(
'manufacturer'));
179 $error = trans(
'admin/manufacturers/message.does_not_exist', compact(
'id'));
182 return Redirect::route(
'manufacturers')->with(
'error', $error);
App\Http\Controllers\ManufacturersController::postCreate |
( |
| ) |
|
Validates and stores the data for a new manufacturer.
- Author
- [A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- ManufacturersController::postCreate()
- Since
- [v1.0]
- Returns
- Redirect
Definition at line 60 of file ManufacturersController.php.
62 $manufacturer =
new Manufacturer;
63 $manufacturer->name = e(Input::get(
'name'));
64 $manufacturer->user_id = Auth::user()->id;
66 if ($manufacturer->save()) {
67 return Redirect::to(
"admin/settings/manufacturers")->with(
'success', trans(
'admin/manufacturers/message.create.success'));
70 return Redirect::back()->withInput()->withErrors($manufacturer->getErrors());
App\Http\Controllers\ManufacturersController::postEdit |
( |
|
$manufacturerId = null | ) |
|
Validates and stores the updated manufacturer data.
- Author
- [A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- ManufacturersController::getEdit()
- Parameters
-
- Since
- [v1.0]
- Returns
- View
Definition at line 105 of file ManufacturersController.php.
108 if (is_null($manufacturer = Manufacturer::find($manufacturerId))) {
110 return Redirect::to(
'admin/settings/manufacturers')->with(
'error', trans(
'admin/manufacturers/message.does_not_exist'));
114 $manufacturer->name = e(Input::get(
'name'));
117 if ($manufacturer->save()) {
119 return Redirect::to(
"admin/settings/manufacturers")->with(
'success', trans(
'admin/manufacturers/message.update.success'));
122 return Redirect::back()->withInput()->withErrors($manufacturer->getErrors());
The documentation for this class was generated from the following file: