public function run()
 {
     $classRooms = DB::select(DB::raw("select classrooms.block from classrooms group by classrooms.block order by classrooms.block"));
     foreach ($classRooms as $value) {
         $block = new Block();
         $block->name = $value->block;
         $block->save();
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Cube::create(['name' => 'First Cube']);
     Block::create(['x' => '1', 'y' => '1', 'z' => '1', 'value' => '23', 'cube_id' => '1']);
     Block::create(['x' => '2', 'y' => '2', 'z' => '2', 'value' => '4', 'cube_id' => '1']);
     Block::create(['x' => '2', 'y' => '2', 'z' => '3', 'value' => '7', 'cube_id' => '1']);
 }
 public function general($request, $id)
 {
     $requestMethod = $request->method();
     switch ($requestMethod) {
         case 'PUT':
             $classroom = Classroom::find($id);
             $functionGetRules = 'getRulesUpdate';
             $code = 'e-g';
             break;
         case 'POST':
             $classroom = new Classroom();
             $functionGetRules = 'getRulesCreate';
             $code = 'c-g';
             break;
     }
     $input = Input::all();
     if ($request->ajax()) {
         $data = $this->val($classroom, $functionGetRules);
         return $data;
     } else {
         $classroom->fill($input);
         $blockSelected = Block::find($input['block_id'])->name;
         $classroom->location = explode(' ', $blockSelected)[1] . ' - ' . $input['location'];
         //$classroom->location = explode(' ', $input['block'])[1].' - '.$input['location'];
         $classroom->save();
     }
     if (Input::get('nAs') == 'true') {
         return Redirect::to('classroom/create')->with('error', $code);
     }
     return Redirect::to(URL::to('datatables', ['salones', 'see']))->with('error', $code);
 }
Example #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('blocks')->delete();
     for ($i = 0; $i < count($this->items); $i++) {
         $row = array_combine(['id', 'alias', 'title', 'text'], $this->items[$i]);
         Block::create($row);
     }
 }
