This repository has been archived by the owner on Feb 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
15 changed files
with
1,090 additions
and
1 deletion.
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,45 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\InventoryComment; | ||
use Laravel\Lumen\Routing\Controller as BaseController; | ||
use Illuminate\Http\Request; | ||
|
||
class InventoryCommentController extends BaseController | ||
{ | ||
public function commentsByInventory($inventory_id) | ||
{ | ||
$comments = InventoryComment::where('inventory_id',$inventory_id)->get(); | ||
return response()->json($comments); | ||
} | ||
|
||
public function create(Request $request, $inventory_id) | ||
{ | ||
$comment = new InventoryComment; | ||
$comment->comment = $request->comment; | ||
$comment->user_id = $request->user_id; | ||
$comment->inventory_id = $inventory_id; | ||
$comment->save(); | ||
return response()->json($comment); | ||
} | ||
|
||
public function update(Request $request, $id) | ||
{ | ||
$comment = InventoryComment::find($id); | ||
if($request->input('comment')) { | ||
$comment->comment = $request->input('comment'); | ||
} | ||
$comment->save(); | ||
return response()->json($comment); | ||
} | ||
|
||
public function destroy($id) | ||
{ | ||
$comment = InventoryComment::find($id); | ||
$comment->delete(); | ||
|
||
return response()->json('inventory comment removed successfully'); | ||
} | ||
} | ||
?> |
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,65 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Inventory; | ||
use Laravel\Lumen\Routing\Controller as BaseController; | ||
use Illuminate\Http\Request; | ||
|
||
class InventoryController extends BaseController | ||
{ | ||
public function inventoryByLocation($storagelocation_id) | ||
{ | ||
$storagelocations = Inventory::where('storagelocation_id', $storagelocation_id)->get(); | ||
return response()->json($storagelocations); | ||
} | ||
|
||
public function create(Request $request, $storagelocation_id) | ||
{ | ||
$inventory = new Inventory; | ||
$inventory->inventoryCategoryCodeSetId = $request->inventoryCategoryCodeSetId; | ||
$inventory->inventoryCategoryCodeId = $request->inventoryCategoryCodeId; | ||
$inventory->name = $request->name; | ||
$inventory->storagelocation_id = $storagelocation_id; | ||
$inventory->description = $request->description; | ||
$inventory->save(); | ||
return response()->json($inventory); | ||
} | ||
|
||
public function show($id) | ||
{ | ||
$inventory = Inventory::find($id); | ||
return response()->json($inventory); | ||
} | ||
|
||
public function update(Request $request, $id) | ||
{ | ||
$inventory = Inventory::find($id); | ||
if($request->input('inventoryCategoryCodeSetId')) { | ||
$inventory->inventoryCategoryCodeSetId = $request->input('inventoryCategoryCodeSetId'); | ||
} | ||
if($request->input('inventoryCategoryCodeId')) { | ||
$inventory->inventoryCategoryCodeId = $request->input('inventoryCategoryCodeId'); | ||
} | ||
if($request->input('name')) { | ||
$inventory->name = $request->input('name'); | ||
} | ||
if($request->input('storagelocation_id')) { | ||
$inventory->storagelocation_id = $request->input('storagelocation_id'); | ||
} | ||
if($request->input('description')) { | ||
$inventory->description = $request->input('description'); | ||
} | ||
$inventory->save(); | ||
return response()->json($inventory); | ||
} | ||
|
||
public function destroy($id) | ||
{ | ||
$inventory = Inventory::find($id); | ||
$inventory->delete(); | ||
|
||
return response()->json('inventory removed successfully'); | ||
} | ||
} | ||
?> |
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,36 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\InventoryCount; | ||
use Laravel\Lumen\Routing\Controller as BaseController; | ||
use Illuminate\Http\Request; | ||
|
||
class InventoryCountController extends BaseController | ||
{ | ||
public function countsByInventory($inventory_id) | ||
{ | ||
$counts = InventoryCount::where('inventory_id',$inventory_id)->get(); | ||
return response()->json($counts); | ||
} | ||
|
||
public function create(Request $request, $inventory_id) | ||
{ | ||
$count = new InventoryCount; | ||
$count->inventory_id = $inventory_id; | ||
$count->counted_at = $request->counted_at; | ||
$count->count = $request->count; | ||
$count->user_id = $request->user_id; | ||
$count->save(); | ||
return response()->json($count); | ||
} | ||
|
||
public function destroy($id) | ||
{ | ||
$count = InventoryCount::find($id); | ||
$count->delete(); | ||
|
||
return response()->json('inventory count removed successfully'); | ||
} | ||
} | ||
?> |
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,66 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\StorageLocation; | ||
use Laravel\Lumen\Routing\Controller as BaseController; | ||
use Illuminate\Http\Request; | ||
|
||
class StorageLocationController extends BaseController | ||
{ | ||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function index() | ||
{ | ||
$storagelocations = StorageLocation::all(); | ||
return response()->json($storagelocations); | ||
} | ||
|
||
public function create(Request $request) | ||
{ | ||
$location = new StorageLocation; | ||
$location->name = $request->name; | ||
$location->description = $request->description; | ||
$location->long = $request->long; | ||
$location->lat = $request->lat; | ||
$location->save(); | ||
return response()->json($location); | ||
} | ||
|
||
public function show($id) | ||
{ | ||
$location = StorageLocation::find($id); | ||
return response()->json($location); | ||
} | ||
|
||
public function update(Request $request, $id) | ||
{ | ||
$location = StorageLocation::find($id); | ||
if($request->input('name')) { | ||
$location->name = $request->input('name'); | ||
} | ||
if($request->input('description')) { | ||
$location->description = $request->input('description'); | ||
} | ||
if($request->input('long')) { | ||
$location->long = $request->input('long'); | ||
} | ||
if($request->input('lat')) { | ||
$location->lat = $request->input('lat'); | ||
} | ||
$location->save(); | ||
return response()->json($location); | ||
} | ||
|
||
public function destroy($id) | ||
{ | ||
$location = StorageLocation::find($id); | ||
$location->delete(); | ||
|
||
return response()->json('location removed successfully'); | ||
} | ||
} | ||
?> |
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,37 @@ | ||
<?php | ||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class Inventory extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
protected $table = 'inventory'; | ||
|
||
protected $fillable = [ | ||
'inventoryCategoryCodeSetId', | ||
'inventoryCategoryCodeId', | ||
'name', | ||
'storagelocation_id', | ||
'description' | ||
]; | ||
protected $hidden = []; | ||
|
||
public function storagelocation() | ||
{ | ||
return $this->belongsTo(StorageLocation::class, 'storagelocation_id', 'id'); | ||
} | ||
|
||
public function comments() | ||
{ | ||
return $this->hasMany(InventoryComment::class, 'inventory_id', 'id'); | ||
} | ||
|
||
public function counts() | ||
{ | ||
return $this->hasMany(InventoryCount::class, 'inventory_id', '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,25 @@ | ||
<?php | ||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class InventoryComment extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
protected $table = 'inventorycomment'; | ||
|
||
protected $fillable = [ | ||
'comment', | ||
'user_id', | ||
'inventory_id' | ||
]; | ||
protected $hidden = []; | ||
|
||
public function inventory() | ||
{ | ||
return $this->belongsTo(Inventory::class, 'inventory_id', '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,26 @@ | ||
<?php | ||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class InventoryCount extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
protected $table = 'inventorycounting'; | ||
|
||
protected $fillable = [ | ||
'inventory_id', | ||
'counted_at', | ||
'count', | ||
'user_id' | ||
]; | ||
protected $hidden = []; | ||
|
||
public function inventory() | ||
{ | ||
return $this->belongsTo(Inventory::class, 'inventory_id', '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,21 @@ | ||
<?php | ||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class StorageLocation extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
protected $table = 'storagelocation'; | ||
|
||
protected $fillable = ['name','description','long', 'lat']; | ||
protected $hidden = []; | ||
|
||
public function inventories() | ||
{ | ||
return $this->hasMany(Inventory::class, 'storagelocation_id', '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
Oops, something went wrong.