mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php
|
|
|
|
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;
|
|
}
|
|
}
|