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


PHP Asset::find方法代码示例

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


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

示例1: getDetail

 public function getDetail($id)
 {
     $_id = new MongoId($id);
     $history = History::where('historyObject._id', $_id)->where('historyObjectType', 'asset')->orderBy('historyTimestamp', 'desc')->orderBy('historySequence', 'desc')->get();
     $diffs = array();
     foreach ($history as $h) {
         $h->date = date('Y-m-d H:i:s', $h->historyTimestamp->sec);
         $diffs[$h->date][$h->historySequence] = $h->historyObject;
     }
     $history = History::where('historyObject._id', $_id)->where('historyObjectType', 'asset')->where('historySequence', 0)->orderBy('historyTimestamp', 'desc')->get();
     $tab_data = array();
     foreach ($history as $h) {
         $apv_status = Assets::getApprovalStatus($h->approvalTicket);
         if ($apv_status == 'pending') {
             $bt_apv = '<span class="btn btn-info change-approval ' . $h->approvalTicket . '" data-id="' . $h->approvalTicket . '" >' . $apv_status . '</span>';
         } else {
             if ($apv_status == 'verified') {
                 $bt_apv = '<span class="btn btn-success" >' . $apv_status . '</span>';
             } else {
                 $bt_apv = '';
             }
         }
         $d = date('Y-m-d H:i:s', $h->historyTimestamp->sec);
         $tab_data[] = array($d, $h->historyAction, $h->historyObject['itemDescription'], $h->historyAction == 'new' ? 'NA' : $this->objdiff($diffs[$d]), $bt_apv);
     }
     $header = array('Modified', 'Event', 'Name', 'Diff', 'Approval');
     $attr = array('class' => 'table', 'id' => 'transTab', 'style' => 'width:100%;', 'border' => '0');
     $t = new HtmlTable($tab_data, $attr, $header);
     $itemtable = $t->build();
     $asset = Asset::find($id);
     Breadcrumbs::addCrumb('Ad Assets', URL::to(strtolower($this->controller_name)));
     Breadcrumbs::addCrumb('Detail', URL::to(strtolower($this->controller_name) . '/detail/' . $asset->_id));
     Breadcrumbs::addCrumb($asset->SKU, URL::to(strtolower($this->controller_name)));
     return View::make('history.table')->with('a', $asset)->with('title', 'Asset Detail ' . $asset->itemDescription)->with('table', $itemtable);
 }
开发者ID:awidarto,项目名称:jexadmin,代码行数:35,代码来源:OrderarchiveController.php

示例2: defaults

 /**
  * Configure asset warping for a default Zing! CMS installation.
  * This sets up:
  *  * sources for CMS uploaded assets and thumbs
  *  * an 'original' profile that leaves files unaltered
  *  * a 'system-default' profile that constrains images to 640x640
  *  * a 'system-thumbnail' profile that constrains images to 50x50
  */
 public function defaults()
 {
     $this->source('asset', '/^\\d+$/', function ($id) {
         $asset = \Asset::find($id);
         return $asset->get_file_blob();
     });
     $this->source('thumb', '/^\\d+$/', function ($id) {
         $asset = \Asset::find($id);
         $blob = $asset->get_thumb_blob();
         if (!$blob && $asset->is_web_safe_image()) {
             $blob = $asset->get_file_blob();
         }
         return $blob;
     });
     $this->profile('original', function ($blob) {
     })->title('Original');
     $this->image_profile('system-default', function ($image) {
         $image->constrain(640, 640);
     })->hide();
     $this->image_profile('system-thumbnail', function ($image) {
         $image->constrain(50, 50);
     })->hide();
 }
开发者ID:jaz303,项目名称:zing,代码行数:31,代码来源:warping.php

示例3: delete

 public function delete($id)
 {
     $wantsJson = Request::wantsJson();
     $asset = Asset::find($id);
     if ($asset == null) {
         return $wantsJson ? Response::json(['errors' => 'No asset found', 'status' => 404, 'id' => $id]) : Redirect::back()->with(['errors' => 'No asset found', 'status' => 404]);
     }
     if (Schema::hasTable('assetables')) {
         $total = 0;
         $assetables = DB::table('assetables')->where('asset_id', $id)->get();
         if ($assetables) {
             $item = null;
             foreach ($assetables as $as) {
                 $as_type = $as->assetable_type;
                 $as_id = $as->assetable_id;
                 $item = $as_type::find($as_id);
                 if ($item) {
                     $item->assets()->detach($asset);
                     $total = $item->assets->count();
                 }
             }
         }
     }
     $asset->delete();
     return $wantsJson ? Response::json(['notice' => 'Asset deleted', 'status' => 200, 'id' => $id]) : Redirect::back()->with(['error' => 'Asset deleted', 'status' => 200, 'id' => $id]);
 }
开发者ID:vanderlin,项目名称:halp,代码行数:26,代码来源:AssetsController.php

示例4: approve

 public function approve()
 {
     //check the users group
     $authorizers = Sentry::findGroupByName('Authorizers');
     $admins = Sentry::findGroupByName('Admin');
     //DLN authorizers
     if (Sentry::getUser()->inGroup($authorizers)) {
         $this->request_code = 1;
         $this->save();
         return array('success' => 1, 'message' => 'Request Approved', 'type' => $this->type);
     } elseif (Sentry::getUser()->inGroup($admins)) {
         //get all license types for request
         $lcnsNames = $this->licenseTypes()->lists('name');
         //get available license seats for each license type
         $that = $this;
         $toAdd = [];
         if ($this->type == 'license') {
             //TODO:: remove and place in seperate method - this will need to be used to update a request
             foreach ($lcnsNames as $lcnsName) {
                 $lcnsSeat = DB::table('licenses')->join('license_types', 'licenses.type_id', '=', 'license_types.id')->join('license_seats', 'licenses.id', '=', 'license_seats.license_id')->orwhere(function ($query) use($lcnsName, $that) {
                     $query->where('license_types.name', '=', $lcnsName)->where('licenses.role_id', $that->role_id)->whereNull('license_seats.assigned_to');
                 })->first();
                 //if seats available add it to array for later processing, else return with error message
                 if ($lcnsSeat) {
                     $toAdd[$lcnsName] = $lcnsSeat;
                 } else {
                     $messageKey = str_replace(' ', '', strtolower($lcnsName));
                     $error = Lang::get('request.message_no_lcns.' . $lcnsName);
                     return array('success' => 0, 'message' => $error);
                 }
             }
             foreach ($toAdd as $key => $lcnsSeat) {
                 if ($key == 'SABA Publisher') {
                     //create computer name as an asset if it doesnt exist
                     if ($obj = DB::table('assets')->where('serial', $this->pc_name)->first(array('id'))) {
                         $asset = Asset::find($obj->id);
                     } else {
                         $asset = new Asset();
                         $asset->name = "DWAN PC";
                         $asset->serial = $this->pc_name;
                         $asset->asset_tag = $this->pc_name;
                         $asset->model_id = 7;
                         //TODO: Remove this hard coding for model id
                         $asset->status_id = 1;
                         $asset->assigned_to = $this->account->id;
                     }
                     $asset->role_id = $this->role_id;
                     $asset->save();
                     License::checkOutToAsset($lcnsSeat->id, $asset->id);
                 }
                 //checkout to account the request has been made for
                 License::checkOutToAccount($lcnsSeat->id, $this->account_id);
             }
         } elseif ($this->type == 'checkin') {
             //clear license fields
             $seat = LicenseSeat::find($this->license_id);
             $seat->checkIn();
         }
         //detach requested licenses
         $this->licenseTypes()->detach();
         $type = $this->type;
         //marked as closed
         $this->delete();
         return array('success' => 1, 'message' => 'Request Approved', 'type' => $type);
     }
 }
开发者ID:amcfarlane1251,项目名称:lcnsMgmt,代码行数:66,代码来源:Requests.php

