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


PHP Item::onlyTrashed方法代码示例

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


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

示例1: restoreItem

/**
 * RESTORE an item 
 *
 * (the model migth allow soft deletes!)
 *
 * Make sure the new sequence number fits sequentially into 
 *    the list of sequence numbers of the existing items for a plan
 *    and that all current sequence numbers are in 1.0 steps
 *
 * @param object $items
 * @param number $new_seq_no
 */
function restoreItem($id)
{
    // this item should be restored
    $item = Item::onlyTrashed()->find($id);
    if (!$item) {
        return false;
    }
    $item->restore();
    // get all items of the related plan
    $plan = Plan::find($item->plan_id);
    $items = $plan->items()->orderBy('seq_no')->get();
    // numbering them countering with 1.0
    $counter = 1.0;
    foreach ($items as $item) {
        if ($item->seq_no != $counter) {
            $i = Item::find($item->id);
            # get the actual DB record
            $item->seq_no = $counter;
            # update the current selection
            $i->seq_no = $counter;
            # update the seq_no
            $i->save();
            # save the record
        }
        $counter += 1.0;
    }
    return true;
}
开发者ID:matthiku,项目名称:cSpot,代码行数:40,代码来源:helpers.php

示例2: restoreAllTrashed

 /**
  * RESTORE all trashed items of a plan
  *
  */
 public function restoreAllTrashed($plan_id)
 {
     // this item should be restored
     $items = Item::onlyTrashed()->where('plan_id', $plan_id)->get();
     if (!$items) {
         return false;
     }
     // restore all items and try to restore their correct sequence number
     foreach ($items as $item) {
         restoreItem($item->id);
     }
     flash('All trashed items restored. Please review the sequence!');
     return \Redirect::back();
 }
开发者ID:matthiku,项目名称:cSpot,代码行数:18,代码来源:ItemController.php

示例3: edit

 /**
  * PLAN DETAILS form
  *
  * @param  int  $id
  * @param  int  $new_item_id    indicates a newly inserted item 
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     // find a single plan by ID
     $plan = Plan::with(['items' => function ($query) {
         $query->withTrashed()->orderBy('seq_no');
     }])->find($id);
     if ($plan) {
         // get list of service types
         $types = Type::get();
         // get list of users
         $users = User::orderBy('first_name')->get();
         // get list of trashed items (if any)
         $trashedItemsCount = Item::onlyTrashed()->where('plan_id', $id)->count();
         // check if a new item was just now inserted (used for highlighing in the view)
         $newest_item_id = 0;
         if (session()->has('newest_item_id')) {
             $newest_item_id = session()->get('newest_item_id');
             session()->forget('newest_item_id');
         }
         // get service times from plan dates
         $plan->start = Carbon::instance($plan->date)->toTimeString();
         // for backwards compatibility, we allowed for null as end date
         if ($plan->date_end) {
             $plan->end = Carbon::instance($plan->date_end)->toTimeString();
         } else {
             $plan->end = "23:59";
         }
         return view($this->view_one, array('plan' => $plan, 'types' => $types, 'users' => $users, 'versionsEnum' => json_decode(env('BIBLE_VERSIONS')), 'newest_item_id' => $newest_item_id, 'trashedItemsCount' => $trashedItemsCount));
     }
     flashError('Plan with id "' . $id . '" not found');
     return \Redirect::route($this->view_idx);
 }
开发者ID:matthiku,项目名称:cSpot,代码行数:39,代码来源:PlanController.php


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