This controller handles all actions related to Depreciations for the Snipe-IT Asset Management application.
More...
|
| getIndex () |
| Returns a view that invokes the ajax tables which actually contains the content for the depreciation listing, which is generated in getDatatable. More...
|
|
| getCreate () |
| Returns a view that displays a form to create a new depreciation. More...
|
|
| postCreate () |
| Validates and stores the new depreciation data. More...
|
|
| getEdit ($depreciationId=null) |
| Returns a view that displays a form to update a depreciation. More...
|
|
| postEdit ($depreciationId=null) |
| Validates and stores the updated depreciation data. More...
|
|
| getDelete ($depreciationId) |
| Validates and deletes a selected depreciation. More...
|
|
| getDatatable () |
| Generates the JSON used to display the depreciation listing. More...
|
|
This controller handles all actions related to Depreciations for the Snipe-IT Asset Management application.
- Version
- v1.0
Definition at line 20 of file DepreciationsController.php.
App\Http\Controllers\DepreciationsController::getCreate |
( |
| ) |
|
App\Http\Controllers\DepreciationsController::getDatatable |
( |
| ) |
|
Generates the JSON used to display the depreciation listing.
- See also
- DepreciationsController::getIndex()
- Author
- [A. Gianotto] [snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- Parameters
-
- Since
- [v1.2]
- Returns
- String JSON
Definition at line 184 of file DepreciationsController.php.
186 $depreciations = Depreciation::select(array(
'id',
'name',
'months'));
188 if (Input::has(
'search')) {
189 $depreciations = $depreciations->TextSearch(e(Input::get(
'search')));
192 if (Input::has(
'offset')) {
193 $offset = e(Input::get(
'offset'));
198 if (Input::has(
'limit')) {
199 $limit = e(Input::get(
'limit'));
204 $allowed_columns = [
'id',
'name',
'months'];
205 $order = Input::get(
'order') ===
'asc' ?
'asc' :
'desc';
206 $sort = in_array(Input::get(
'sort'), $allowed_columns) ? Input::get(
'sort') :
'created_at';
208 $depreciations->orderBy($sort, $order);
210 $depreciationsCount = $depreciations->count();
211 $depreciations = $depreciations->skip($offset)->take($limit)->get();
215 foreach ($depreciations as $depreciation) {
216 $actions =
'<a href="'.route(
'update/depreciations', $depreciation->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/depreciations', $depreciation->id).
'" data-content="'.trans(
'admin/depreciations/message.delete.confirm').
'" data-title="'.trans(
'general.delete').
' '.htmlspecialchars($depreciation->name).
'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
219 'id' => $depreciation->id,
220 'name' => e($depreciation->name),
221 'months' => e($depreciation->months),
222 'actions' => $actions
226 $data = array(
'total' => $depreciationsCount,
'rows' => $rows);
App\Http\Controllers\DepreciationsController::getDelete |
( |
|
$depreciationId | ) |
|
Validates and deletes a selected depreciation.
This is a hard-delete. We do not currently soft-delete depreciations.
- Author
- [A. Gianotto] [<snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- Since
- [v1.0]
- Returns
- Redirect
Definition at line 152 of file DepreciationsController.php.
155 if (is_null($depreciation = Depreciation::find($depreciationId))) {
157 return Redirect::to(
'admin/settings/depreciations')->with(
'error', trans(
'admin/depreciations/message.not_found'));
160 if ($depreciation->has_models() > 0) {
163 return Redirect::to(
'admin/settings/depreciations')->with(
'error', trans(
'admin/depreciations/message.assoc_users'));
166 $depreciation->delete();
169 return Redirect::to(
'admin/settings/depreciations')->with(
'success', trans(
'admin/depreciations/message.delete.success'));
App\Http\Controllers\DepreciationsController::getEdit |
( |
|
$depreciationId = null | ) |
|
Returns a view that displays a form to update a depreciation.
- Author
- [A. Gianotto] [<snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- DepreciationsController::postEdit()
- Parameters
-
- Since
- [v1.0]
- Returns
- View
Definition at line 95 of file DepreciationsController.php.
98 if (is_null($depreciation = Depreciation::find($depreciationId))) {
100 return Redirect::to(
'admin/settings/depreciations')->with(
'error', trans(
'admin/depreciations/message.does_not_exist'));
106 $depreciation_options = array(
'' =>
'Top Level') + DB::table(
'depreciations')->where(
'id',
'!=', $depreciationId)->lists(
'name',
'id');
107 return View::make(
'depreciations/edit', compact(
'depreciation'))->with(
'depreciation_options', $depreciation_options);
App\Http\Controllers\DepreciationsController::getIndex |
( |
| ) |
|
App\Http\Controllers\DepreciationsController::postCreate |
( |
| ) |
|
Validates and stores the new depreciation data.
- Author
- [A. Gianotto] [<snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- DepreciationsController::postCreate()
- Since
- [v1.0]
- Returns
- Redirect
Definition at line 62 of file DepreciationsController.php.
69 $depreciation =
new Depreciation();
72 $depreciation->name = e(Input::get(
'name'));
73 $depreciation->months = e(Input::get(
'months'));
74 $depreciation->user_id = Auth::user()->id;
77 if ($depreciation->save()) {
79 return Redirect::to(
"admin/settings/depreciations")->with(
'success', trans(
'admin/depreciations/message.create.success'));
82 return Redirect::back()->withInput()->withErrors($depreciation->getErrors());
App\Http\Controllers\DepreciationsController::postEdit |
( |
|
$depreciationId = null | ) |
|
Validates and stores the updated depreciation data.
- Author
- [A. Gianotto] [<snipe.nosp@m.@sni.nosp@m.pe.ne.nosp@m.t]
- See also
- DepreciationsController::getEdit()
- Parameters
-
- Since
- [v1.0]
- Returns
- Redirect
Definition at line 120 of file DepreciationsController.php.
123 if (is_null($depreciation = Depreciation::find($depreciationId))) {
125 return Redirect::to(
'admin/settings/depreciations')->with(
'error', trans(
'admin/depreciations/message.does_not_exist'));
129 $depreciation->name = e(Input::get(
'name'));
130 $depreciation->months = e(Input::get(
'months'));
133 if ($depreciation->save()) {
135 return Redirect::to(
"admin/settings/depreciations/")->with(
'success', trans(
'admin/depreciations/message.update.success'));
138 return Redirect::back()->withInput()->withErrors($depreciation->getErrors());
The documentation for this class was generated from the following file: