Merge branch 'develop' of github.com:snipe/snipe-it into develop
This commit is contained in:
@@ -53,49 +53,49 @@ class AssetsController extends AdminController {
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'asset_tag' => 'required|min:3|unique:assets',
|
||||
'model_id' => 'required',
|
||||
'serial' => 'required|min:3',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// create a new model instance
|
||||
$asset = new Asset();
|
||||
|
||||
// attempt validation
|
||||
if ($asset->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Save the asset data
|
||||
$asset->name = e(Input::get('name'));
|
||||
$asset->serial = e(Input::get('serial'));
|
||||
$asset->model_id = e(Input::get('model_id'));
|
||||
$asset->purchase_date = e(Input::get('purchase_date'));
|
||||
$asset->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$asset->order_number = e(Input::get('order_number'));
|
||||
$asset->notes = e(Input::get('notes'));
|
||||
$asset->asset_tag = e(Input::get('asset_tag'));
|
||||
$asset->user_id = Sentry::getId();
|
||||
$asset->physical = '1';
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
if($asset->save())
|
||||
{
|
||||
// Redirect to the asset listing page
|
||||
return Redirect::to("admin")->with('success', Lang::get('admin/assets/message.create.success'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failure
|
||||
$errors = $asset->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Create a new asset
|
||||
$asset = new Asset;
|
||||
|
||||
// Save the asset data
|
||||
$asset->name = e(Input::get('name'));
|
||||
$asset->serial = e(Input::get('serial'));
|
||||
$asset->model_id = e(Input::get('model_id'));
|
||||
$asset->purchase_date = e(Input::get('purchase_date'));
|
||||
$asset->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$asset->order_number = e(Input::get('order_number'));
|
||||
$asset->notes = e(Input::get('notes'));
|
||||
$asset->asset_tag = e(Input::get('asset_tag'));
|
||||
$asset->user_id = Sentry::getId();
|
||||
$asset->physical = '1';
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
if($asset->save())
|
||||
{
|
||||
// Redirect to the asset listing page
|
||||
return Redirect::to("admin")->with('success', Lang::get('admin/assets/message.create.success'));
|
||||
}
|
||||
|
||||
// Redirect to the asset create page with an error
|
||||
return Redirect::to('assets/create')->with('error', Lang::get('admin/assets/message.create.error'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,45 +137,44 @@ class AssetsController extends AdminController {
|
||||
return Redirect::to('admin')->with('error', Lang::get('admin/assets/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'asset_tag' => 'required|min:3',
|
||||
'model_id' => 'required',
|
||||
'serial' => 'required|min:3',
|
||||
);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// attempt validation
|
||||
if ($asset->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
// Update the asset data
|
||||
$asset->name = e(Input::get('name'));
|
||||
$asset->serial = e(Input::get('serial'));
|
||||
$asset->model_id = e(Input::get('model_id'));
|
||||
$asset->purchase_date = e(Input::get('purchase_date'));
|
||||
$asset->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$asset->order_number = e(Input::get('order_number'));
|
||||
$asset->asset_tag = e(Input::get('asset_tag'));
|
||||
$asset->notes = e(Input::get('notes'));
|
||||
$asset->physical = '1';
|
||||
|
||||
// Was the asset created?
|
||||
if($asset->save())
|
||||
{
|
||||
// Redirect to the asset listing page
|
||||
return Redirect::to("admin")->with('success', Lang::get('admin/assets/message.update.success'));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Did not validate
|
||||
$errors = $asset->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Update the asset data
|
||||
$asset->name = e(Input::get('name'));
|
||||
$asset->serial = e(Input::get('serial'));
|
||||
$asset->model_id = e(Input::get('model_id'));
|
||||
$asset->purchase_date = e(Input::get('purchase_date'));
|
||||
$asset->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$asset->order_number = e(Input::get('order_number'));
|
||||
$asset->asset_tag = e(Input::get('asset_tag'));
|
||||
$asset->notes = e(Input::get('notes'));
|
||||
$asset->physical = '1';
|
||||
|
||||
|
||||
// Was the asset updated?
|
||||
if($asset->save())
|
||||
{
|
||||
// Redirect to the new asset page
|
||||
return Redirect::to("assets/$assetId/edit")->with('success', Lang::get('admin/assets/message.update.success'));
|
||||
}
|
||||
|
||||
// Redirect to the asset management page with error
|
||||
return Redirect::to("assets/$assetId/edit")->with('error', Lang::get('admin/assets/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,38 +49,40 @@ class CategoriesController extends AdminController {
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// create a new model instance
|
||||
$category = new Category();
|
||||
|
||||
// attempt validation
|
||||
if ($category->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Update the category data
|
||||
$category->name = e(Input::get('name'));
|
||||
$category->parent = e(Input::get('parent'));
|
||||
$category->user_id = Sentry::getId();
|
||||
|
||||
// Was the asset created?
|
||||
if($category->save())
|
||||
{
|
||||
// Redirect to the new category page
|
||||
return Redirect::to("admin/settings/categories")->with('success', Lang::get('admin/categories/message.create.success'));
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new category
|
||||
$category = new Category;
|
||||
|
||||
// Update the category data
|
||||
$category->name = e(Input::get('name'));
|
||||
$category->parent = e(Input::get('parent'));
|
||||
$category->user_id = Sentry::getId();
|
||||
|
||||
// Was the category created?
|
||||
if($category->save())
|
||||
else
|
||||
{
|
||||
// Redirect to the new category page
|
||||
return Redirect::to("admin/settings/categories")->with('success', Lang::get('admin/categories/message.create.success'));
|
||||
// failure
|
||||
$errors = $category->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the category create page
|
||||
return Redirect::to('admin/settings/categories/create')->with('error', Lang::get('admin/categories/message.create.error'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,34 +123,35 @@ class CategoriesController extends AdminController {
|
||||
return Redirect::to('admin/categories')->with('error', Lang::get('admin/categories/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// attempt validation
|
||||
if ($category->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Update the category data
|
||||
$category->name = e(Input::get('name'));
|
||||
$category->parent = e(Input::get('parent'));
|
||||
|
||||
// Was the asset created?
|
||||
if($category->save())
|
||||
{
|
||||
// Redirect to the new category page
|
||||
return Redirect::to("admin/settings/categories")->with('success', Lang::get('admin/categories/message.update.success'));
|
||||
}
|
||||
}
|
||||
|
||||
// Update the category data
|
||||
$category->name = e(Input::get('name'));
|
||||
$category->parent = e(Input::get('parent'));
|
||||
|
||||
// Was the category updated?
|
||||
if($category->save())
|
||||
else
|
||||
{
|
||||
// Redirect to the new category page
|
||||
return Redirect::to("admin/settings/categories/$categoryId/edit")->with('success', Lang::get('admin/categories/message.update.success'));
|
||||
// failure
|
||||
$errors = $category->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the category management page
|
||||
return Redirect::to("admin/settings/categories/$categoryID/edit")->with('error', Lang::get('admin/categories/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,38 +49,39 @@ class DepreciationsController extends AdminController {
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// create a new instance
|
||||
$depreciation = new Depreciation();
|
||||
|
||||
// attempt validation
|
||||
if ($depreciation->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Depreciation data
|
||||
$depreciation->name = e(Input::get('name'));
|
||||
$depreciation->months = e(Input::get('months'));
|
||||
$depreciation->user_id = Sentry::getId();
|
||||
|
||||
// Was the asset created?
|
||||
if($depreciation->save())
|
||||
{
|
||||
// Redirect to the new depreciation page
|
||||
return Redirect::to("admin/settings/depreciations")->with('success', Lang::get('admin/depreciations/message.create.success'));
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new depreciation
|
||||
$depreciation = new Depreciation;
|
||||
|
||||
// Update the depreciation data
|
||||
$depreciation->name = e(Input::get('name'));
|
||||
$depreciation->months = e(Input::get('months'));
|
||||
$depreciation->user_id = Sentry::getId();
|
||||
|
||||
// Was the depreciation created?
|
||||
if($depreciation->save())
|
||||
else
|
||||
{
|
||||
// Redirect to the new depreciation page
|
||||
return Redirect::to("admin/settings/depreciations")->with('success', Lang::get('admin/depreciations/message.create.success'));
|
||||
// failure
|
||||
$errors = $depreciation->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the depreciation create page
|
||||
return Redirect::to('admin/settings/depreciations/create')->with('error', Lang::get('admin/depreciations/message.create.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,41 +115,44 @@ class DepreciationsController extends AdminController {
|
||||
*/
|
||||
public function postEdit($depreciationId = null)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
// Check if the depreciation exists
|
||||
if (is_null($depreciation = Depreciation::find($depreciationId)))
|
||||
{
|
||||
// Redirect to the blogs management page
|
||||
return Redirect::to('admin/settings/depreciations')->with('error', Lang::get('admin/depreciations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// attempt validation
|
||||
if ($depreciation->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Depreciation data
|
||||
$depreciation->name = e(Input::get('name'));
|
||||
$depreciation->months = e(Input::get('months'));
|
||||
|
||||
// Was the asset created?
|
||||
if($depreciation->save())
|
||||
{
|
||||
// Redirect to the depreciation page
|
||||
return Redirect::to("admin/settings/depreciations/$depreciationId/edit")->with('success', Lang::get('admin/depreciations/message.update.success'));
|
||||
}
|
||||
}
|
||||
|
||||
// Update the depreciation data
|
||||
$depreciation->name = e(Input::get('name'));
|
||||
$depreciation->months = e(Input::get('months'));
|
||||
|
||||
// Was the depreciation updated?
|
||||
if($depreciation->save())
|
||||
else
|
||||
{
|
||||
// Redirect to the new depreciation page
|
||||
return Redirect::to("admin/settings/depreciations/$depreciationId/edit")->with('success', Lang::get('admin/depreciations/message.update.success'));
|
||||
// failure
|
||||
$errors = $depreciation->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the depreciation management page
|
||||
return Redirect::to("admin/settings/depreciations/$depreciationId/edit")->with('error', Lang::get('admin/depreciations/message.update.error'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,17 +163,17 @@ class DepreciationsController extends AdminController {
|
||||
*/
|
||||
public function getDelete($depreciationId)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
// Check if the depreciation exists
|
||||
if (is_null($depreciation = Depreciation::find($depreciationId)))
|
||||
{
|
||||
// Redirect to the blogs management page
|
||||
return Redirect::to('admin/settings/depreciations')->with('error', Lang::get('admin/depreciations/message.not_found'));
|
||||
}
|
||||
|
||||
// Delete the blog post
|
||||
// Delete the depreciation
|
||||
$depreciation->delete();
|
||||
|
||||
// Redirect to the blog posts management page
|
||||
// Redirect to the depreciations management page
|
||||
return Redirect::to('admin/settings/depreciations')->with('success', Lang::get('admin/depreciations/message.delete.success'));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,46 +49,48 @@ class LicensesController extends AdminController {
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'serial' => 'required|min:5',
|
||||
'license_email' => 'email',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// create a new model instance
|
||||
$license = new License();
|
||||
|
||||
// attempt validation
|
||||
if ($license->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Save the license data
|
||||
$license->name = e(Input::get('name'));
|
||||
$license->serial = e(Input::get('serial'));
|
||||
$license->license_email = e(Input::get('license_email'));
|
||||
$license->license_name = e(Input::get('license_name'));
|
||||
$license->notes = e(Input::get('notes'));
|
||||
$license->order_number = e(Input::get('order_number'));
|
||||
$license->purchase_date = e(Input::get('purchase_date'));
|
||||
$license->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$license->user_id = Sentry::getId();
|
||||
$license->physical = '0';
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
if($license->save())
|
||||
{
|
||||
// Redirect to the new license page
|
||||
return Redirect::to("admin/licenses")->with('success', Lang::get('admin/licenses/message.create.success'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failure
|
||||
$errors = $license->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Create a new license
|
||||
$license = new License;
|
||||
|
||||
// Update the license data
|
||||
$license->name = e(Input::get('name'));
|
||||
$license->serial = e(Input::get('serial'));
|
||||
$license->license_email = e(Input::get('license_email'));
|
||||
$license->license_name = e(Input::get('license_name'));
|
||||
$license->notes = e(Input::get('notes'));
|
||||
$license->order_number = e(Input::get('order_number'));
|
||||
$license->purchase_date = e(Input::get('purchase_date'));
|
||||
$license->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$license->user_id = Sentry::getId();
|
||||
|
||||
// Was the license created?
|
||||
if($license->save())
|
||||
{
|
||||
// Redirect to the new license page
|
||||
return Redirect::to("admin/licenses")->with('success', Lang::get('admin/licenses/message.create.success'));
|
||||
}
|
||||
|
||||
// Redirect to the license create page
|
||||
// Redirect to the category create page
|
||||
return Redirect::to('admin/licenses/edit')->with('error', Lang::get('admin/licenses/message.create.error'))->with('license',new License);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,42 +129,44 @@ class LicensesController extends AdminController {
|
||||
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'serial' => 'required|min:5',
|
||||
'license_email' => 'email',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
|
||||
// attempt validation
|
||||
if ($license->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Update the license data
|
||||
$license->name = e(Input::get('name'));
|
||||
$license->serial = e(Input::get('serial'));
|
||||
$license->license_email = e(Input::get('license_email'));
|
||||
$license->license_name = e(Input::get('license_name'));
|
||||
$license->notes = e(Input::get('notes'));
|
||||
$license->order_number = e(Input::get('order_number'));
|
||||
$license->purchase_date = e(Input::get('purchase_date'));
|
||||
$license->purchase_cost = e(Input::get('purchase_cost'));
|
||||
$license->physical = '0';
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
if($license->save())
|
||||
{
|
||||
// Redirect to the new license page
|
||||
return Redirect::to("admin/licenses/$licenseId/edit")->with('success', Lang::get('admin/licenses/message.update.success'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failure
|
||||
$errors = $license->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Update the license data
|
||||
$license->name = e(Input::get('name'));
|
||||
$license->serial = e(Input::get('serial'));
|
||||
$license->license_email = e(Input::get('license_email'));
|
||||
$license->license_name = e(Input::get('license_name'));
|
||||
$license->notes = e(Input::get('notes'));
|
||||
$license->order_number = e(Input::get('order_number'));
|
||||
$license->purchase_date = e(Input::get('purchase_date'));
|
||||
$license->purchase_cost = e(Input::get('purchase_cost'));
|
||||
|
||||
// Was the license updated?
|
||||
if($license->save())
|
||||
{
|
||||
// Redirect to the new license page
|
||||
return Redirect::to("admin/licenses/$licenseId/edit")->with('success', Lang::get('admin/licenses/message.update.success'));
|
||||
}
|
||||
|
||||
// Redirect to the license management page
|
||||
// Redirect to the category create page
|
||||
return Redirect::to("admin/licenses/$licenseId/edit")->with('error', Lang::get('admin/licenses/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,45 +49,44 @@ class LocationsController extends AdminController {
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'city' => 'required|min:3',
|
||||
'state' => 'required|alpha|min:2|max:2',
|
||||
'country' => 'required|alpha|min:2|max:2',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// create a new model instance
|
||||
$location = new Location();
|
||||
|
||||
// attempt validation
|
||||
if ($location->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Save the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
$location->city = e(Input::get('city'));
|
||||
$location->state = e(Input::get('state'));
|
||||
$location->country = e(Input::get('country'));
|
||||
$location->user_id = Sentry::getId();
|
||||
|
||||
// Was the asset created?
|
||||
if($location->save())
|
||||
{
|
||||
// Redirect to the new location page
|
||||
return Redirect::to("admin/settings/locations")->with('success', Lang::get('admin/locations/message.create.success'));
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new location
|
||||
$location = new Location;
|
||||
|
||||
// Update the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
$location->city = e(Input::get('city'));
|
||||
$location->state = e(Input::get('state'));
|
||||
$location->country = e(Input::get('country'));
|
||||
$location->user_id = Sentry::getId();
|
||||
|
||||
// Was the location created?
|
||||
if($location->save())
|
||||
else
|
||||
{
|
||||
// Redirect to the new location page
|
||||
return Redirect::to("admin/settings/locations")->with('success', Lang::get('admin/locations/message.create.success'));
|
||||
// failure
|
||||
$errors = $location->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the location create page
|
||||
return Redirect::to('admin/settings/locations/create')->with('error', Lang::get('admin/locations/message.create.error'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Location update.
|
||||
*
|
||||
@@ -119,47 +118,46 @@ class LocationsController extends AdminController {
|
||||
*/
|
||||
public function postEdit($locationId = null)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
// Check if the location exists
|
||||
if (is_null($location = Location::find($locationId)))
|
||||
{
|
||||
// Redirect to the blogs management page
|
||||
return Redirect::to('admin/settings/locations')->with('error', Lang::get('admin/locations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'city' => 'required|min:3',
|
||||
'state' => 'required|alpha|min:2|max:2',
|
||||
'country' => 'required|alpha|min:2|max:2',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
|
||||
// attempt validation
|
||||
if ($location->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Update the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
$location->city = e(Input::get('city'));
|
||||
$location->state = e(Input::get('state'));
|
||||
$location->country = e(Input::get('country'));
|
||||
|
||||
// Was the asset created?
|
||||
if($location->save())
|
||||
{
|
||||
// Redirect to the saved location page
|
||||
return Redirect::to("admin/settings/locations/$locationId/edit")->with('success', Lang::get('admin/locations/message.update.success'));
|
||||
}
|
||||
}
|
||||
|
||||
// Update the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
$location->city = e(Input::get('city'));
|
||||
$location->state = e(Input::get('state'));
|
||||
$location->country = e(Input::get('country'));
|
||||
|
||||
|
||||
// Was the location updated?
|
||||
if($location->save())
|
||||
else
|
||||
{
|
||||
// Redirect to the new location page
|
||||
return Redirect::to("admin/settings/locations/$locationId/edit")->with('success', Lang::get('admin/locations/message.update.success'));
|
||||
// failure
|
||||
$errors = $location->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the location management page
|
||||
return Redirect::to("admin/settings/locations/$locationId/edit")->with('error', Lang::get('admin/locations/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,17 +168,17 @@ class LocationsController extends AdminController {
|
||||
*/
|
||||
public function getDelete($locationId)
|
||||
{
|
||||
// Check if the blog post exists
|
||||
// Check if the location exists
|
||||
if (is_null($location = Location::find($locationId)))
|
||||
{
|
||||
// Redirect to the blogs management page
|
||||
return Redirect::to('admin/settings/locations')->with('error', Lang::get('admin/locations/message.not_found'));
|
||||
}
|
||||
|
||||
// Delete the blog post
|
||||
// Delete the location
|
||||
$location->delete();
|
||||
|
||||
// Redirect to the blog posts management page
|
||||
// Redirect to the locations management page
|
||||
return Redirect::to('admin/settings/locations')->with('success', Lang::get('admin/locations/message.delete.success'));
|
||||
}
|
||||
|
||||
|
||||
@@ -45,37 +45,38 @@ class ManufacturersController extends AdminController {
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
}
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// Create a new manufacturer
|
||||
$manufacturer = new Manufacturer;
|
||||
|
||||
// Update the manufacturer data
|
||||
$manufacturer->name = e(Input::get('name'));
|
||||
$manufacturer->user_id = Sentry::getId();
|
||||
|
||||
// Was the manufacturer created?
|
||||
if($manufacturer->save())
|
||||
// attempt validation
|
||||
if ($manufacturer->validate($new))
|
||||
{
|
||||
// Redirect to the new manufacturer page
|
||||
return Redirect::to("admin/settings/manufacturers")->with('success', Lang::get('admin/manufacturers/message.create.success'));
|
||||
|
||||
// Save the location data
|
||||
$manufacturer->name = e(Input::get('name'));
|
||||
$manufacturer->user_id = Sentry::getId();
|
||||
|
||||
// Was it created?
|
||||
if($manufacturer->save())
|
||||
{
|
||||
// Redirect to the new manufacturer page
|
||||
return Redirect::to("admin/settings/manufacturers")->with('success', Lang::get('admin/manufacturers/message.create.success'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failure
|
||||
$errors = $manufacturer->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the manufacturer create page
|
||||
return Redirect::to('admin/settings/manufacturers/create')->with('error', Lang::get('admin/manufacturers/message.create.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,33 +114,34 @@ class ManufacturersController extends AdminController {
|
||||
return Redirect::to('admin/settings/manufacturers')->with('error', Lang::get('admin/manufacturers/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// attempt validation
|
||||
if ($manufacturer->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Save the data
|
||||
$manufacturer->name = e(Input::get('name'));
|
||||
|
||||
// Was it created?
|
||||
if($manufacturer->save())
|
||||
{
|
||||
// Redirect to the new manufacturer page
|
||||
return Redirect::to("admin/settings/manufacturers")->with('success', Lang::get('admin/manufacturers/message.update.success'));
|
||||
}
|
||||
}
|
||||
|
||||
// Update the manufacturer data
|
||||
$manufacturer->name = e(Input::get('name'));
|
||||
|
||||
// Was the manufacturer updated?
|
||||
if($manufacturer->save())
|
||||
else
|
||||
{
|
||||
// Redirect to the new manufacturer page
|
||||
return Redirect::to("admin/settings/manufacturers")->with('success', Lang::get('admin/manufacturers/message.update.success'));
|
||||
// failure
|
||||
$errors = $manufacturer->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the manufacturer management page
|
||||
return Redirect::to("admin/settings/manufacturers/$manufacturerId/edit")->with('error', Lang::get('admin/manufacturers/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,39 +48,41 @@ class ModelsController extends AdminController {
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
}
|
||||
|
||||
// Create a new model
|
||||
// Create a new manufacturer
|
||||
$model = new Model;
|
||||
|
||||
// Update the model data
|
||||
$model->name = e(Input::get('name'));
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->depreciation_id = e(Input::get('depreciation_id'));
|
||||
$model->user_id = Sentry::getId();
|
||||
|
||||
// Was the model created?
|
||||
if($model->save())
|
||||
// attempt validation
|
||||
if ($model->validate($new))
|
||||
{
|
||||
// Redirect to the new model page
|
||||
return Redirect::to("assets/models")->with('success', Lang::get('admin/models/message.create.success'));
|
||||
|
||||
// Save the model data
|
||||
$model->name = e(Input::get('name'));
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->depreciation_id = e(Input::get('depreciation_id'));
|
||||
$model->user_id = Sentry::getId();
|
||||
|
||||
|
||||
// Was it created?
|
||||
if($model->save())
|
||||
{
|
||||
// Redirect to the new model page
|
||||
return Redirect::to("assets/models")->with('success', Lang::get('admin/models/message.create.success'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failure
|
||||
$errors = $model->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Redirect to the model create page
|
||||
return Redirect::to('assets/models/create')->with('error', Lang::get('admin/models/message.create.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,35 +121,36 @@ class ModelsController extends AdminController {
|
||||
return Redirect::to('admin/models')->with('error', Lang::get('admin/models/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
// get the POST data
|
||||
$new = Input::all();
|
||||
|
||||
// Create a new validator instance from our validation rules
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
// If validation fails, we'll exit the operation now.
|
||||
if ($validator->fails())
|
||||
// attempt validation
|
||||
if ($model->validate($new))
|
||||
{
|
||||
// Ooops.. something went wrong
|
||||
return Redirect::back()->withInput()->withErrors($validator);
|
||||
|
||||
// Update the model data
|
||||
$model->name = e(Input::get('name'));
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->depreciation_id = e(Input::get('depreciation_id'));
|
||||
|
||||
|
||||
// Was it created?
|
||||
if($model->save())
|
||||
{
|
||||
// Redirect to the new model page
|
||||
return Redirect::to("assets/models/$modelId/edit")->with('success', Lang::get('admin/models/message.update.success'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failure
|
||||
$errors = $model->errors();
|
||||
return Redirect::back()->withInput()->withErrors($errors);
|
||||
}
|
||||
|
||||
// Update the model data
|
||||
$model->name = e(Input::get('name'));
|
||||
$model->modelno = e(Input::get('modelno'));
|
||||
$model->depreciation_id = e(Input::get('depreciation_id'));
|
||||
|
||||
// Was the model updated?
|
||||
if($model->save())
|
||||
{
|
||||
// Redirect to the new model page
|
||||
return Redirect::to("assets/models/$modelId/edit")->with('success', Lang::get('admin/models/message.update.success'));
|
||||
}
|
||||
|
||||
// Redirect to the model management page
|
||||
// Redirect to the model create page
|
||||
return Redirect::to("assets/models/$modelId/edit")->with('error', Lang::get('admin/models/message.update.error'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+10
-15
@@ -1,23 +1,18 @@
|
||||
<?php
|
||||
|
||||
class Asset extends Eloquent {
|
||||
|
||||
/**
|
||||
* Deletes an asset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
class Asset extends Elegant {
|
||||
|
||||
protected $table = 'assets';
|
||||
|
||||
public function delete()
|
||||
{
|
||||
// Delete the asset
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'asset_tag' => 'required|min:3|unique:assets',
|
||||
'model_id' => 'required',
|
||||
'serial' => 'required|min:3',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Handle depreciation
|
||||
*/
|
||||
public function depreciation()
|
||||
{
|
||||
$depreciation_id = Model::find($this->model_id)->depreciation_id;
|
||||
|
||||
+6
-12
@@ -1,20 +1,14 @@
|
||||
<?php
|
||||
|
||||
class Category extends Eloquent {
|
||||
class Category extends Elegant {
|
||||
|
||||
/**
|
||||
* Deletes a category
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
* Category validation rules
|
||||
*/
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:2',
|
||||
);
|
||||
|
||||
protected $table = 'categories';
|
||||
|
||||
public function delete()
|
||||
{
|
||||
// Delete the category
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
<?php
|
||||
|
||||
class Depreciation extends Eloquent {
|
||||
|
||||
/**
|
||||
* Deletes a depreciation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
protected $table = 'depreciations';
|
||||
|
||||
public function delete()
|
||||
{
|
||||
// Delete the depreciation
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
|
||||
class Depreciation extends Elegant {
|
||||
|
||||
// Declare the rules for the form validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'months' => 'required|min:1|integer',
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?
|
||||
|
||||
class Elegant extends Eloquent
|
||||
{
|
||||
protected $rules = array();
|
||||
protected $errors;
|
||||
|
||||
public function validate($data)
|
||||
{
|
||||
// make a new validator object
|
||||
$v = Validator::make($data, $this->rules);
|
||||
|
||||
// check for failure
|
||||
if ($v->fails())
|
||||
{
|
||||
// set errors and return false
|
||||
$this->errors = $v->errors();
|
||||
return false;
|
||||
}
|
||||
|
||||
// validation pass
|
||||
return true;
|
||||
}
|
||||
|
||||
public function errors()
|
||||
{
|
||||
return $this->errors;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class License extends Eloquent {
|
||||
class License extends Elegant {
|
||||
|
||||
/**
|
||||
* Deletes a category
|
||||
@@ -10,11 +10,11 @@ class License extends Eloquent {
|
||||
|
||||
protected $table = 'assets';
|
||||
|
||||
public function delete()
|
||||
{
|
||||
// Delete the license
|
||||
return parent::delete();
|
||||
}
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'serial' => 'required|min:5',
|
||||
'license_email' => 'email',
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
+7
-13
@@ -1,19 +1,13 @@
|
||||
<?php
|
||||
|
||||
class Location extends Eloquent {
|
||||
|
||||
/**
|
||||
* Deletes a location
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
class Location extends Elegant {
|
||||
|
||||
protected $table = 'locations';
|
||||
|
||||
public function delete()
|
||||
{
|
||||
// Delete the depreciation
|
||||
return parent::delete();
|
||||
}
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'city' => 'required|min:3',
|
||||
'state' => 'required|alpha|min:2|max:2',
|
||||
'country' => 'required|alpha|min:2|max:2',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
<?php
|
||||
class Manufacturer extends Elegant {
|
||||
|
||||
class Manufacturer extends Eloquent {
|
||||
|
||||
/**
|
||||
* Deletes a manufacturer
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Declare the rules for the form validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:2',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
+5
-12
@@ -1,17 +1,10 @@
|
||||
<?php
|
||||
|
||||
class Model extends Eloquent {
|
||||
class Model extends Elegant {
|
||||
|
||||
/**
|
||||
* Deletes the model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
|
||||
// Delete the model
|
||||
return parent::delete();
|
||||
}
|
||||
// Declare the rules for the form validation
|
||||
protected $rules = array(
|
||||
'name' => 'required|min:3',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<div class="control-group {{ $errors->has('months') ? 'error' : '' }}">
|
||||
<label class="control-label" for="name">Number of Months</label>
|
||||
<div class="controls">
|
||||
<input class="span6" type="text" name="months" id="months" value="{{ Input::old('months', $depreciation->months) }}" />
|
||||
<input class="span2" type="text" name="months" id="months" value="{{ Input::old('months', $depreciation->months) }}" />
|
||||
{{ $errors->first('months', '<span class="help-inline">:message</span>') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group {{ $errors->has('name') ? 'error' : '' }}">
|
||||
<div class="control-group {{ $errors->has('modelno') ? 'error' : '' }}">
|
||||
<label class="control-label" for="modelno">Model No.</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="modelno" id="modelno" value="{{ Input::old('modelno', $model->modelno) }}" />
|
||||
|
||||
Reference in New Issue
Block a user