mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
ALPHA 3.0.3
This commit is contained in:
@@ -3,10 +3,55 @@
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Item;
|
||||
|
||||
class Schedule extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
public function getInventory($periode)
|
||||
{
|
||||
$dispo = [];
|
||||
$used = [];
|
||||
$dispo_item = collect();
|
||||
|
||||
$string_periode = 'p'.$periode;
|
||||
|
||||
$inventory = Item::all();
|
||||
|
||||
foreach ($inventory as $item) {
|
||||
array_push($dispo, $item->id);
|
||||
}
|
||||
|
||||
$n1 = 'n1_'.$string_periode.'_item';
|
||||
$items_array = explode("-",$this->$n1);
|
||||
|
||||
foreach ($items_array as $item_array) {
|
||||
array_push($used,$item_array);
|
||||
}
|
||||
|
||||
$n2 = 'n2_'.$string_periode.'_item';
|
||||
$items_array = explode("-",$this->$n2);
|
||||
|
||||
foreach ($items_array as $item_array) {
|
||||
array_push($used,$item_array);
|
||||
}
|
||||
|
||||
$n3 = 'n3_'.$string_periode.'_item';
|
||||
$items_array = explode("-",$this->$n3);
|
||||
|
||||
foreach ($items_array as $item_array) {
|
||||
array_push($used,$item_array);
|
||||
}
|
||||
|
||||
$dispo = array_diff($dispo,$used);
|
||||
|
||||
foreach ($dispo as $key) {
|
||||
$dispo_item->push(Item::find($key));
|
||||
}
|
||||
|
||||
return $dispo_item;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user