当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::forCurrentUser方法代码示例

本文整理汇总了PHP中app\models\Item::forCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::forCurrentUser方法的具体用法?PHP Item::forCurrentUser怎么用?PHP Item::forCurrentUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Item的用法示例。


在下文中一共展示了Item::forCurrentUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     Route::bind('items', function ($id) {
         return Item::forCurrentUser()->findOrFail($id);
     });
     Route::bind('categories', function ($id) {
         return Category::forCurrentUser()->findOrFail($id);
     });
 }
开发者ID:JennySwift,项目名称:lists,代码行数:16,代码来源:RouteServiceProvider.php

示例2: it_can_show_an_item

 /**
  * @test
  */
 public function it_can_show_an_item()
 {
     $this->logInUser();
     $item = Item::forCurrentUser()->first();
     $response = $this->call('GET', '/api/items/' . $item->id);
     $content = json_decode($response->getContent(), true);
     //        dd($content);
     $this->checkItemKeysExist($content);
     $this->checkItemKeysExist($content['children'][0]);
     $this->checkItemKeysExist($content['breadcrumb'][0]);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
 }
开发者ID:JennySwift,项目名称:lists,代码行数:15,代码来源:ItemsShowTest.php

示例3: calculateIndex

 /**
  * Calculate what the index of an item should be if it is not specified,
  * in order to add it as the last child of the parent.
  * @param $new_index
  * @param $parent
  * @return mixed
  */
 public function calculateIndex($new_index, $parent)
 {
     if (isset($new_index)) {
         return $new_index;
     } else {
         if ($parent) {
             if (count($parent->children) > 0) {
                 return $parent->children->last()->index + 1;
             } else {
                 return 0;
             }
         } else {
             return Item::forCurrentUser()->whereNull('parent_id')->max('index') + 1;
         }
     }
 }
开发者ID:JennySwift,项目名称:lists,代码行数:23,代码来源:Item.php

示例4: it_can_remove_an_urgency_from_an_item

 /**
  *
  * @test
  * @return void
  */
 public function it_can_remove_an_urgency_from_an_item()
 {
     DB::beginTransaction();
     $this->logInUser();
     $item = Item::forCurrentUser()->where('urgency', 1)->first();
     $response = $this->call('PUT', '/api/items/' . $item->id, ['urgency' => false]);
     $content = json_decode($response->getContent(), true);
     //dd($content);
     $this->checkItemKeysExist($content);
     $this->assertEquals(null, $content['urgency']);
     $this->assertEquals(200, $response->getStatusCode());
     DB::rollBack();
 }
开发者ID:JennySwift,项目名称:lists,代码行数:18,代码来源:ItemsUpdateTest.php

示例5: it_can_calculate_the_next_time_for_a_recurring_item_that_has_a_not_before_time_in_the_past

 /**
  * @test
  * @return void
  */
 public function it_can_calculate_the_next_time_for_a_recurring_item_that_has_a_not_before_time_in_the_past()
 {
     DB::beginTransaction();
     $this->logInUser();
     $item = Item::forCurrentUser()->whereNotNull('recurring_unit')->first();
     //Check the recurring values are as expected
     $this->assertEquals('minute', $item->recurring_unit);
     $this->assertEquals(1, $item->recurring_frequency);
     //Make the not before time in the past
     $response = $this->call('PUT', '/api/items/' . $item->id, ['not_before' => '2016-03-01 13:30:05']);
     $content = json_decode($response->getContent(), true);
     //dd($content);
     $this->assertEquals('2016-03-01 13:30:05', $content['notBefore']);
     //Check it calculates the next time correctly, for when the instance of the recurring item in the past is completed
     $response = $this->call('PUT', '/api/items/' . $item->id, ['updatingNextTimeForRecurringItem' => true]);
     $content = json_decode($response->getContent(), true);
     //dd($content);
     $this->checkItemKeysExist($content);
     $expectedNextTime = Carbon::now();
     //Make the expected seconds right for the test
     if ($expectedNextTime->second < 5) {
         $expectedNextTime->second = 5;
     } else {
         $expectedNextTime->minute++;
         $expectedNextTime->second = 5;
     }
     $this->assertEquals($expectedNextTime, $content['notBefore']);
     $this->assertEquals(200, $response->getStatusCode());
     DB::rollBack();
 }
开发者ID:JennySwift,项目名称:lists,代码行数:34,代码来源:ItemsRecurringTest.php

示例6: undoDeleteItem

 /**
  *
  * @return mixed
  */
 public function undoDeleteItem()
 {
     $item = Item::forCurrentUser()->onlyTrashed()->orderBy('deleted_at', 'desc')->first();
     $item->restore();
     $item = $this->transform($this->createItem($item, new ItemTransformer()))['data'];
     return response($item, Response::HTTP_OK);
 }
开发者ID:JennySwift,项目名称:lists,代码行数:11,代码来源:ItemsController.php

示例7: moveIn

 /**
  * For moving item to new parent. Make room for the new item.
  * @param $new_parent
  * @param $new_index
  */
 public function moveIn($new_parent, $new_index)
 {
     if ($new_parent) {
         Item::where('parent_id', $new_parent->id)->where('index', '>=', $new_index)->increment('index');
     } else {
         //Moving home
         Item::forCurrentUser()->whereNull('parent_id')->where('index', '>=', $new_index)->increment('index');
     }
 }
开发者ID:JennySwift,项目名称:lists,代码行数:14,代码来源:ItemsRepository.php


注:本文中的app\models\Item::forCurrentUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。