本文整理汇总了PHP中Modules::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Modules::where方法的具体用法?PHP Modules::where怎么用?PHP Modules::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Modules
的用法示例。
在下文中一共展示了Modules::where方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showPermission
function showPermission($id)
{
$this->data['status'] = Session::has("status") ? Session::get("status") : FALSE;
$this->data['message'] = Session::has("message") ? Session::get("message") : "";
$this->data['id'] = $id;
// GET ALL PERMISSION
$permissions = Permission::where('group_id', $id)->get()->toArray();
$permissionMap = array();
// GET ALL MODULE
$moduleData = Modules::where('group_id', $id)->get()->toArray();
if (!empty($permissions)) {
foreach ($permissions as $permission) {
$permissionMap[$permission['module_id']][] = $permission;
}
}
if (!empty($moduleData)) {
$moduleData = array_column($moduleData, 'name', 'id');
}
// GET USER PERMISSION
$groupPermissions = Sentry::findGroupById($id)->getPermissions();
$this->data['permissionMap'] = $permissionMap;
$this->data['moduleData'] = $moduleData;
$this->data['groupPermissions'] = $groupPermissions;
if (Request::isMethod('post')) {
$this->postPermission($id, $this->data);
if ($this->data['status'] === TRUE) {
return Redirect::to($this->moduleURL . 'permission/' . $this->data['id']);
}
}
$this->layout->content = View::make('showPermission', $this->data);
}
示例2: postModuleChange
public function postModuleChange()
{
$inputData = Input::get('modData');
parse_str($inputData, $formFields);
$moduleData = array('mfulltitle' => $formFields['mname'], 'mshorttitle' => $formFields['mshorttitle'], 'mdescription' => $formFields['mdescription'], 'mcode' => $formFields['mcode'], 'mfieldofstudy' => $formFields['mfieldofstudy'], 'mcoordinator' => $formFields['mcoordinator'], 'mlevel' => $formFields['mlevel'], 'mcredits' => $formFields['mcredits'], 'mid' => $formFields['mid'], 'departmentid' => Auth::user()->department);
Validator::extend('ranked', function ($attribute, $value, $parameters) {
$coord = User::where('name', $value)->first();
if ($coord && $coord->rank < 1) {
return false;
}
return true;
});
$rules = array('mfulltitle' => 'required|max:50|unique:modules,mfulltitle,' . $formFields['mcode'] . ',mcode', 'mshorttitle' => 'required|max:50|unique:modules,mshorttitle,' . $formFields['mcode'] . ',mcode', 'mdescription' => 'required|min:30', 'mcode' => 'required|min:7|max:8|alpha_num|unique:modules,mcode,' . $formFields['mcode'] . ',mcode', 'mfieldofstudy' => 'required|max:100', 'mcoordinator' => 'required|exists:users,name|ranked', 'mlevel' => 'required|in:Fundamental,Intermediate,Advanced,Expert', 'mcredits' => 'required|integer|between:5,25', 'mid' => 'required|exists:modules,mid', 'departmentid' => 'required');
$messages = ['ranked' => "This user can't coordinate this class."];
$validator = Validator::make($moduleData, $rules, $messages);
if ($validator->fails()) {
return Response::json(array('fail' => true, 'errors' => $validator->getMessageBag()->toArray()));
} else {
$mod = Modules::where('mid', $moduleData['mid'])->first();
$mod->mfulltitle = $moduleData['mfulltitle'];
$mod->mshorttitle = $moduleData['mshorttitle'];
$mod->mdescription = $moduleData['mdescription'];
$mod->mcode = $moduleData['mcode'];
$mod->mfieldofstudy = $moduleData['mfieldofstudy'];
$mod->mcoordinator = $moduleData['mcoordinator'];
$mod->mlevel = $moduleData['mlevel'];
$mod->mcredits = $moduleData['mcredits'];
$mod->departmentid = $moduleData['departmentid'];
if ($mod->save()) {
Session::flash('global', 'You have edited the module "' . $moduleData['mfulltitle'] . '".');
//return success message
return Response::json(array('success' => true, 'mName' => $moduleData['mfulltitle']));
}
}
}
示例3: updateModule
/**
* Function that updates a module
*/
protected function updateModule($mid, $d, $expected)
{
$data = '';
foreach ($d as $key => $value) {
$data = $data . $key . '=' . $value . '&';
}
$response = $this->call('POST', '/module-change', ['modData' => $data]);
$json = json_decode($response->getContent());
if ($expected) {
$this->assertEquals(true, $json->success);
// Get the module we just updated.
$m = Modules::where('mid', $mid)->first();
// Verify that the change was made.
$this->assertEquals('name12345', $m->mfulltitle);
// Now return the module.
return $m;
} else {
$this->assertEquals(true, $json->fail);
}
}
示例4:
<div class="col-sm-6 col-md-4 myclass{{ $elec->electiveId }}">
<div class="feature-box">
<div class="feature-icon"><i class="fa fa-twitter"></i></div>
<div class="feature-text">
<?php
$mod = Modules::where('mid', $elec->electiveId)->first();
?>
<h3>{{$mod->mshorttitle}}</h3>
<small style="float:right"><u>{{$mod->mcredits}} Credits</u></small>
<p>{{User::find(Classes::find($elec->classId)->classlecturer)->name}}</p>
</br>
</div>
<form class="electiveUnregister">
<input type="hidden" id="electiveId" value="{{ $mod->mid }}" />
<button type="submit" class="pull-left btn-elec btn-primary"><i class="fa fa-arrow-right"></i>remove elective</button>
</form>
<button type="button" id="checkTime" onclick="loadTime({{$elec->classId}})" class="ascensorLink ascensorLink3 pull-right btn-elec btn-primary"><i class="fa fa-arrow-right"></i>check timetable</button>
</div>
</div>
示例5: render
function render()
{
$listModuleFile = array();
$listIgnores = array('.', '..', '.DS_Store', '.svn');
$primaryArray = array('Create', 'Read', 'Edit', 'Delete');
$listFiles = array_diff(scandir($this->modulePath), $listIgnores);
// GET LIST FILE IN FOLDER
if (!empty($listFiles)) {
foreach ($listFiles as $file) {
$fileName = ucwords(str_replace("_", " ", $file));
$fileSlug = str_replace("_", "-", $file);
$listModuleFile[$fileSlug] = $fileName;
}
}
// GET LIST FILE IN DATABASE
$listModuleStore = Modules::get()->toArray();
$listModuleStore = array_column($listModuleStore, 'name', 'slug');
// NEW MODULE
$diffInsert = array_diff($listModuleFile, $listModuleStore);
$insertData = array();
if (!empty($diffInsert)) {
foreach ($diffInsert as $k => $v) {
$mA = explode("-", $k);
$suffix = last($mA);
if ($suffix == 'manager') {
$count = count($mA);
$preSuffix = $mA[$count - 2];
$suffix = $preSuffix . "_" . $suffix;
}
$groupString = "group_" . $suffix . "_id";
$group = 0;
if (Config::has("backend.{$groupString}")) {
$group = Config::get("backend.{$groupString}");
}
$insertData = array('slug' => $k, 'name' => $v, 'group_id' => $group, 'status' => 1);
if ($item = Modules::create($insertData)) {
if ($item->save()) {
// // Insert Menu
// $menuInsert = array(
// 'status' => 0,
// 'name' => $item->name,
// 'module_id' => $item->id,
// 'slug' => $item->slug.'/show-list',
// );
// Menus::create($menuInsert);
// Create Primary Permission
foreach ($primaryArray as $p) {
$primaryInsert = array('name' => $item->name . " " . $p, 'slug' => $item->slug . "-" . strtolower($p), 'module_id' => $item->id, 'group_id' => $group, 'action' => strtolower($p));
Permission::create($primaryInsert);
}
}
}
}
}
// REMOVE MODULE
$diffRemove = array_diff($listModuleStore, $listModuleFile);
if (!empty($diffRemove)) {
foreach ($diffRemove as $k => $v) {
$item = Modules::where(array('slug' => $k, 'name' => $v))->first();
$deleteID = $item->id;
if ($item->delete()) {
// Menus::where('module_id', $deleteID)->delete();
Permission::where('module_id', $deleteID)->delete();
}
}
}
}
示例6: printClassList
function printClassList($classId)
{
if (Classes::where('classid', $classId)->count()) {
$class = Classes::where('classid', $classId)->first();
if ($class->classlecturer != Auth::user()->id) {
return;
}
$filename = Modules::where('mid', $class->classmodule)->first()->mcode . "Elec" . $classId . "List.csv";
$delimiter = ",";
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $filename . '";');
$array = array();
array_push($array, array('Student ID' => 'Student ID', 'Name' => 'Student Name'));
foreach (json_decode($class->classstudents) as $student) {
$studentarray = array('Student Id' => User::find($student)->username, 'Name' => User::find($student)->name);
array_push($array, $studentarray);
}
$f = fopen('php://output', 'w');
foreach ($array as $line) {
fputcsv($f, $line, $delimiter);
}
}
}
示例7:
<?php
// Get the module.
$mod = Modules::where('mid', $elec->classmodule)->first();
?>
<div class="mix {{ $mod->department->faculty->short() }} {{ $mod->department->short() }} col-sm-4 col-xs-6">
<a data-toggle="modal" role="button" href="#{{$mod->mcode}}">
<div class="feature-box">
<div class="department">
<div class="department-box">
<span>{{ $mod->mshorttitle }}</span>
</div>
</div>
</div>
</a>
<div class="modal fade" id="{{$mod->mcode}}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 class="h3 modal-title">{{ $mod->mfulltitle }}</h3>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="modal-entery">
<p>{{ $mod->mdescription }}</p>
<h4 class="h4">Lecturer</h4>
{{ $mod->mcoordinator }}
<h4 class="h4">Field of Study</h4>
示例8: render
function render()
{
$listModuleFile = array();
$listIgnores = array('dashboard', 'home', 'chat', 'search', '.', '..', '.DS_Store', '.svn');
$primaryArray = array('Create', 'Read', 'Edit', 'Delete');
$listFiles = array_diff(scandir($this->modulePath), $listIgnores);
// GET LIST FILE IN FOLDER
if (!empty($listFiles)) {
foreach ($listFiles as $file) {
$file = str_replace("_backend", "", $file);
$fileName = ucwords(str_replace("_", " ", $file));
$fileSlug = str_replace("_", "-", $file);
$listModuleFile[$fileSlug] = $fileName;
}
}
// GET LIST FILE IN DATABASE
$listModuleStore = Modules::get()->toArray();
$listModuleStore = array_column($listModuleStore, 'name', 'slug');
// NEW MODULE
$diffInsert = array_diff($listModuleFile, $listModuleStore);
$insertData = array();
if (!empty($diffInsert)) {
foreach ($diffInsert as $k => $v) {
$insertData = array('slug' => $k, 'name' => $v, 'status' => 1);
if ($item = Modules::create($insertData)) {
if ($item->save()) {
// Insert Menu
$menuInsert = array('status' => 0, 'name' => $item->name, 'module_id' => $item->id, 'slug' => $item->slug . '/show-list');
Menus::create($menuInsert);
// Create Primary Permission
foreach ($primaryArray as $p) {
$primaryInsert = array('name' => $item->name . " " . $p, 'slug' => $item->slug . "-" . strtolower($p), 'module_id' => $item->id, 'action' => strtolower($p));
Permission::create($primaryInsert);
}
}
}
}
}
// REMOVE MODULE
$diffRemove = array_diff($listModuleStore, $listModuleFile);
if (!empty($diffRemove)) {
foreach ($diffRemove as $k => $v) {
$item = Modules::where(array('slug' => $k, 'name' => $v))->first();
$deleteID = $item->id;
if ($item->delete()) {
Menus::where('module_id', $deleteID)->delete();
Permission::where('module_id', $deleteID)->delete();
}
}
}
}
示例9: date
$year = date('Y', strtotime(date("Y-m-d", time()) . " + 365 day"));
$semester = date('Y-m-d', strtotime($year . '-01-01'));
}
$class = null;
?>
<select id="class-Select" class="form-control">
<?php
foreach (Classes::where('classlecturer', Auth::user()->id)->get() as $c) {
// Check if this class belongs to this year.
if (date('Y', strtotime($c->created)) === date('Y', strtotime($today))) {
// Now check that it is part of this semester.
if (date('Y-m-d', strtotime($c->created)) < $semester) {
if (!isset($class)) {
$class = $c;
}
$elective = Modules::where('mid', $c->classmodule)->first();
?>
<option value="{{ $c->classid }}">{{ $elective->mshorttitle }}</option>
<?php
}
}
}
?>
</select>
<br>
<form action="" method="POST" id="classForm">
<label>Space Limit:</label><input type="text" class="form-control" id="classlimit" placeholder="Class Space Limit" value="{{ $class->classlimit }}" />
<label>Space Left:</label><input type="text" class="form-control" id="classleft" placeholder="Space Left in Class" value="{{ ($class->classlimit - $class->classcurrent) }}" disabled/>
<input type="hidden" id="classId" value="{{ $class->classid }}"/>
<div style="margin-top:10px">
<button type="submit" class="btn btn-info pink">Update Class</button>