diff --git a/app/Item.php b/app/Item.php index b90f3c6..83afbac 100644 --- a/app/Item.php +++ b/app/Item.php @@ -34,10 +34,10 @@ class Item extends Model public static function create(array $attributes = []) { - $uid = static::query()->where('eid',$attributes['eid'])->max('uid') + 1; + $uid = static::query()->withTrashed()->where('eid',$attributes['eid'])->max('uid') + 1; $attributes['uid'] = $uid; - static::query()->create($attributes); - return Item::find($uid); + $item = static::query()->create($attributes); + return Item::find($item->iid); } protected static function extended($columns=Array()){ diff --git a/tests/ItemTest.php b/tests/ItemTest.php index 3c19d83..7f96829 100644 --- a/tests/ItemTest.php +++ b/tests/ItemTest.php @@ -153,12 +153,12 @@ class ItemTest extends TestCase $event = Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); - $item1 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'1']); + Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'1']); $item2 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'2']); $this->assertEquals(2, count(Item::all())); - $this->delete('/1/EVENT/item/'.$item1->uid); + $this->delete('/1/EVENT/item/'.$item2->uid); $this->assertResponseOk(); $this->assertEquals(1, count(Item::all())); @@ -168,10 +168,6 @@ class ItemTest extends TestCase $this->assertEquals(3, $item3['uid']); $this->assertEquals(2, count(Item::all())); - $this->delete('/1/EVENT/item/'.$item2->uid); - - $this->assertResponseOk(); - $this->assertEquals(1, count(Item::all())); } }