public function placeObject(Level $level, Vector3 $pos, Random $random) { if ($this->leavesBottomY === -1 or $this->leavesMaxRadius === -1) { $this->findRandomLeavesSize(); } $level->setBlockRaw(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock()); $leavesRadius = 0; for ($yy = $this->totalHeight; $yy >= $this->leavesBottomY; --$yy) { for ($xx = -$leavesRadius; $xx <= $leavesRadius; ++$xx) { for ($zz = -$leavesRadius; $zz <= $leavesRadius; ++$zz) { if (abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0) { $level->setBlockRaw(new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz), new LeavesBlock($this->type)); } } } if ($leavesRadius > 0 and $yy === $pos->y + $this->leavesBottomY + 1) { --$leavesRadius; } elseif ($leavesRadius < $this->leavesMaxRadius) { ++$leavesRadius; } } for ($yy = 0; $yy < $this->totalHeight - 1; ++$yy) { $level->setBlockRaw(new Vector3($pos->x, $pos->y + $yy, $pos->z), new WoodBlock($this->type)); } }
public function placeObject(Level $level, Vector3 $pos, Random $random) { if ($this->leavesSizeY === -1 or $this->leavesAbsoluteMaxRadius === -1) { $this->findRandomLeavesSize($random); } $level->setBlockRaw(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock()); $leavesRadius = 0; $leavesMaxRadius = 1; $leavesBottomY = $this->totalHeight - $this->leavesSizeY; $firstMaxedRadius = false; for ($leavesY = 0; $leavesY <= $leavesBottomY; ++$leavesY) { $yy = $this->totalHeight - $leavesY; for ($xx = -$leavesRadius; $xx <= $leavesRadius; ++$xx) { for ($zz = -$leavesRadius; $zz <= $leavesRadius; ++$zz) { if (abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0) { $level->setBlockRaw(new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz), new LeavesBlock($this->type)); } } } if ($leavesRadius >= $leavesMaxRadius) { $leavesRadius = $firstMaxedRadius ? 1 : 0; $firstMaxedRadius = true; if (++$leavesMaxRadius > $this->leavesAbsoluteMaxRadius) { $leavesMaxRadius = $this->leavesAbsoluteMaxRadius; } } else { ++$leavesRadius; } } $trunkHeightReducer = $random->nextRange(0, 3); for ($yy = 0; $yy < $this->totalHeight - $trunkHeightReducer; ++$yy) { $level->setBlockRaw(new Vector3($pos->x, $pos->y + $yy, $pos->z), new WoodBlock($this->type)); } }
public static function level_form(Level $level) { switch ($level->id()) { case 1: $level_field = 'info'; $level_name = _('Beginner'); break; case 2: $level_field = 'success'; $level_name = _('Intermediate'); break; case 3: $level_field = 'warning'; $level_name = _('Advanced'); break; case 4: $level_field = 'danger'; $level_name = _('Fluent'); break; case 5: $level_field = 'primary'; $level_name = _('Mother Tong'); break; } echo '<div class="progress"> <div class="progress-bar progress-bar-' . $level_field . '" role="progressbar" aria-valuenow="' . $level->id() . '" aria-valuemin="0" aria-valuemax="5" style="width: ' . $level->id() * 20 . '%;"> ' . $level_name . '</div></div>'; }
public function run() { $lvl = new Level(); $lvl->game_id = 1; $lvl->level_name = 'First Lvl'; $lvl->save(); }
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz) { if ($this->meta === AIR) { if ($target instanceof LiquidBlock) { $level->setBlock($target, new AirBlock(), true, false, true); if (($player->gamemode & 0x1) === 0) { $this->meta = $target instanceof WaterBlock ? WATER : LAVA; } return true; } } elseif ($this->meta === WATER) { //Support Make Non-Support Water to Support Water if ($block->getID() === AIR || $block instanceof WaterBlock && ($block->getMetadata() & 0x7) != 0x0) { $water = new WaterBlock(); $level->setBlock($block, $water, true, false, true); $water->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz); if (($player->gamemode & 0x1) === 0) { $this->meta = 0; } return true; } } elseif ($this->meta === LAVA) { if ($block->getID() === AIR) { $level->setBlock($block, new LavaBlock(), true, false, true); if (($player->gamemode & 0x1) === 0) { $this->meta = 0; } return true; } } return false; }
function form($id = FALSE) { $data['user'] = new User($id); $levels = new Level(); $data['levels'] = $levels->get(); $this->template->build('admin/user_form', $data); }
function delete($id = FALSE) { if ($id) { $level = new Level($id); $level->delete(); set_notify('success', 'ลบข้อมูลเรียบร้อยแล้วค่ะ'); redirect('users/admin/users'); } }
/** * This function checks if a Level has access to a specific site part. It checks this using * a SQL query on the relationship table (ACCESS_TABLE) * @global DB $db The Database class * @param Level $level This Level object is the Level for which access should be checked * @param string $sajtdel This string should be a sajtdel for which access should be checked. * @return bool True or false depending on access * @see ACCESS_TABLE * @see $sajtDelar */ public static function levelHasAccess($level, $sajtdel) { global $db; if ($db->row("SELECT * FROM " . self::ACCESS_TABLE . " WHERE sajtdel='" . $sajtdel . "' AND levelId=" . $level->getId())) { return true; } else { return false; } }
public function load() { $this->clear(); $level = new Level('College'); $level->save(); print_r(sprintf("Created Level: %s (%s)\n", $level->getName(), $level->getId())); $level = new Level('Summer'); $level->save(); print_r(sprintf("Created Level: %s (%s)\n", $level->getName(), $level->getId())); }
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz) { if (($player->gamemode & 0x1) === 0 and $this->useOn($block) and $this->getMetadata() >= $this->getMaxDurability()) { $player->setSlot($player->slot, new Item(AIR, 0, 0), false); } if ($block->getID() === AIR and $target instanceof SolidBlock) { $level->setBlock($block, new FireBlock(), true, false, true); $block->level->scheduleBlockUpdate(new Position($block, 0, 0, $block->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); return true; } return false; }
public static function growGrass(Level $level, Vector3 $pos, Random $random, $count = 15, $radius = 10) { $arr = array(BlockAPI::get(DANDELION, 0), BlockAPI::get(CYAN_FLOWER, 0), BlockAPI::get(TALL_GRASS, 1), BlockAPI::get(TALL_GRASS, 1), BlockAPI::get(TALL_GRASS, 1), BlockAPI::get(TALL_GRASS, 1)); $arrC = count($arr) - 1; for ($c = 0; $c < $count; ++$c) { $x = $random->nextRange($pos->x - $radius, $pos->x + $radius); $z = $random->nextRange($pos->z - $radius, $pos->z + $radius); if ($level->level->getBlockID($x, $pos->y + 1, $z) === AIR and $level->level->getBlockID($x, $pos->y, $z) === GRASS) { $t = $arr[$random->nextRange(0, $arrC)]; $level->setBlockRaw(new Vector3($x, $pos->y + 1, $z), $t); } } }
function updatePosition() { $positionList = $this->input->post('positionList'); $idList = $this->input->post('idList'); $levels = new Level(); for ($i = 0; $i < count($idList); $i++) { $levels->where("id", $idList[$i]); $levels->get(); $levels->position = $positionList[$i]; $levels->save(); $levels->clear(); } redirect("admin/levels/listAll/"); }
function save($object = '', $related_field = '') { if (!$this->exists()) { $o = new Level(); $o->select_max('position'); $o->get(); if (count($o->all) != 0) { $max = $o->position + 1; $this->position = $max; } else { $this->postion = 1; } } return parent::save($object, $related_field); }
public function new_notice() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); $data["actions"] = Session::get('actions'); if (in_array('side_nuevo_comunicado', $data["actions"])) { $current_ay = AcademicYear::getCurrentAcademicYear(); if (!$current_ay) { return View::make('notices/academic_year_error', $data); } $data["levels"] = Level::lists('name', 'id'); $data["levels"]["0"] = 'Todos los niveles'; return View::make('notices/new_notice', $data); } else { // Llamo a la función para registrar el log de auditoria $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'"; Helpers::registerLog(10, $log_description); Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.'); return Redirect::to('/dashboard'); } } else { return View::make('error/error'); } }
public function getStdClass() { // init $result = new \stdClass(); // action $result->id = $this->id; $result->person = $this->person->getStdClass(); // $result->name = html_entity_decode($this->name, ENT_COMPAT | ENT_HTML401, 'UTF-8');; // $result->address = html_entity_decode($this->address, ENT_COMPAT | ENT_HTML401, 'UTF-8'); $result->name = $this->name; $result->address = $this->address; $result->latitude = $this->latitude; $result->longitude = $this->longitude; $result->level = $this->level->getStdClass(); $result->interpretationType = $this->interpretationType->getStdClass(); $result->language = $this->language; $result->textCombined = $this->textCombined->getStdClass(); $result->textHouseX = $this->textHouseX->getStdClass(); $result->textHouseY = $this->textHouseY->getStdClass(); $result->zodiacX = $this->zodiacX->getStdClass(); $result->zodiacY = $this->zodiacY->getStdClass(); $factorListStdClass = array(); /** @var Factor $factor */ foreach ($this->factors as $factor) { array_push($factorListStdClass, $factor->getStdClass()); } $result->factors = $factorListStdClass; // $result->code = html_entity_decode($this->code, ENT_COMPAT | ENT_HTML401, 'UTF-8');; $result->code = $this->code; $result->isPaid = $this->isPaid; $result->dateCreated = $this->dateCreated; // return return $result; }
function is_login($level_name = FALSE) { $CI =& get_instance(); $user = new User($CI->session->userdata('id')); if ($level_name) { $level = new Level(); if ($user->level->level) { $id = $level->get_by_level($level_name)->id >= $user->level->id ? true : false; } else { $id = false; } } else { $id = $user->id; } return $id ? true : false; }
public function run() { $faker = Faker::create(); $names = ['Root', 'Super Admin', 'Admin']; foreach (range(1, 3) as $index) { Level::create(['name' => $names[$index - 1], 'description' => $faker->realText(25)]); } }
/** * tearDown metodē tiek dzēsts pievienotais ieraksts */ public function testListLevel() { $aAssumedResult = array(0 => array('id' => $this->nListLevelId, 'label' => 'label', 'value' => 'label', 'parent_id' => 999, 'level' => Level::LEVEL_2, 'code' => 'code', 'hidden' => Level::VISIBLE, 'external' => false)); //print_r($aAssumedResult); $aResult = $this->object->listLevel(999, 2, 'cod'); //print_r($aResult); $this->assertEquals($aAssumedResult, $aResult); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $level = Level::find($id); if (!$level) { Session::flash('errorMessage', 'This level dose not exits'); return $this->index(); } return View::make('games.show')->with('level', $level); }
public function testget() { $query = Level::with('calls')->where('id', 9); // $query->whereHas('calls',function($q){ // $q->where('level_id',9); // }); $data = $query->get(); return Response::json($data); }
public function run() { DB::table('Players')->delete(); DB::table('Questions')->delete(); DB::table('Questionnaires')->delete(); DB::table('Answers')->delete(); DB::table('Level')->delete(); $eingang = Questionnaire::create(array('name' => 'eingang')); $mittel = Questionnaire::create(array('name' => 'mittel')); $end = Questionnaire::create(array('name' => 'end')); $test = Questionnaire::create(array('name' => 'test')); $level = Level::create(array('score' => 1, 'mistakes' => 10, 'hits' => 2, 'info' => 'info')); $test1 = Question::create(array('question' => '1', 'questionnaire_id' => $test->id)); $test2 = Question::create(array('question' => '2', 'questionnaire_id' => $test->id)); $test3 = Question::create(array('question' => '3', 'questionnaire_id' => $test->id)); $test4 = Question::create(array('question' => '4', 'questionnaire_id' => $test->id)); $eingang1 = Question::create(array('question' => 'Ich spiele häufig Computerspiele', 'questionnaire_id' => $eingang->id)); $eingang1 = Question::create(array('question' => 'Ich kenne die Gestaltgesetze', 'questionnaire_id' => $eingang->id)); $frage1 = Question::create(array('question' => 'Das Spiel hat mir Spass gemacht', 'questionnaire_id' => $end->id)); $fam1 = Question::create(array('question' => 'Ich mag solche Rätsel und Knobeleien', 'questionnaire_id' => $end->id)); $fam15 = Question::create(array('question' => 'Ich glaube, der Schwierigkeit dieses Spiels gewachsen zu sein', 'questionnaire_id' => $end->id)); $fam16 = Question::create(array('question' => 'Wahrscheinlich werde ich das Spiel nicht schaffen.', 'questionnaire_id' => $end->id)); $fam1 = Question::create(array('question' => 'Bei dem Spiel mag ich die Rolle des Wissenschaftlers, der Zusammenhänge entdeckt.', 'questionnaire_id' => $end->id)); $fam2 = Question::create(array('question' => 'Das Spiel ist eine richtige Herausforderung für mich.', 'questionnaire_id' => $end->id)); $fam3 = Question::create(array('question' => 'Nach dem Lesen der Instruktion erscheint mir das Spiel sehr interessant.', 'questionnaire_id' => $end->id)); $fam4 = Question::create(array('question' => 'Ich bin sehr gespannt darauf, wie gut ich hier abschneiden werde.', 'questionnaire_id' => $end->id)); $fam5 = Question::create(array('question' => 'Ich fürchte mich ein wenig davor, dass ich mich hier blamieren könnte', 'questionnaire_id' => $end->id)); $fam6 = Question::create(array('question' => 'Ich bin fest entschlossen, mich bei diesem Spiel voll anzustrengen.', 'questionnaire_id' => $end->id)); $fam7 = Question::create(array('question' => 'Bei Spielen wie diesem brauche ich keine Belohnung, sie machen mir auch so viel Spaß. ', 'questionnaire_id' => $end->id)); $fam8 = Question::create(array('question' => 'Es ist mir etwas peinlich, hier zu versagen.', 'questionnaire_id' => $end->id)); $fam9 = Question::create(array('question' => 'Ich glaube, dass kann jeder schaffen', 'questionnaire_id' => $end->id)); $fam10 = Question::create(array('question' => 'Ich glaube, ich schaffe dieses Spiel nicht', 'questionnaire_id' => $end->id)); $fam11 = Question::create(array('question' => 'Wenn ich das Spiel schaffe, werde ich schon ein wenig stolz auf meine Tüchtigkeit sein.', 'questionnaire_id' => $end->id)); $fam12 = Question::create(array('question' => 'Wenn ich an das Spiel denke, bin ich etwas beunruhigt.', 'questionnaire_id' => $end->id)); $fam13 = Question::create(array('question' => 'Eine solches Spiel würde ich auch in meiner Freizeit spielen.', 'questionnaire_id' => $end->id)); $fam14 = Question::create(array('question' => 'Die konkreten Leistungsanforderungen hier lähmen mich.', 'questionnaire_id' => $end->id)); $frage1 = Question::create(array('question' => 'Das Spiel hat mir Spass gemacht', 'questionnaire_id' => $mittel->id)); $fammid1 = Question::create(array('question' => 'Ich mag solche Rätsel und Knobeleien', 'questionnaire_id' => $mittel->id)); $fammid15 = Question::create(array('question' => 'Ich glaube, der Schwierigkeit dieses Spiels gewachsen zu sein', 'questionnaire_id' => $mittel->id)); $fammid16 = Question::create(array('question' => 'Wahrscheinlich werde ich das Spiel nicht schaffen.', 'questionnaire_id' => $mittel->id)); $fammid1 = Question::create(array('question' => 'Bei dem Spiel mag ich die Rolle des Wissenschaftlers, der Zusammenhänge entdeckt.', 'questionnaire_id' => $mittel->id)); $fammid2 = Question::create(array('question' => 'Das Spiel ist eine richtige Herausforderung für mich.', 'questionnaire_id' => $mittel->id)); $fammid3 = Question::create(array('question' => 'Nach dem Lesen der Instruktion erscheint mir das Spiel sehr interessant.', 'questionnaire_id' => $mittel->id)); $fammid4 = Question::create(array('question' => 'Ich bin sehr gespannt darauf, wie gut ich hier abschneiden werde.', 'questionnaire_id' => $mittel->id)); $fammid5 = Question::create(array('question' => 'Ich fürchte mich ein wenig davor, dass ich mich hier blamieren könnte', 'questionnaire_id' => $mittel->id)); $fammid6 = Question::create(array('question' => 'Ich bin fest entschlossen, mich bei diesem Spiel voll anzustrengen.', 'questionnaire_id' => $mittel->id)); $fammid7 = Question::create(array('question' => 'Bei Spielen wie diesem brauche ich keine Belohnung, sie machen mir auch so viel Spaß. ', 'questionnaire_id' => $mittel->id)); $fammid8 = Question::create(array('question' => 'Es ist mir etwas peinlich, hier zu versagen.', 'questionnaire_id' => $mittel->id)); $fammid9 = Question::create(array('question' => 'Ich glaube, dass kann jeder schaffen', 'questionnaire_id' => $mittel->id)); $fammid10 = Question::create(array('question' => 'Ich glaube, ich schaffe dieses Spiel nicht', 'questionnaire_id' => $mittel->id)); $fammid11 = Question::create(array('question' => 'Wenn ich das Spiel schaffe, werde ich schon ein wenig stolz auf meine Tüchtigkeit sein.', 'questionnaire_id' => $mittel->id)); $fammid12 = Question::create(array('question' => 'Wenn ich an das Spiel denke, bin ich etwas beunruhigt.', 'questionnaire_id' => $mittel->id)); $fammid13 = Question::create(array('question' => 'Eine solches Spiel würde ich auch in meiner Freizeit spielen.', 'questionnaire_id' => $mittel->id)); $fammid14 = Question::create(array('question' => 'Die konkreten Leistungsanforderungen hier lähmen mich.', 'questionnaire_id' => $mittel->id)); }
public function placeObject(Level $level, Vector3 $pos, Random $random) { // The base dirt block $dirtpos = new Vector3($pos->x, $pos->y - 1, $pos->z); $level->setBlockRaw($dirtpos, new DirtBlock()); // Adjust the tree trunk's height randomly // plot [-14:11] int( x / 8 ) + 5 // - min=4 (all leaves are 4 tall, some trunk must show) // - max=6 (top leaves are within ground-level whacking range // on all small trees) $heightPre = $random->nextRange(-14, 11); $this->trunkHeight = intval($heightPre / 8) + 5; // Adjust the starting leaf density using the trunk height as a // starting position (tall trees with skimpy leaves don't look // too good) $leafPre = $random->nextRange($this->trunkHeight, 10) / 20; // (TODO: seed may apply) // Now build the tree (from the top down) $leaflevel = 0; for ($yy = $this->trunkHeight + 1; $yy >= 0; --$yy) { if ($leaflevel < self::$leavesHeight) { // The size is a slight variation on the trunkheight $radius = self::$leafRadii[$leaflevel] + $leafPre; $bRadius = 3; for ($xx = -$bRadius; $xx <= $bRadius; ++$xx) { for ($zz = -$bRadius; $zz <= $bRadius; ++$zz) { if (sqrt($xx * $xx + $zz * $zz) <= $radius) { $leafpos = new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz); $level->setBlockRaw($leafpos, new LeavesBlock($this->type)); } } } $leaflevel++; } // Place the trunk last if ($leaflevel > 1) { $trunkpos = new Vector3($pos->x, $pos->y + $yy, $pos->z); $level->setBlockRaw($trunkpos, new WoodBlock($this->type)); } } }
public function getGame() { if (Input::get('level')) { $level = Level::find(Input::get('level')); if (!$level) { return Redirect::to('/game'); } $game = Auth::user()->createGame($level); return Redirect::to("/game/" . $game->id); } return View::make('game.game'); }
public function placeObject(Level $level, Vector3 $pos) { $clusterSize = (int) $this->type->clusterSize; $angle = $this->random->nextFloat() * M_PI; $offset = VectorMath::getDirection2D($angle)->multiply($clusterSize)->divide(8); $x1 = $pos->x + 8 + $offset->x; $x2 = $pos->x + 8 - $offset->x; $z1 = $pos->z + 8 + $offset->y; $z2 = $pos->z + 8 - $offset->y; $y1 = $pos->y + $this->random->nextRange(0, 3) + 2; $y2 = $pos->y + $this->random->nextRange(0, 3) + 2; for ($count = 0; $count <= $clusterSize; ++$count) { $seedX = $x1 + ($x2 - $x1) * $count / $clusterSize; $seedY = $y1 + ($y2 - $y1) * $count / $clusterSize; $seedZ = $z1 + ($z2 - $z1) * $count / $clusterSize; $size = ((sin($count * (M_PI / $clusterSize)) + 1) * $this->random->nextFloat() * $clusterSize / 16 + 1) / 2; $startX = (int) ($seedX - $size); $startY = (int) ($seedY - $size); $startZ = (int) ($seedZ - $size); $endX = (int) ($seedX + $size); $endY = (int) ($seedY + $size); $endZ = (int) ($seedZ + $size); for ($x = $startX; $x <= $endX; ++$x) { $sizeX = pow(($x + 0.5 - $seedX) / $size, 2); if ($sizeX < 1) { for ($y = $startY; $y <= $endY; ++$y) { $sizeY = pow(($y + 0.5 - $seedY) / $size, 2); if ($y > 0 and $sizeX + $sizeY < 1) { for ($z = $startZ; $z <= $endZ; ++$z) { $sizeZ = pow(($z + 0.5 - $seedZ) / $size, 2); if ($sizeX + $sizeY + $sizeZ < 1 and $level->level->getBlockID($x, $y, $z) === STONE) { $level->setBlockRaw(new Vector3($x, $y, $z), $this->type->material); } } } } } } } }
public function getLevelToEnroll() { if ($this->enrollments()->get()->isEmpty()) { return $this->level; } else { // obtener la matricula del año pasado o la ultima matriculada registrada $level_id = $this->enrollments()->orderBy('date', 'DESC')->first()->level->id; // se debe matricular al siguiente nivel if ($level_id < 9) { return Level::find($level_id + 1); } else { return Level::find(9); } } }
public static function getDefault() { if (!self::$theDefault) { // we use loadById to load the object with an "isDefault" value of 1 try { self::$theDefault = parent::loadById(1, get_class(), "isDefault"); return self::$theDefault; } catch (Exception $e) { // no default found, return false instead return false; } } else { return self::$theDefault; } }
public function new_incident() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); $data["actions"] = Session::get('actions'); if (in_array('side_nueva_anotacion', $data["actions"])) { $current_ay = AcademicYear::getCurrentAcademicYear(); if (!$current_ay) { return View::make('control_notebook_incidents/academic_year_error', $data); } $data["levels"] = Level::lists('name', 'id'); $data["levels"]["0"] = 'Seleccione un nivel'; $level_id = Input::old('level_id'); $level = null; if ($level_id) { $level = $level_id; } else { $level = Input::get('level'); } $data["level"] = $level ? $level : '0'; if ($data["level"]) { $data["students"] = Student::getStudentsEnrolledInLevel($data["level"])->lists('FullName', 'id'); //$data["students"] = Student::orderBy('lastname')->get()->lists('FullName','id'); $data["students"]["0"] = 'Seleccione un alumno'; } else { $data["students"] = ['0' => 'Seleccione un nivel']; } $student_id = Input::old('student_id'); if ($student_id) { $data["student_id"] = $student_id; } else { $data["student_id"] = '0'; } $data["types"] = ['0' => 'Seleccione', '1' => 'Informativa', '2' => 'Felicitación', '3' => 'Llamada de atención']; return View::make('control_notebook_incidents/new_incident', $data); } else { // Llamo a la función para registrar el log de auditoria $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'"; Helpers::registerLog(10, $log_description); Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.'); return Redirect::to('/dashboard'); } } else { return View::make('error/error'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::check()) { $level = Level::find($id); $previous = Level::where('next_level', '=', $level->id)->first(); $previous->next_level = $level->next_level; $previous->save(); $calls = Call::where('level_id', '=', $id)->get(); foreach ($calls as $call) { $call->delete(); } $level = Level::find($id); $level->delete(); return $this->index(); } return 'you are not authorized to do this'; }
public static function verifyHourIntersection($level_id, $initial_hour, $final_hour) { $v = Level::find($level_id)->schedules()->where(function ($query) use($initial_hour, $final_hour) { $query->where(function ($q1) use($initial_hour) { $q1->where('initial_hour', '<=', $initial_hour)->where('final_hour', '>', $initial_hour); })->orWhere(function ($q2) use($final_hour) { $q2->where('initial_hour', '<', $final_hour)->where('final_hour', '>=', $final_hour); })->orWhere(function ($q3) use($initial_hour, $final_hour) { $q3->where('initial_hour', '>', $initial_hour)->where('final_hour', '<', $final_hour); }); })->get(); if ($v->isEmpty()) { return true; } else { return false; } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $condition = array('condition' => 'status=:status', 'params' => array(':status' => 1), 'order' => 'name'); $levels = Level::model()->findAll($condition); $option_levels = array(); foreach ($levels as $level) { $option_levels[$level->level_id] = $level->name; } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Type'])) { $model->attributes = $_POST['Type']; if ($model->save()) { $this->redirect(array('index', 'id' => $model->type_id)); } } $this->render('update', array('model' => $model, 'option_levels' => $option_levels)); }