示例5: syncGrades

 /**
  * Query to sync form scores with gradebook
  *
  * @param      obj   $course
  * @param      array $member_id
  * @return     void
  */
 public function syncGrades($course, $member_id = null)
 {
     if (!is_null($member_id) && !empty($member_id)) {
         if (!is_array($member_id)) {
             $member_id = (array) $member_id;
         }
     } else {
         // Pull all section members
         $members = $course->offering()->section()->members(array('student' => 1));
         $member_id = array();
         // Get member id's for refresh filter
         foreach ($members as $member) {
             $member_id[] = $member->get('id');
         }
     }
     if (count($member_id) == 0) {
         return;
     }
     // Get the assets
     $asset = new Asset($this->_db);
     $assets = $asset->find(array('w' => array('course_id' => $course->get('id'), 'section_id' => $course->offering()->section()->get('id'), 'offering_id' => $course->offering()->get('id'), 'asset_type' => 'form')));
     // Query for existing data
     $query = "SELECT * FROM `#__courses_grade_book` WHERE `member_id` IN (" . implode(',', $member_id) . ") AND `scope` IN ('asset')";
     $this->_db->setQuery($query);
     $results = $this->_db->loadObjectList();
     $existing_grades = array();
     foreach ($results as $r) {
         $existing_grades[$r->member_id . '.' . $r->scope_id] = array('id' => $r->id, 'score' => $r->score);
     }
     $inserts = array();
     $updates = array();
     $deletes = array();
     if (count($assets) > 0) {
         foreach ($assets as $asset) {
             // Add null values for unpublished forms that may have already been taken
             if ($asset->state != 1) {
                 $deletes[] = $asset->id;
                 continue;
             }
             $crumb = false;
             // Check for result for given student on form
             $crumb = $asset->url;
             if (!$crumb || strlen($crumb) != 20 || $asset->state != 1) {
                 // Break foreach, this is not a valid form!
                 continue;
             }
             include_once dirname(__DIR__) . DS . 'models' . DS . 'formDeployment.php';
             $dep = \Components\Courses\Models\PdfFormDeployment::fromCrumb($crumb, $course->offering()->section()->get('id'));
             $results = $dep->getResults('member_id', $member_id);
             switch ($dep->getState()) {
                 // Form isn't available yet
                 case 'pending':
                     // Null value
                     foreach ($member_id as $u) {
                         $key = $u . '.' . $asset->id;
                         if (!array_key_exists($key, $existing_grades)) {
                             $inserts[] = "('{$u}', NULL, 'asset', '{$asset->id}', NULL)";
                         } else {
                             if (!is_null($existing_grades[$key]['score'])) {
                                 $updates[] = "UPDATE `#__courses_grade_book` SET `score` = NULL WHERE `id` = '" . $existing_grades[$key]['id'] . "'";
                             }
                         }
                     }
                     break;
                     // Form availability has expired - students either get a 0, or their score (no nulls)
                 // Form availability has expired - students either get a 0, or their score (no nulls)
                 case 'expired':
                     foreach ($member_id as $u) {
                         $score = isset($results[$u]['score']) ? $results[$u]['score'] : '0.00';
                         $finished = isset($results[$u]['finished']) ? '\'' . $results[$u]['finished'] . '\'' : 'NULL';
                         $key = $u . '.' . $asset->id;
                         if (!array_key_exists($key, $existing_grades)) {
                             $inserts[] = "('{$u}', '{$score}', 'asset', '{$asset->id}', {$finished})";
                         } else {
                             if ($existing_grades[$key]['score'] != $score) {
                                 $updates[] = "UPDATE `#__courses_grade_book` SET `score` = '{$score}', `score_recorded` = {$finished} WHERE `id` = '" . $existing_grades[$key]['id'] . "'";
                             }
                         }
                     }
                     break;
                     // Form is still active - students either get their score, or a null
                 // Form is still active - students either get their score, or a null
                 case 'active':
                     foreach ($member_id as $u) {
                         $resp = $dep->getRespondent($u);
                         // Form is active and they have completed it!
                         if ($resp->getEndTime() && $resp->getEndTime() != '') {
                             $score = isset($results[$u]['score']) ? '\'' . $results[$u]['score'] . '\'' : 'NULL';
                             $key = $u . '.' . $asset->id;
                             if (!array_key_exists($key, $existing_grades)) {
                                 $inserts[] = "('{$u}', {$score}, 'asset', '{$asset->id}', '" . $results[$u]['finished'] . "')";
                             } else {
                                 if ($existing_grades[$key]['score'] != $score) {
//.........这里部分代码省略.........
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:grade.book.php

示例6: dispAsset

 public function dispAsset($data)
 {
     if ($data['assetType'] == 'location') {
         return 'location';
     } else {
         if ($data['assetType'] == 'rack') {
             return 'rack';
         } else {
             $asset = Asset::find($data['assetId']);
             return isset($asset->SKU) ? $asset->SKU : '';
         }
     }
 }
开发者ID:awidarto,项目名称:bilnatracker,代码行数:13,代码来源:ApprovalController.php

示例7: postEdit

 public function postEdit($id, $data = null)
 {
     if (isset($data['useImage']) && $data['useImage'] == 'linked') {
         $this->validator = array('itemDescription' => 'required', 'extImageURL' => 'required');
     } else {
         $this->validator = array('itemDescription' => 'required');
     }
     $hobj = Asset::find($id)->toArray();
     $hobj['_id'] = new MongoId($id);
     $hdata['historyTimestamp'] = new MongoDate();
     $hdata['historyAction'] = 'update';
     $hdata['historySequence'] = 0;
     $hdata['historyObjectType'] = 'asset';
     $hdata['historyObject'] = $hobj;
     History::insert($hdata);
     return parent::postEdit($id, $data);
 }
开发者ID:awidarto,项目名称:bilnatracker,代码行数:17,代码来源:AssetController.php

示例8: populateDashboard

 public function populateDashboard($roleId)
 {
     //get asset info
     $allAssets = DB::table('models')->join('assets', 'assets.model_id', '=', 'models.id')->orwhere(function ($query) use($roleId) {
         $query->where('assets.role_id', $roleId);
         $query->where('assets.deleted_at', NULL);
     })->get();
     $assets = array();
     //populate assets array
     foreach ($allAssets as $key => $asset) {
         $modelObj = Asset::find($asset->id);
         if ($modelObj->assigneduser) {
             $location = $modelObj->assetloc->name;
         } elseif ($modelObj->defaultLoc) {
             $location = $modelObj->defaultLoc->name;
         } else {
             $location = null;
         }
         $assets[$key] = new \stdClass();
         $assets[$key]->model = $asset->name;
         $assets[$key]->assetTag = $asset->asset_tag;
         $assets[$key]->numOfLcns = $modelObj->licenseSeatsCount();
         $assets[$key]->location = $location;
     }
     return $assets;
 }
开发者ID:amcfarlane1251,项目名称:lcnsMgmt,代码行数:26,代码来源:Asset.php

示例9: assetName

 public function assetName($data)
 {
     $asset = Asset::find($data['assetId']);
     if ($asset) {
         return '<a href="' . URL::to('asset/detail/' . $data['assetId']) . '" >' . $asset->SKU . '</a>';
     } else {
         return '-';
     }
 }
开发者ID:awidarto,项目名称:bilnatracker,代码行数:9,代码来源:CsController.php

示例10: function

     Route::put('themes/{id}', ['uses' => 'core\\controllers\\AdminController@updateTheme']);
     Route::get('themes/{id}/edit', ['uses' => 'core\\controllers\\AdminController@editTheme']);
 });
 // --------------------------------------------------------------------------
 // Assets
 // --------------------------------------------------------------------------
 Route::group(['prefix' => 'images'], function () {
     Route::get('/', ['uses' => 'core\\controllers\\AssetsController@index']);
     Route::get('{id}/{size?}', ['uses' => 'core\\controllers\\AssetsController@resize']);
 });
 // ------------------------------------------------------------------------
 Route::get('assets/upload/modal', function () {
     return View::make('slate::admin.assets.upload-modal');
 });
 Route::get('assets/{id}/edit', function ($id) {
     return View::make('slate::admin.assets.edit-modal', ['asset' => Asset::find($id)]);
 });
 Route::post('assets/upload', ['uses' => 'core\\controllers\\AssetsController@upload']);
 Route::put('assets/{id}', ['uses' => 'core\\controllers\\AssetsController@edit']);
 // --------------------------------------------------------------------------
 // Home
 // --------------------------------------------------------------------------
 Route::get('/', function () {
     return View::make('slate::site.index');
 });
 // --------------------------------------------------------------------------
 // Register | Login
 // --------------------------------------------------------------------------
 Route::get('register', ['uses' => 'core\\controllers\\UsersController@register']);
 Route::get('login', ['uses' => 'core\\controllers\\UsersController@login']);
 // --------------------------------------------------------------------------
开发者ID:vanderlin,项目名称:Gear2,代码行数:31,代码来源:routes.php

示例11: postEdit

 /**
  * postEdit
  *
  * @param null $assetMaintenanceId
  *
  * @return mixed
  * @author  Vincent Sposato <vincent.sposato@gmail.com>
  * @version v1.0
  */
 public function postEdit($assetMaintenanceId = null)
 {
     // get the POST data
     $new = Input::all();
     // Check if the asset maintenance exists
     if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
         // Redirect to the asset maintenance management page
         return Redirect::to('admin/asset_maintenances')->with('error', Lang::get('admin/asset_maintenances/message.not_found'));
     } else {
         if (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
             return static::getInsufficientPermissionsRedirect();
         }
     }
     // attempt validation
     if ($assetMaintenance->validate($new)) {
         if (e(Input::get('supplier_id')) == '') {
             $assetMaintenance->supplier_id = null;
         } else {
             $assetMaintenance->supplier_id = e(Input::get('supplier_id'));
         }
         if (e(Input::get('is_warranty')) == '') {
             $assetMaintenance->is_warranty = 0;
         } else {
             $assetMaintenance->is_warranty = e(Input::get('is_warranty'));
         }
         if (e(Input::get('cost')) == '') {
             $assetMaintenance->cost = '';
         } else {
             $assetMaintenance->cost = ParseFloat(e(Input::get('cost')));
         }
         if (e(Input::get('notes')) == '') {
             $assetMaintenance->notes = null;
         } else {
             $assetMaintenance->notes = e(Input::get('notes'));
         }
         $asset = Asset::find(e(Input::get('asset_id')));
         if (!Company::isCurrentUserHasAccess($asset)) {
             return static::getInsufficientPermissionsRedirect();
         }
         // Save the asset maintenance data
         $assetMaintenance->asset_id = e(Input::get('asset_id'));
         $assetMaintenance->asset_maintenance_type = e(Input::get('asset_maintenance_type'));
         $assetMaintenance->title = e(Input::get('title'));
         $assetMaintenance->start_date = e(Input::get('start_date'));
         $assetMaintenance->completion_date = e(Input::get('completion_date'));
         if ($assetMaintenance->completion_date == "" || $assetMaintenance->completion_date == "0000-00-00") {
             $assetMaintenance->completion_date = null;
             if ($assetMaintenance->asset_maintenance_time !== 0 || !is_null($assetMaintenance->asset_maintenance_time)) {
                 $assetMaintenance->asset_maintenance_time = null;
             }
         }
         if ($assetMaintenance->completion_date !== "" && $assetMaintenance->completion_date !== "0000-00-00" && $assetMaintenance->start_date !== "" && $assetMaintenance->start_date !== "0000-00-00") {
             $startDate = Carbon::parse($assetMaintenance->start_date);
             $completionDate = Carbon::parse($assetMaintenance->completion_date);
             $assetMaintenance->asset_maintenance_time = $completionDate->diffInDays($startDate);
         }
         // Was the asset maintenance created?
         if ($assetMaintenance->save()) {
             // Redirect to the new asset maintenance page
             return Redirect::to("admin/asset_maintenances")->with('success', Lang::get('admin/asset_maintenances/message.create.success'));
         }
     } else {
         // failure
         $errors = $assetMaintenance->errors();
         return Redirect::back()->withInput()->withErrors($errors);
     }
     // Redirect to the improvement create page
     return Redirect::to('admin/asset_maintenances/edit')->with('error', Lang::get('admin/asset_maintenances/message.create.error'))->with('assetMaintenance', $assetMaintenance);
 }
开发者ID:spOmes,项目名称:snipe-it,代码行数:78,代码来源:AssetMaintenancesController.php

示例12: destroy

 public function destroy($id)
 {
     try {
         //get the asset to be deleted
         $deleteAsset = Asset::find($id);
         //soft delete the asset
         $deleteAsset->active = 0;
         $deleteAsset->save();
         //return the deleted asset
         return $deleteAsset->toJSON();
     } catch (Exception $e) {
         return json_encode('{"error":{"text":' . $e->getMessage() . '}}');
     }
 }
开发者ID:p-tricky,项目名称:CAEWeb,代码行数:14,代码来源:AssetManagementApiController.php

示例13: function

    // ------------------------------------------------------------------------
    // Users Roles & Permissions CMS
    // ------------------------------------------------------------------------
    Route::get('users', function () {
        return View::make('admin.index', ['users' => User::orderBy('created_at', 'DESC')->paginate(12), 'active_link' => 'users']);
    });
    Route::get('users/{id}', function ($id) {
        return View::make('admin.edituser', ['user' => User::find($id), 'active_link' => 'users']);
    });
    // edit a profile (*** ADMIN ONLY ***)
    Route::get('users/{id}/roles/edit', function ($id) {
        $user = User::find($id);
        if (Auth::user()->hasRole('Admin')) {
            return View::make('admin.roles.edit-user-roles', ['user' => $user, 'active_link' => 'index']);
        }
        return 'You do not have permissions to do this...';
    });
    Route::resource('roles', 'RolesController');
    Route::resource('permissions', 'PermissionsController');
    Route::put('users/{id}', ['uses' => 'UsersController@editUserRoles']);
    // admin only (master)
    Route::get('assets', function () {
        return View::make('admin.assets.index');
    });
    Route::get('assets/upload', function () {
        return View::make('admin.assets.upload-popup');
    });
    Route::get('assets/{id}/edit', function ($id) {
        return View::make('admin.assets.edit-popup', ['asset' => Asset::find($id)]);
    });
});
开发者ID:vanderlin,项目名称:halp,代码行数:31,代码来源:admin_routes.php


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