function get_global_blocks()
{
    $blocks = Block::where('page_id', '=', 0)->get();
    foreach ($blocks as $block) {
        $page['global-' . $block['name']] = $block['content'];
    }
    return $page;
}
 public function displayIndex()
 {
     try {
         $dataArr = Block::getBlocksDisplayArray();
         return view('back/adminka', $dataArr);
     } catch (\Exception $exception) {
         return ['status' => 'Что-то пошло не так. ' . $exception->getMessage()];
     }
 }
 public function createInit()
 {
     try {
         Block::initBlocks();
     } catch (Exception $exception) {
         return ['status' => 'Что-то пошло не так. ' . $exception->getMessage()];
     }
     return ['status' => 'OK'];
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('page')->delete();
     DB::table('block')->delete();
     $page = new Page();
     $page->name = 'Homepage';
     $page->slug = 'homepage';
     $page->enabled = true;
     $page->user_id = DB::table('users')->first()->id;
     $page->save();
     for ($i = 0; $i < 3; $i++) {
         $block = new Block();
         $block->slug = 'html_block' . $i;
         $block->type = 'html';
         $block->content = array('html' => '<b>Bold ' . $i . ' block</b>');
         $block->class = 'col-md-4';
         $block->enabled = true;
         $block->page_id = $page->id;
         $block->save();
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update($x, $y, $z, $value)
 {
     $blocks = $this->cube->blocks()->get();
     foreach ($blocks as $block) {
         if ($block->x == $x && $block->y == $y && $block->z == $z) {
             $block->value = $value;
             $block->save();
             return;
         }
     }
     $block = Block::create(array('x' => $x, 'y' => $y, 'z' => $z, 'value' => $value, 'cube_id' => $this->cube->id));
 }
Example #10
0
    public function handler($type)
    {
        //download
        $blocks = Block::get();
        $content = '<?xml version="1.0" encoding="utf-8"?>
<blocks>
';
        foreach ($blocks as $block) {
            $content .= "    <block id=\"" . $block->pimp_id . "\" name=\"" . $block->name . "\">\n";
            // now get the properties
            foreach ($block->properties as $property) {
                if ($property->attribute == 'property') {
                    $content .= "      <property ";
                    $content .= "name=\"" . $property->key . "\" value=\"" . $property->value . "\" ";
                    if ($property->parameters != '') {
                        $params = implode("\" ", explode("|", $property->parameters));
                        $params = str_replace("=", "=\"", $params);
                        $content .= $params . "\" ";
                    }
                    $content .= "/>\n";
                } elseif ($property->attribute == 'class') {
                    $content .= "      <property class=\"" . $property->value . "\">\n";
                    if ($property->parameters != '') {
                        $subprop = explode("|", $property->parameters);
                        foreach ($subprop as $p) {
                            $parts = explode("&", $p);
                            $content .= "         <property name=\"{$parts['0']}\" value=\"{$parts['1']}\" />\n";
                        }
                    }
                    $content .= "      </property>\n";
                } else {
                    $content .= "      <drop ";
                    $content .= "event=\"" . $property->key . "\" ";
                    if ($property->value != '') {
                        $content .= "name=\"" . $property->value . "\" ";
                    }
                    if ($property->parameters != '') {
                        $params = implode("\" ", explode("|", $property->parameters));
                        $params = str_replace("=", "=\"", $params);
                        $content .= $params . "\" ";
                    }
                    $content .= "/>\n";
                }
            }
            $content .= "    </block>\n";
        }
        $content .= "</blocks>";
        $fileName = "blocks.xml";
        $headers = ['Content-Type: text/plain; charset=utf-8', 'Content-Disposition' => sprintf('attachment; filename="%s"', $fileName)];
        return Response::make($content, 200, $headers);
    }
 public function update_content(PageUpdateRequest $request)
 {
     $page_contents = $request->all();
     array_shift($page_contents);
     $keys = array_keys($page_contents);
     $values = array_values($page_contents);
     foreach ($keys as $i => $key) {
         if (substr($key, 0, 7) == 'global-') {
             $key = substr($key, 7);
         }
         Block::where('name', '=', $key)->update(['content' => $values[$i]]);
     }
     return Redirect::back()->with('update', 'PAGE UPDATED SUCCESSFULLY!');
     // return var_dump($page_contents);
 }
 public function saveBlock()
 {
     if (Request::has('entity')) {
         $dataobj = Request::all();
         if ($dataobj['entity'] == 'block') {
             try {
                 $block = Block::firstOrCreate(['name' => $dataobj['block']]);
                 $result = $block->saveBlock($dataobj);
                 return ['status' => $result];
             } catch (Exception $exception) {
                 return ['status' => 'Что-то пошло не так. ' . $exception->getMessage()];
             }
         } else {
             return ['status' => 'Имя сохраняемой сущности не равно block (' . $dataobj['entity'] . ').'];
         }
     } else {
         return ['status' => 'Не хватает параметров для сохранения.'];
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $classRooms = DB::select(DB::raw("select classrooms.id,classrooms.block from classrooms"));
     $array = [];
     foreach ($classRooms as $classRoom) {
         $array[] = Block::select()->where('name', '=', $classRoom->block)->get()->first()->id;
     }
     Schema::table('classrooms', function ($table) {
         $table->dropColumn('block');
         $table->integer('block_id')->unsigned()->nullable();
         $table->foreign('block_id')->references('id')->on('blocks');
     });
     $index = 0;
     $classRoom = Classroom::all();
     foreach ($classRoom as $value) {
         $value->block_id = $array[$index];
         $value->save();
         $index++;
     }
 }
Example #14
0
 public function homepage()
 {
     $user = Auth::user() ?: false;
     $cars = Car::with('inquiriesCount')->orderBy('domestic', 'asc')->orderBy('name')->get();
     $cars1 = $cars->filter(function ($item) {
         return $item->name == "ВАЗ";
     });
     $cars2 = $cars->filter(function ($item) {
         return $item->name != "ВАЗ";
     });
     $cars = $cars1->merge($cars2);
     $carsList = $cars->lists('name', 'id')->toArray();
     $lastInquiries = Inquiry::with('car', 'city')->orderBy('created_at', 'desc')->paginate(config('vars.inquiries_per_page'));
     $lastInquiries->setPath('inquiry/index');
     Carbon::setLocale(config('app.locale'));
     $lastNews = News::orderBy('published_at', 'desc')->paginate(config('vars.news_per_page'));
     $lastNews->setPath('news/index');
     $cities = City::lists('name', 'id')->all();
     $blocks = Block::all()->keyBy('alias');
     $faq = Faq::all();
     return view('homepage', compact('user', 'cars', 'carsList', 'lastInquiries', 'lastNews', 'cities', 'blocks', 'faq'));
 }
Example #15
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $user = Auth::user();
     $block = Block::findOrNew($id);
     foreach (Material::get(array('name'))->toArray() as $mat) {
         $materials[$mat['name']] = $mat['name'];
     }
     $blocks = array(0 => 'None');
     foreach (Block::select('name')->orderBy('name', 'ASC')->get()->toArray() as $pointer) {
         $blocks[$pointer['name']] = $pointer['name'];
     }
     $items = array(0 => 'None');
     foreach (Item::select('name')->orderBy('name', 'ASC')->get()->toArray() as $pointer) {
         $items[$pointer['name']] = $pointer['name'];
     }
     $shapes = array(0 => 'None');
     foreach (BlockProperties::select('value')->where('key', 'Shape')->groupBy('value')->get()->toArray() as $pointer) {
         $shapes[$pointer['value']] = $pointer['value'];
     }
     $models = array(0 => 'None');
     foreach (BlockProperties::select('value')->where('key', 'Model')->groupBy('value')->get()->toArray() as $pointer) {
         $models[$pointer['value']] = $pointer['value'];
     }
     $meshes = array(0 => 'None');
     foreach (BlockProperties::select('value')->where('key', 'Mesh')->groupBy('value')->get()->toArray() as $pointer) {
         $meshes[$pointer['value']] = $pointer['value'];
     }
     $groups = array(0 => 'None');
     foreach (BlockProperties::select('value')->where('key', 'Group')->groupBy('value')->get()->toArray() as $pointer) {
         $groups[$pointer['value']] = $pointer['value'];
     }
     $classes = array(0 => 'None');
     foreach (BlockProperties::select('value')->where('key', 'Class')->groupBy('value')->get()->toArray() as $pointer) {
         $classes[$pointer['value']] = $pointer['value'];
     }
     $droppables = array(0 => 'None');
     foreach (Block::get(array('name'))->toArray() as $pointer) {
         $droppables[$pointer['name']] = $pointer['name'];
     }
     foreach (Item::get(array('name'))->toArray() as $pointer) {
         $droppables[$pointer['name']] = $pointer['name'];
     }
     $placements = array(0 => 'None');
     foreach (BlockProperties::select('value')->where('key', 'Place')->groupBy('value')->get()->toArray() as $pointer) {
         $placements[$pointer['value']] = $pointer['value'];
     }
     $collisions = array('bullet' => 'bullet', 'melee' => 'melee', 'movement' => 'movement', 'rocket' => 'rocket', 'sight' => 'sight');
     $sounds = array(0 => "No sound");
     $buffs = array(0 => "No buff");
     $loot = array(0 => "No loot table");
     $tags = array(0 => "No tags", 'Door' => "Door", 'Gore' => "Gore", 'TreeTrunk' => "TreeTrunk", 'Window' => "Window");
     $meshDamages = array(0 => "None", "Door/Door_DMG0" => "Door/Door_DMG0", "Door/Door_DMG1" => "Door/Door_DMG1", "Door/Door_DMG2" => "Door/Door_DMG2", "Door/Door_DMG3" => "Door/Door_DMG3", "Door/Door_DMG4" => "Door/Door_DMG4", "Door/Hatch_DMG0" => "Door/Hatch_DMG0", "Door/Hatch_DMG1" => "Door/Hatch_DMG1", "Door/Hatch_DMG2" => "Door/Hatch_DMG2", "Door/Hatch_DMG3" => "Door/Hatch_DMG3", "Door/Hatch_DMG4" => "Door/Hatch_DMG4");
     $particleNames = array(0 => "None", "campfire" => "campfire", "candle_flame" => "candle_flame", "candleWall_flame" => "candleWall_flame", "ember_pile" => "ember_pile", "forge" => "hotembers", "hotembers" => "hotembers", "sandstorm" => "sandstorm", "smokestorm" => "smokestorm", "snowstorm1" => "snowstorm1", "torch_wall" => "torch_wall");
     $particleOnDeath = array(0 => "None", "treeGib_birch" => "treeGib_birch", "treeGib_burnt" => "treeGib_burnt");
     $properties = array('BigDecorationRadius' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'BuffsWhenWalkedOn' => array('type' => 'select', 'options' => $buffs, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'CanDecorateOnSlopes' => array('type' => 'checkbox', 'options' => '', 'value' => true, 'attribute' => 'property', 'parameters' => ''), 'CanMobsSpawnOn' => array('type' => 'checkbox', 'options' => '', 'value' => true, 'attribute' => 'property', 'parameters' => ''), 'CanPickup' => array('type' => 'checkbox', 'options' => '', 'value' => false, 'attribute' => 'property', 'parameters' => ''), 'CanPlayersSpawnOn' => array('type' => 'checkbox', 'options' => '', 'value' => true, 'attribute' => 'property', 'parameters' => ''), 'Class' => array('type' => 'select', 'options' => $classes, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'CloseSound' => array('type' => 'select', 'options' => $sounds, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Collide' => array('type' => 'selectmulti', 'options' => $collisions, 'value' => '', 'attribute' => 'property', 'parameters' => ''), 'CustomIcon' => array('type' => 'select', 'options' => $blocks, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'CustomIconTint' => array('type' => 'text', 'options' => '', 'value' => '000000', 'attribute' => 'property', 'parameters' => ''), 'Damage' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Damage_received' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Density' => array('type' => 'number', 'options' => '', 'value' => 1, 'attribute' => 'property', 'parameters' => ''), 'DowngradeBlock' => array('type' => 'select', 'options' => $blocks, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'DropScale' => array('type' => 'number', 'options' => '', 'value' => 2, 'attribute' => 'property', 'parameters' => ''), 'FallDamage' => array('type' => 'checkbox', 'options' => '', 'value' => true, 'attribute' => 'property', 'parameters' => ''), 'FallOver' => array('type' => 'checkbox', 'options' => '', 'value' => false, 'attribute' => 'property', 'parameters' => ''), 'FuelValue' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'GrassBlock1' => array('type' => 'select', 'options' => $blocks, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'GrassBlock2' => array('type' => 'select', 'options' => $blocks, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Group' => array('type' => 'select', 'options' => $groups, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'HeatMapFrequency' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'HeatMapStrength' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'HeatMapTime' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'IsDeveloper' => array('type' => 'checkbox', 'options' => '', 'value' => false, 'attribute' => 'property', 'parameters' => ''), 'IsPlant' => array('type' => 'checkbox', 'options' => '', 'value' => false, 'attribute' => 'property', 'parameters' => ''), 'IsTerrainDecoration' => array('type' => 'checkbox', 'options' => '', 'value' => true, 'attribute' => 'property', 'parameters' => ''), 'Light' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'LiquidMoving' => array('type' => 'number', 'options' => array(0 => "N/A", 'waterMoving' => 'waterMoving', 'waterMovingBucket' => 'waterMovingBucket'), 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'LiquidStatic' => array('type' => 'number', 'options' => array(0 => "N/A", 'water' => 'water', 'waterStaticBucket' => 'waterStaticBucket'), 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'LootList' => array('type' => 'select', 'options' => $loot, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'LPHardnessScale' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Map.Color' => array('type' => 'text', 'options' => '', 'value' => '', 'attribute' => 'property', 'parameters' => ''), 'Material' => array('type' => 'select', 'options' => $materials, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Mesh' => array('type' => 'select', 'options' => $meshes, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Mesh-Damage-1' => array('type' => 'select', 'options' => $meshDamages, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Mesh-Damage-2' => array('type' => 'select', 'options' => $meshDamages, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Mesh-Damage-3' => array('type' => 'select', 'options' => $meshDamages, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Mesh-Damage-4' => array('type' => 'select', 'options' => $meshDamages, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Mesh-Damage-5' => array('type' => 'select', 'options' => $meshDamages, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Model' => array('type' => 'select', 'options' => $models, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'ModelOffset' => array('type' => 'text', 'options' => '', 'value' => array(0, 0, 0), 'attribute' => 'property', 'parameters' => ''), 'MovementFactor' => array('type' => 'number', 'options' => '', 'value' => 1, 'attribute' => 'property', 'parameters' => ''), 'MultiBlockDim' => array('type' => 'text', 'options' => '', 'value' => array(1, 1, 1), 'attribute' => 'property', 'parameters' => ''), 'OpenSound' => array('type' => 'select', 'options' => $sounds, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'ParticleName' => array('type' => 'select', 'options' => $particleNames, 'value' => 'none', 'attribute' => 'property', 'parameters' => ''), 'ParticleOffset' => array('type' => 'text', 'options' => '', 'value' => array(0, 0, 0), 'attribute' => 'property', 'parameters' => ''), 'ParticleOnDeath' => array('type' => 'select', 'options' => $particleOnDeath, 'value' => 'none', 'attribute' => 'property', 'parameters' => ''), 'PickupTarget' => array('type' => 'select', 'options' => array_merge($blocks, $items), 'value' => 'none', 'attribute' => 'property', 'parameters' => ''), 'Place' => array('type' => 'select', 'options' => $placements, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'PlaceAltBlockValue' => array('type' => 'selectmulti', 'options' => $blocks, 'value' => 'none', 'attribute' => 'property', 'parameters' => ''), 'PlaceEverywhere' => array('type' => 'checkbox', 'options' => '', 'value' => false, 'attribute' => 'property', 'parameters' => ''), 'Shape' => array('type' => 'select', 'options' => $shapes, 'value' => '0', 'attribute' => 'property', 'parameters' => ''), 'ShapeMinBB' => array('type' => 'text', 'options' => '', 'value' => array(0, 0, 0), 'attribute' => 'property', 'parameters' => ''), 'SiblingBlock' => array('type' => 'select', 'options' => $blocks, 'value' => '0', 'attribute' => 'property', 'parameters' => ''), 'SiblingDirection' => array('type' => 'text', 'options' => '', 'value' => array(0, 0, 0), 'attribute' => 'property', 'parameters' => ''), 'SmallDecorationRadius' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'StateChange' => array('type' => 'select', 'options' => array('none' => "Does not change", 'PlantGrowing' => 'Grows like a plant', 'UpgradeBlock' => 'Upgradable Block', 'UpgradeRated' => 'Changes like concrete', 'Explosion' => 'Make it explodable (Gas pumps)'), 'value' => 'none', 'attribute' => 'class', 'parameters' => ''), 'Tag' => array('type' => 'select', 'options' => $tags, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Texture' => array('type' => 'text', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'UpwardsCount' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'UpgradeRated.BlockCombined' => array('type' => 'select', 'options' => $blocks, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'UpgradeRated.Rate' => array('type' => 'number', 'options' => '', 'value' => 15, 'attribute' => 'property', 'parameters' => ''), 'UpgradeRated.ToBlock' => array('type' => 'select', 'options' => $blocks, 'value' => 0, 'attribute' => 'property', 'parameters' => ''), 'Weight' => array('type' => 'number', 'options' => '', 'value' => 0, 'attribute' => 'property', 'parameters' => ''));
     foreach ($properties as $key => $prop) {
         foreach ($block->properties as $bprop) {
             $parameters = array('ToBlock' => 0, 'Item' => 0, 'ItemCount' => 0, 'UpgradeHitCount' => 0, 'Next' => 0, 'GrowthRate' => 0, 'FertileLevel' => 0, 'IsRandom' => false, 'LightLevelStay' => 0, 'GrowIfAnythinOnTop' => false, 'IsGrowOnTopEnabled' => false, 'GrowOnTop' => false, 'GrowthRate' => false, 'ParticleIndex' => 0, 'RadiusBlocks' => 0, 'BlockDamage' => 0, 'RadiusEntities' => 0, 'EntityDamage' => 0);
             if ($bprop->attribute == 'class' && in_array($bprop->value, array('UpgradeBlock', 'PlantGrowing', 'Explosion'))) {
                 /* parameters in format Key&Value|Key&Value */
                 if ($bprop->parameters != '') {
                     $param = explode("|", $bprop->parameters);
                     foreach ($param as $p) {
                         $t = explode("&", $p);
                         $parameters[$t[0]] = $t[1];
                     }
                 }
                 $properties['StateChange']['value'] = $bprop->value;
                 $properties['StateChange']['attribute'] = $bprop->attribute;
                 $properties['StateChange']['parameters'] = $parameters;
             } else {
                 if ($bprop->key == $key) {
                     if ($bprop->parameters != '') {
                         $param = explode("|", $bprop->parameters);
                         foreach ($param as $p) {
                             $t = explode("&", $p);
                             $parameters[$t[0]] = $t[1];
                         }
                     }
                     /* handle breaking up things like multi-dim, model offset, etc into pieces */
                     $value = $bprop->value;
                     if ($key == 'ModelOffset' || $key == 'MultiBlockDim' || $key == 'SiblingDirection' || $key == 'ParticleOffset' || $key == 'ShapeMinBB') {
                         $value = explode(",", $value);
                     }
                     $properties[$key]['value'] = $value;
                     $properties[$key]['attribute'] = $bprop->attribute;
                     $properties[$key]['parameters'] = $parameters;
                 }
             }
         }
     }
     if ($properties['StateChange']['value'] == 'none') {
         $properties['StateChange']['parameters'] = $parameters;
     }
     return view('forms.block', compact('block', 'user', 'properties', 'materials', 'blocks', 'items'));
 }
Example #16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Block::destroy($id);
     Flash::success("Запись - {$id} удалена");
     return redirect(route('admin.blocks.index'));
 }
 public function printData($year, $month, $day, $room)
 {
     //$data = ReservationInfo::where('reservationDate',$date)->get();
     $date = $year . "-" . $month . "-" . $day;
     $blocks = Block::all();
     $data = ReservationInfo::where('reservationDate', $date)->where('room', $room)->get();
     $filas = "";
     foreach ($blocks as $block) {
         if (!$data->where('block_id', $block->id)->isEmpty()) {
             $info = $data->where('block_id', $block->id)->first();
             $filas .= "\n                <tr>\n                    <th>" . $block->startBlock . " a " . $block->finishBlock . "</th>\n                    <th>" . $info->Reservation->Patient->firstname . " " . $info->Reservation->Patient->lastname . "</th>\n                    <th>" . $info->Reservation->Atention->name . "</th>\n                    <th>" . $info->Reservation->Medic->name . "</th>\n                    <th class='" . $info->Reservation->status . "'>" . $info->Reservation->status . "</th>\n                </tr>";
         } else {
             $filas .= "\n                <tr>\n                    <th>" . $block->startBlock . " a " . $block->finishBlock . "</th>\n                    <th></th>\n                    <th></th>\n                    <th></th>\n                    <th></th>\n                </tr>";
         }
     }
     return $filas;
 }
 public function returnClassrooms()
 {
     $blocks = explode(",", Input::get("data"));
     foreach ($blocks as $key => $value) {
         $blocks[$key] = 'name = "' . $value . '"';
     }
     $idBlock = Block::select()->whereRaw(implode(' or ', $blocks))->lists("id");
     $classRooms = Classroom::select()->whereIn('block_id', $idBlock)->orderBy('location')->get();
     return $classRooms;
 }
Example #19
0
 public static function getBlocksDisplayArray()
 {
     $blocks = Block::with(['stringfields', 'textfields', 'numbs', 'bools', 'images'])->get();
     $dataArr = [];
     foreach ($blocks as $block) {
         $dataArr[$block->name] = ['title' => $block->title, 'stringfields' => [], 'textfields' => [], 'images' => [], 'bools' => [], 'numbs' => []];
         $block_strfs =& $dataArr[$block->name]['stringfields'];
         foreach ($block->stringfields as $stringfield) {
             $block_strfs[$stringfield->name] = $stringfield->value;
         }
         $block_textfs =& $dataArr[$block->name]['textfields'];
         foreach ($block->textfields as $textfield) {
             $block_textfs[$textfield->name] = $textfield->value;
         }
         $block_images =& $dataArr[$block->name]['images'];
         foreach ($block->images as $image) {
             $block_images[$image->name] = ['alt' => $image->alt, 'primary_link' => $image->primary_link, 'secondary_link' => $image->secondary_link, 'icon_link' => $image->icon_link, 'preview_link' => $image->preview_link];
         }
         $block_bools =& $dataArr[$block->name]['bools'];
         foreach ($block->bools as $boolitem) {
             $block_bools[$boolitem->name] = $boolitem->value;
         }
         $block_numbs =& $dataArr[$block->name]['numbs'];
         foreach ($block->numbs as $numb) {
             $block_numbs[$numb->name] = $numb->value;
         }
         $dataArr[$block->name]['group'] = $block->getGroupItemsArray();
     }
     return $dataArr;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param   \Illuminate\Http\Request    $request
  * @return  \Illuminate\Http\Response
  */
 public function destroyBlock(Request $request)
 {
     $this->validate($request, ["id" => "required|exists:block,id"]);
     Block::destroy($request->input("id"));
     return "true";
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Block::destroy($id);
     Session::flash('flash_message', 'Block successfully deleted!');
     return redirect('block');
 }
 public function checkBlock()
 {
     $userId = $this->request->input('userid');
     $friendId = $this->request->input('friendid');
     $UData = User::where('id', $friendId)->first();
     if ($UData) {
         $Favorite = Block::where('block_person', $friendId)->where('block_by', $userId)->first();
         if ($Favorite) {
             $Response = array('success' => '1');
         } else {
             $Response = array('success' => '0');
         }
         return json_encode($Response);
     } else {
         echo 'not found';
     }
 }
Example #23
0
 public function updateBlock($slug, $blockid, $value)
 {
     if ($this->lock) {
         return false;
     }
     $blocks = Block::find($blockid);
     $blocks = $this->blocks()->where('id', $blockid);
     if ($blocks->count() == 0) {
         return false;
     }
     $block = $blocks->first();
     if (alphaID($block->swatch_id) != $slug) {
         return false;
     }
     return $block->iterate($value);
 }
Example #24
0
 public function parseBlocks($blocks, $userid, $alpha, $core = 0, $modid = 0)
 {
     //purge all existing blocks that are core and of this alpha version
     Block::where(array('user_id' => 1, 'alpha' => 12.4))->delete();
     //dd($blocks);
     $processed = 0;
     foreach ($blocks['block'] as $item) {
         $block = new \App\Block();
         $block->name = $item['@attributes']['name'];
         if ($core) {
             $block->user_id = 1;
             $block->mod_id = 1;
             $block->core = 1;
             $block->pimp_id = $item['@attributes']['id'];
         } else {
             $block->user_id = $userid;
             $block->mod_id = $modid;
             $block->core = 0;
             $block->pimp_id = 0;
         }
         $block->alpha = $alpha;
         $block->save();
         $currentid = $item['@attributes']['id'];
         if (isset($item['property'])) {
             foreach ($item['property'] as $prop) {
                 if (isset($prop['@attributes'])) {
                     $attribs = $prop['@attributes'];
                     $properties = '';
                     $parameters = '';
                     $attribute = 'property';
                     foreach ($attribs as $key => $value) {
                         if ($key == 'name') {
                             $propname = $value;
                         } else {
                             if ($key == 'value') {
                                 $propvalue = $value;
                             } else {
                                 if ($key == 'class') {
                                     $attribute = 'class';
                                     $propname = 'class';
                                     $propvalue = $value;
                                 } else {
                                     $parameters = $parameters . "{$key}={$value}|";
                                 }
                             }
                         }
                         if ($key == 'value' && $value == 'PlantGrowing') {
                             $plantblock = true;
                         } else {
                             $plantblock = false;
                         }
                         if ($value == 'UpgradeBlock') {
                             $properties = "UB";
                             foreach ($prop['property'] as $subprop) {
                                 foreach ($subprop['@attributes'] as $ukey => $uvalue) {
                                     if ($ukey == 'name') {
                                         $subname = $uvalue;
                                     }
                                     if ($ukey == 'value') {
                                         $subvalue = $uvalue;
                                     }
                                 }
                                 $parameters = $parameters . "{$subname}&{$subvalue}|";
                             }
                         }
                         if ($value == 'Explosion') {
                             $properties = "EX";
                             foreach ($prop['property'] as $subprop) {
                                 foreach ($subprop['@attributes'] as $ukey => $uvalue) {
                                     if ($ukey == 'name') {
                                         $subname = $uvalue;
                                     }
                                     if ($ukey == 'value') {
                                         $subvalue = $uvalue;
                                     }
                                 }
                                 $parameters = $parameters . "{$subname}&{$subvalue}|";
                             }
                         }
                         if ($value == 'PlantGrowing' && !$plantblock) {
                             $properties = "PG";
                             foreach ($prop['property'] as $subprop) {
                                 foreach ($subprop['@attributes'] as $gkey => $gvalue) {
                                     if ($gkey == 'name') {
                                         $subname = $gvalue;
                                     }
                                     if ($gkey == 'value') {
                                         $subvalue = $gvalue;
                                     }
                                 }
                                 $parameters = $parameters . "{$subname}&{$subvalue}|";
                             }
                         }
                     }
                     $prop = new \App\BlockProperties();
                     $prop->block_id = $block->id;
                     $prop->attribute = $attribute;
                     $prop->key = $propname;
                     $prop->key = $propname;
                     $prop->value = $propvalue;
                     $prop->properties = rtrim($properties, "|");
                     $prop->parameters = rtrim($parameters, "|");
                     $prop->save();
                 }
             }
         }
         if (isset($item['drop'])) {
             foreach ($item['drop'] as $property) {
                 $parameters = '';
                 $okToSave = false;
                 $propname = '';
                 $propvalue = '';
                 foreach ($property as $key => $value) {
                     if (is_array($value)) {
                         $parameters = '';
                         foreach ($value as $skey => $svalue) {
                             if ($skey == 'event') {
                                 $propname = $svalue;
                             } else {
                                 if ($skey == 'name') {
                                     $propvalue = $svalue;
                                 } else {
                                     $parameters = $parameters . "{$skey}={$svalue}|";
                                 }
                             }
                         }
                         $prop = new \App\BlockProperties();
                         $prop->block_id = $block->id;
                         $prop->attribute = 'drop';
                         $prop->key = $propname;
                         $prop->value = $propvalue;
                         $prop->parameters = rtrim($parameters, "|");
                         $prop->save();
                     } else {
                         $okToSave = true;
                         if ($key == 'event') {
                             $propname = $value;
                         } else {
                             if ($key == 'name') {
                                 $propvalue = $value;
                             } else {
                                 $parameters = $parameters . "{$key}={$value}|";
                             }
                         }
                     }
                 }
                 if ($okToSave) {
                     $prop = new \App\BlockProperties();
                     $prop->block_id = $block->id;
                     $prop->attribute = 'drop';
                     $prop->key = $propname;
                     $prop->value = $propvalue;
                     $prop->parameters = rtrim($parameters, "|");
                     $prop->save();
                 }
             }
         }
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $cubes = Cube::all();
     $cube = $cubes->find($id);
     $blocks = $cube->blocks()->get();
     $message = 'The cube was updated successfully';
     $validator = Validator::make($request->all(), ['x' => 'required|integer|max:32767', 'y' => 'required|integer|max:32767', 'z' => 'required|integer|max:32767', 'value' => 'required|integer|max:9223372036854775807']);
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $x = $request->input('x');
     $y = $request->input('y');
     $z = $request->input('z');
     $value = $request->input('value');
     foreach ($blocks as $block) {
         if ($block->x == $x && $block->y == $y && $block->z == $z) {
             $block->value = $value;
             $block->save();
             $blocks = $cube->blocks()->paginate(10);
             return view('cubes.show', array('cubes' => $cubes, 'cube_act' => $cube, 'blocks' => $blocks, 'message' => $message));
         }
     }
     $block = Block::create(array('x' => $x, 'y' => $y, 'z' => $z, 'value' => $value, 'cube_id' => $cube->id));
     $blocks = $cube->blocks()->paginate(10);
     return view('cubes.show', array('cubes' => $cubes, 'cube_act' => $cube, 'blocks' => $blocks, 'message' => $message));
 }