本文整理汇总了PHP中Asset::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset::where方法的具体用法?PHP Asset::where怎么用?PHP Asset::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset::where方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
// create default user asset
$asset = Asset::where('filename', '=', 'default.png')->first();
if ($asset == NULL) {
$asset = new Asset();
$asset->filename = 'default.png';
$asset->path = 'assets/content/users';
$asset->save();
}
$admin = Role::where('name', '=', 'Admin')->first();
// create default roles
if ($admin == NULL) {
$admin = new Role();
$admin->name = 'Admin';
$admin->save();
}
$adminUser = User::where('username', '=', 'admin')->first();
if ($adminUser != NULL) {
echo "Admin User Already Exsit";
} else {
$adminUser = new User();
$adminUser->username = 'admin';
$adminUser->email = 'admin@admin.com';
$adminUser->password = 'admin';
$adminUser->password_confirmation = 'admin';
$adminUser->confirmation_code = md5(uniqid(mt_rand(), true));
if ($adminUser->save()) {
$adminUser->attachRole($admin);
echo "Admin User Created";
}
}
}
示例2: getExpiringWarrantee
public static function getExpiringWarrantee($days = 30)
{
return Asset::where('archived', '=', '0')->whereNotNull('warranty_months')->whereNotNull('purchase_date')->whereNull('deleted_at')->whereRaw(DB::raw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL ' . $days . ' DAY) AND DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) > NOW()'))->orderBy('purchase_date', 'ASC')->get();
}
示例3: officeAssetsReports
public function officeAssetsReports()
{
if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin" || Session::get("user_type") == "User")) {
$view = View::make("Reports.office_assets_reports");
$view->nav = "system";
$view->tab = "office";
$totalOfficeAssets = Asset::whereHas("classification", function ($q) {
$q->where("type", "=", "Office");
})->get()->count();
//Summary
$printers = Asset::whereHas("classification", function ($q) {
$q->where("name", "=", "Printers");
})->get()->count();
$projectors = Asset::whereHas("classification", function ($q) {
$q->where("name", "=", "Projectors");
})->get()->count();
$otherAssets = Asset::whereHas("classification", function ($q) {
$q->where("name", "=", "Other Assets");
})->get()->count();
if ($totalOfficeAssets > 0) {
$printersPercentage = $printers > 0 ? $printers / $totalOfficeAssets * 100 : "0.00";
$projectorsPercentage = $projectors > 0 ? $projectors / $totalOfficeAssets * 100 : "0.00";
$otherAssetsPercentage = $otherAssets > 0 ? $otherAssets / $totalOfficeAssets * 100 : "0.00";
} else {
$printersPercentage = "0.00";
$projectorsPercentage = "0.00";
$otherAssetsPercentage = "0.00";
}
$view->totalOfficeAssets = $totalOfficeAssets;
$view->printers = $printers;
$view->projectors = $projectors;
$view->otherAssets = $otherAssets;
$view->printersPercentage = $printersPercentage;
$view->projectorsPercentage = $projectorsPercentage;
$view->otherAssetsPercentage = $otherAssetsPercentage;
//Status
//Printer Status
$p_available = Asset::where("status", "=", "Available")->whereHas("classification", function ($q) {
$q->where("name", "=", "Printers");
})->count();
$p_for_repair = Asset::where("status", "=", "For Repair")->whereHas("classification", function ($q) {
$q->where("name", "=", "Printers");
})->count();
$p_installed = Asset::where("status", "=", "Installed")->whereHas("classification", function ($q) {
$q->where("name", "=", "Printers");
})->count();
$p_lost = Asset::where("status", "=", "Lost")->whereHas("classification", function ($q) {
$q->where("name", "=", "Printers");
})->count();
$p_retired = Asset::where("status", "=", "Retired")->whereHas("classification", function ($q) {
$q->where("name", "=", "Printers");
})->count();
$view->p_available = $p_available;
$view->p_for_repair = $p_for_repair;
$view->p_installed = $p_installed;
$view->p_lost = $p_lost;
$view->p_retired = $p_retired;
//Projector Status
$pro_available = Asset::where("status", "=", "Available")->whereHas("classification", function ($q) {
$q->where("name", "=", "Projectors");
})->count();
$pro_for_repair = Asset::where("status", "=", "For Repair")->whereHas("classification", function ($q) {
$q->where("name", "=", "Projectors");
})->count();
$pro_installed = Asset::where("status", "=", "Installed")->whereHas("classification", function ($q) {
$q->where("name", "=", "Projectors");
})->count();
$pro_lost = Asset::where("status", "=", "Lost")->whereHas("classification", function ($q) {
$q->where("name", "=", "Projectors");
})->count();
$pro_retired = Asset::where("status", "=", "Retired")->whereHas("classification", function ($q) {
$q->where("name", "=", "Projectors");
})->count();
$view->pro_available = $pro_available;
$view->pro_for_repair = $pro_for_repair;
$view->pro_installed = $pro_installed;
$view->pro_lost = $pro_lost;
$view->pro_retired = $pro_retired;
//Other Assets Status
$o_available = Asset::where("status", "=", "Available")->whereHas("classification", function ($q) {
$q->where("name", "=", "Other Assets");
})->count();
$o_for_repair = Asset::where("status", "=", "For Repair")->whereHas("classification", function ($q) {
$q->where("name", "=", "Other Assets");
})->count();
$o_installed = Asset::where("status", "=", "Installed")->whereHas("classification", function ($q) {
$q->where("name", "=", "Other Assets");
})->count();
$o_lost = Asset::where("status", "=", "Lost")->whereHas("classification", function ($q) {
$q->where("name", "=", "Other Assets");
})->count();
$o_retired = Asset::where("status", "=", "Retired")->whereHas("classification", function ($q) {
$q->where("name", "=", "Other Assets");
})->count();
$view->o_available = $o_available;
$view->o_for_repair = $o_for_repair;
$view->o_installed = $o_installed;
$view->o_lost = $o_lost;
$view->o_retired = $o_retired;
return $view;
//.........这里部分代码省略.........
示例4: function
// $em = Employee::has("manager")->get();
// echo $em->manager->first()->id;
// echo $em->count();
// foreach($em as $e){
// echo $e->manager->first_name;
// }
// $employees = Employee::paginate(10);
// foreach($employees as $e){
// //KEEP IN MIND TO CHECK IF NULL. BECAUSE IF IT IS, IT WILL RETURN A FUCKING ERROR YOU SANOVA BITCH
// if(!empty($e->manager->first_name))
// echo $e->manager->first_name."<br/>";
// else
// echo "null biiiitch<br/>";
// }
$key = "4";
$asset = Asset::where("serial_number", "LIKE", "{$key}")->orWhere("id", "=", $key)->orWhereHas("employee", function ($q) use($key) {
$q->where("last_name", "LIKE", "%{$key}%");
})->get();
foreach ($asset as $a) {
echo $a->employee->last_name . "<br/>";
}
});
Route::get("dummy4", function () {
// $logs = UserLog::whereBetween("datetime",array("2014-12-01","2014-12-02"." 23:59:59.000000"))->get();
// foreach($logs as $l){
// echo $l->datetime."<br/>";
// }
// $g1 = Asset::whereHas("classification",function($query){
// $query->where("name","=","Laptops");
// })
// ->whereHas("model",function($query){
示例5: processImport
//.........这里部分代码省略.........
}
}
if ($validator->messages()->get("laptop serial number")) {
foreach ($validator->messages()->get("laptop serial number") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("software type")) {
foreach ($validator->messages()->get("software type") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("warranty start date")) {
foreach ($validator->messages()->get("warranty start date") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("warranty end date")) {
foreach ($validator->messages()->get("warranty end date") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("status")) {
foreach ($validator->messages()->get("status") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
}
if ($r->status != "Lost" && Employee::where("employee_number", "=", $r->employeenumber)->whereIn("status", array("OJT Graduate", "Graduate", "Resigned", "Obsolete"))->first()) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "Cannot assign an asset to employees no longer working in the company." . "<br/>";
}
if (trim($r->laptopsn) != null && !Asset::where("serial_number", "=", $r->laptopsn)->whereHas("classification", function ($q) {
$q->where("name", "=", "Laptops");
})->first()) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "Cannot assign software asset to non-laptop assets. Please check the serial number and try again." . "<br/>";
}
if (!$rowHasError) {
$hasCorrectRows = true;
$software_type_id = SoftwareType::where("software_type", "=", $r->softwaretype)->get(array("id"))->first();
//Create the asset
$software = new Software();
$software->asset_tag = trim($r->assettag) != null ? trim($r->assettag) : null;
$software->product_key = trim($r->productkey);
$software->employee_number = trim($r->employeenumber) != null ? trim($r->employeenumber) : null;
$software->assigned_to_serial_number = trim($r->laptopsn) != null ? trim($r->laptopsn) : null;
$software->location = trim($r->location) != null ? trim($r->location) : null;
$software->software_type_id = $software_type_id->id;
示例6: deleteAssets
public function deleteAssets()
{
if (Session::has('username') && Session::get('user_type') == "Root") {
$assets = Input::get("asset_id");
$hasDeletedAny = false;
$noOfDeletedAssets = 0;
foreach ($assets as $a) {
$asset = Asset::where("id", "=", $a)->whereHas("classification", function ($query) {
$query->where("type", "=", "Network");
})->first();
if (!$asset) {
continue;
}
$desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted network asset ( type: " . $asset->classification->name . ") <strong>" . $asset->asset_tag . "</strong>, SN: <strong>" . $asset->serial_number . "</strong>.";
//Log the changes made
$newLog = new UserLog();
$newLog->description = $desc;
$newLog->user_id = Session::get('user_id');
$newLog->type = "System";
$newLog->save();
$hasDeletedAny = true;
$noOfDeletedAssets += 1;
$asset->delete();
}
if ($hasDeletedAny) {
$desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> has deleted <strong>" . $noOfDeletedAssets . "</strong> network asset(s).";
//Log the changes made
$newLog = new UserLog();
$newLog->description = $desc;
$newLog->user_id = Session::get('user_id');
$newLog->type = "System";
$newLog->save();
}
return Redirect::to(Session::get("page"));
} else {
return Redirect::to("/");
}
}
示例7: update
function update()
{
$this->filter_access('Assets', 'roled_edit', 'assets/index');
$asset = new Asset();
$asset->where('asset_id', $this->input->post('id'))->update(array('asset_name' => $this->input->post('asset_name'), 'asset_status' => $this->input->post('asset_status'), 'staff_id' => $this->input->post('staff_id'), 'date' => $this->input->post('date')));
$this->session->set_flashdata('message', 'Asset Update successfuly.');
redirect('assets/');
}
示例8: fire
//.........这里部分代码省略.........
$user_email_array = User::generateFormattedNameFromFullName($this->option('email_format'), $user_name);
$first_name = $user_email_array['first_name'];
$last_name = $user_email_array['last_name'];
if ($user_email == '') {
$user_email = $user_email_array['username'] . '@' . Config::get('app.domain');
}
if ($user_username == '') {
if ($this->option('username_format') == 'email') {
$user_username = $user_email;
} else {
$user_name_array = User::generateFormattedNameFromFullName($this->option('username_format'), $user_name);
$user_username = $user_name_array['username'];
}
}
}
$this->comment('Full Name: ' . $user_name);
$this->comment('First Name: ' . $first_name);
$this->comment('Last Name: ' . $last_name);
$this->comment('Username: ' . $user_username);
$this->comment('Email: ' . $user_email);
$this->comment('Category Name: ' . $user_asset_category);
$this->comment('Item: ' . $user_asset_name);
$this->comment('Manufacturer ID: ' . $user_asset_mfgr);
$this->comment('Model No: ' . $user_asset_modelno);
$this->comment('Serial No: ' . $user_asset_serial);
$this->comment('Asset Tag: ' . $user_asset_tag);
$this->comment('Location: ' . $user_asset_location);
$this->comment('Purchase Date: ' . $user_asset_purchase_date);
$this->comment('Purchase Cost: ' . $user_asset_purchase_cost);
$this->comment('Notes: ' . $user_asset_notes);
$this->comment('Company Name: ' . $user_asset_company_name);
$this->comment('------------- Action Summary ----------------');
if ($user_username != '') {
if ($user = User::MatchEmailOrUsername($user_username, $user_email)->whereNotNull('username')->first()) {
$this->comment('User ' . $user_username . ' already exists');
} else {
// Create the user
$user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'username' => $user_username, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 12), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'User imported through asset importer'));
// Find the group using the group id
$userGroup = Sentry::findGroupById(3);
// Assign the group to the user
$user->addGroup($userGroup);
$this->comment('User ' . $first_name . ' created');
}
} else {
$user = new User();
}
// Check for the location match and create it if it doesn't exist
if ($location = Location::where('name', e($user_asset_location))->first()) {
$this->comment('Location ' . $user_asset_location . ' already exists');
} else {
$location = new Location();
if ($user_asset_location != '') {
$location->name = e($user_asset_location);
$location->address = '';
$location->city = '';
$location->state = '';
$location->country = '';
$location->user_id = 1;
if (!$this->option('testrun') == 'true') {
if ($location->save()) {
$this->comment('Location ' . $user_asset_location . ' was created');
} else {
$this->comment('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
}
} else {
示例9: exportOfficeBegin
public function exportOfficeBegin()
{
if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) {
if (isset($_GET["search"])) {
$view = View::make("Export.export_office");
$view->nav = "system";
$view->tab = "office";
$input = Input::all();
$asset_tag = trim($input["asset_tag"]) != null ? str_replace(' ', '%', trim($input["asset_tag"])) : "";
$serial_number = trim($input["serial_number"]) != null ? str_replace(' ', '%', trim($input["serial_number"])) : "";
$employee = trim($input["employee"]) != null ? trim($input["employee"]) : "";
$classification_id = trim($input["classification_id"]) != null ? str_replace(' ', '%', trim($input["classification_id"])) : "";
$asset_status = !empty($input["asset_status"]) ? $input["asset_status"] : "";
$model = !empty($input["model"]) ? $input["model"] : "";
$warranty_start = trim($input["warranty_start"]) != null ? str_replace(' ', '%', trim($input["warranty_start"])) : "";
$warranty_end = trim($input["warranty_end"]) != null ? str_replace(' ', '%', trim($input["warranty_end"])) : "";
$assets = Asset::where("asset_tag", "LIKE", "%{$asset_tag}%")->whereHas("classification", function ($query) {
$query->where("type", "=", "Office");
})->where(function ($query) use($serial_number) {
if (!empty($serial_number)) {
$query->where("serial_number", "LIKE", $serial_number);
}
})->where(function ($query) use($employee) {
$emp = "%" . str_replace(' ', '%', $employee) . "%";
$emp = DB::connection()->getPdo()->quote($emp);
if (!empty($employee)) {
$query->where("employee_number", "LIKE", $employee)->orWhereHas("employee", function ($q) use($employee, $emp) {
$q->whereRaw("concat(first_name,' ',last_name) LIKE {$emp}");
})->orWhereHas("employee", function ($q) use($employee, $emp) {
$q->whereRaw("concat(last_name,' ',first_name) LIKE {$emp}");
});
}
})->where(function ($query) use($classification_id) {
if (!empty($classification_id)) {
$query->where("classification_id", "LIKE", "{$classification_id}");
}
})->where(function ($query) use($asset_status) {
if (!empty($asset_status)) {
$query->where("status", "=", "{$asset_status}");
}
})->where(function ($query) use($model) {
if (!empty($model)) {
$query->where("model_id", "=", $model);
}
})->where(function ($query) use($warranty_start) {
if (!empty($warranty_start)) {
$query->where("warranty_start", "LIKE", "{$warranty_start}%");
}
})->where(function ($query) use($warranty_end) {
if (!empty($warranty_end)) {
$query->where("warranty_end", "LIKE", "{$warranty_end}%");
}
})->orderBy("asset_tag", "asc")->paginate(25);
$results = Asset::where("asset_tag", "LIKE", "%{$asset_tag}%")->whereHas("classification", function ($query) {
$query->where("type", "=", "Office");
})->where(function ($query) use($serial_number) {
if (!empty($serial_number)) {
$query->where("serial_number", "LIKE", $serial_number);
}
})->where(function ($query) use($employee) {
$emp = "%" . str_replace(' ', '%', $employee) . "%";
$emp = DB::connection()->getPdo()->quote($emp);
if (!empty($employee)) {
$query->where("employee_number", "LIKE", $employee)->orWhereHas("employee", function ($q) use($employee, $emp) {
$q->whereRaw("concat(first_name,' ',last_name) LIKE {$emp}");
})->orWhereHas("employee", function ($q) use($employee, $emp) {
$q->whereRaw("concat(last_name,' ',first_name) LIKE {$emp}");
});
}
})->where(function ($query) use($classification_id) {
if (!empty($classification_id)) {
$query->where("classification_id", "LIKE", "{$classification_id}");
}
})->where(function ($query) use($asset_status) {
if (!empty($asset_status)) {
$query->where("status", "=", "{$asset_status}");
}
})->where(function ($query) use($model) {
if (!empty($model)) {
$query->where("model_id", "=", $model);
}
})->where(function ($query) use($warranty_start) {
if (!empty($warranty_start)) {
$query->where("warranty_start", "LIKE", "{$warranty_start}%");
}
})->where(function ($query) use($warranty_end) {
if (!empty($warranty_end)) {
$query->where("warranty_end", "LIKE", "{$warranty_end}%");
}
})->count();
$getAssetClassifications = AssetClassification::where("type", "=", "Office")->get();
$assetClassifications = array("" => "All");
foreach ($getAssetClassifications as $gac) {
$assetClassifications[$gac->id] = $gac->name;
}
$getAssetModels = Model::whereHas('classification', function ($query) {
$query->where("type", "=", "Office");
})->orderBy("name", "asc")->get();
$assetModels = array("" => "--Select One--");
foreach ($getAssetModels as $gam) {
//.........这里部分代码省略.........
示例10: validateData
public function validateData($items)
{
$assetnames = array();
foreach ($items as $item) {
$assetnames[] = strval($item['SKU']);
}
$namecount = array_count_values($assetnames);
$dbval = array();
foreach ($items as $item) {
$dbval[$item['SKU']] = Asset::where('SKU', $item['SKU'])->count();
}
return array('in' => $namecount, 'db' => $dbval);
}
示例11: ExtractAdAsset
public static function ExtractAdAsset($merchant_id, $selection = true)
{
$category = Asset::where('merchantId', $merchant_id)->get()->toArray();
if ($selection) {
$cats = array('' => 'All');
} else {
$cats = array();
}
if (count($category) > 0) {
foreach ($category as $cat) {
$cats[$cat['_id']] = $cat['itemDescription'];
}
}
return $cats;
}
示例12: findAsset
public function findAsset()
{
//input from Backbone
$queryParams = Input::get('queryParams');
$foundAsset = Asset::where('serial_number', '=', $queryParams['serial_number'])->where('asset_type', '=', $queryParams['asset_type'])->get();
//if found, returns the object, else it returns false
return Response::json($foundAsset);
}