public function prepareData() { $locality = new Locality(); $locality->postal_code = '1920'; $locality->city = 'Martigny'; $locality->save(); $locality = new Locality(); $locality->postal_code = '1965'; $locality->city = 'Savièse'; $locality->save(); $locality = new Locality(); $locality->postal_code = '2300'; $locality->city = 'Neuchâtel'; $locality->save(); }
/** * Store a newly created resource in storage. * POST /brewer * * @return Response */ public function store() { if (Input::get('brewer_id')) { $brewer = Brewer::find(Input::get('brewer_id')); } else { $brewer = new Brewer(); } $locality = Locality::find(Input::get('locality_id')); if (!$locality) { return Redirect::back()->withInput()->withMessage('Invalid Locality'); } $brewer->name = Input::get('name'); $brewer->url = Input::get('url'); $brewer->locality_id = $locality->id; $brewer->save(); if (Input::hasFile('logo')) { $f = Input::file('logo'); //Change the image name: s<number_of_service>-<filename>. $filename = 'brewer-' . $brewer->id . '-' . $f->getClientOriginalName(); //Move it to our public folder $f->move(public_path() . '/upload/', $filename); //This is the path to show it on the web $complete_path = '/upload/' . $filename; //create the gallery $image = array('path' => $complete_path, 'brewer_id' => $brewer->id, 'beer_id' => NULL); if ($brewer->logoUrl()) { $brewer->logo()->fill($image)->save(); } else { Image::create($image); } } return Redirect::to('/dashboard/brewers'); }
/** * returns the locality name including hierarchy * @return String */ public function completeName() { $name = $this->name; if ($this->locality_id != null) { $name .= ", " . Locality::find($this->locality_id)->completeName(); } return $name; }
/** * Deletes the speified style * @param $id * @return mixed */ public function deleteLocality($id) { if (!count(Locality::where('locality_id', $id))) { Locality::find($id)->delete(); return Redirect::back()->withMessage('Locality deleted correctly'); } else { return Redirect::back()->withMessage("Locality can't be deleted. Delete the child localities first"); } }
/** * return the country Locality Model Object of this brewer */ public function country() { $locality = $this->locality; if (!$locality || $locality->type == "continent") { return null; } while ($locality->type != "country") { $locality = Locality::find($locality->locality_id); } return $locality; }
public function searchElement($element_name, $text = null) { $html = ""; $elements = []; $db_elements = DB::table($element_name)->where('name', 'like', "%" . $text . "%")->get(); foreach ($db_elements as $db_element) { switch ($element_name) { case "beer": $elements[] = Beer::find($db_element->id); break; case "brewer": $elements[] = Brewer::find($db_element->id); break; case "locality": $elements[] = Locality::find($db_element->id); break; case "style": $elements[] = Style::find($db_element->id); break; } } foreach ($elements as $element) { $html .= '<li class="list-group-item clearfix">'; if ($element_name == "locality" && $element->flag()) { $html .= '<img src="' . $element->flag()->path . '" style="height:15px"> '; } elseif ($element_name == "brewer" && $element->logo()) { $html .= '<img src="' . $element->logo()->path . '" style="height:15px"> '; } $html .= '<span>' . $element->name . '</span>' . '<div class="btn-group pull-right">'; if ($element_name == "brewer" || $element_name == "beer") { $html .= '<a href="' . URL::to('/dashboard/' . $element_name . 's/edit/' . $element->id) . '">'; } $html .= '<button type="button" class="btn btn-info" '; if ($element_name != "brewer" && $element_name == "beer") { $html .= 'onclick="editElement(' . $element->id . ')"'; } $html .= '>Edit</button>'; if ($element_name == "brewer" || $element_name == "beer") { $html .= '</a>'; } $html .= '<a href="' . URL::to('/dashboard/' . $element_name . 's/delete/' . $element->id) . '"><button type="button" class="btn btn-danger">Delete</button></a>'; $html .= '</div></li>'; } return Response::json(['html' => $html]); }
<?php } ?> <?php } ?> <?php } elseif ($user->role == 2) { ?> <!-- if platoon leader --> <div class='panel panel-default'> <div class='panel-heading'><strong> Your <?php echo Locality::run("Platoon", $member->game_id); ?> </strong> <span class=" pull-right"><?php echo Platoon::countPlatoon($member->platoon_id); ?> members</span></div> <div class='list-group' id='squads'> <?php if (count((array) $squads)) { $i = 1; ?> <!-- get squads --> <?php foreach ($squads as $squad) {
<?php echo $alerts; ?> <div class="margin-top-20"> <!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist"> <li role="presentation" class="active"><a href="#activity" aria-controls="home" role="tab" data-toggle="tab">Server Activity</a></li> <?php if ($user->role >= 1 && $memberInfo->position_id == 5) { ?> <li role="presentation"><a href="#squadmembers" aria-controls="squadmembers" role="tab" data-toggle="tab"><?php echo Locality::run('Squad', $memberInfo->game_id); ?> members</a></li> <?php } ?> <li role="presentation"><a href="#recruits" aria-controls="recruits" role="tab" data-toggle="tab">Recruiting records</a></li> <li role="presentation"><a href="#history" aria-controls="history" role="tab" data-toggle="tab">Member history</a></li> </ul> </div> <div class='row margin-top-20'>
foreach ($rolesArray as $role) { ?> <?php if ($role->id <= $user->role || User::isDev()) { ?> <option value="<?php echo $role->id; ?> " <?php echo $userInfo->role == $role->id ? "selected" : NULL; ?> <?php echo $user->role == $role->id && !User::isDev() ? "disabled" : NULL; ?> ><?php echo Locality::run($role->role_name, $member->game_id); ?> </option> <?php } ?> <?php } ?> </select> </div> <?php } ?> <?php
echo $member->rank_id; ?> </td> <td class='text-center col-hidden'><?php echo $member->last_activity; ?> </td> <?php if (is_object($position) && property_exists($position, 'id')) { ?> <td><em><span class='<?php echo $position->class; ?> ' title='<?php echo Locality::run($position->desc, $member->game_id); ?> '><i class='<?php echo $position->icon; ?> '></i> <?php echo $member->forum_name; ?> </span></em></td> <?php } else { ?> <td><em><?php echo $member->forum_name; ?> </span></em></td>
/** * @return \yii\db\ActiveQuery */ public function getLocality() { return $this->hasOne(Locality::className(), ['Id' => 'localityId']); }
class="label label-default movable"><?php echo $member->forum_name; ?> </a> </h4> <?php } ?> <?php } ?> </p> </div> <div class="panel-footer text-muted"><strong>TIP</strong>: Drag and drop a member onto a <?php echo Locality::run('platoon', $division->id); ?> to assign them. </div> </div> </div> </div> </div> <?php } ?> <?php } ?> </div>
<li class='list-group-item text-right'><span class='pull-left'><strong>Last promoted: </strong></span> <span class='text-muted'><?php echo !is_null($memberInfo->last_promotion) ? date('Y-m-d', strtotime($memberInfo->last_promotion)) : "Not available"; ?> </span> </li> <?php echo property_exists($platoonInfo, 'item') ? $platoonInfo->item : null; ?> <?php $position = $memberInfo->position_id ? Position::convert($memberInfo->position_id)->desc : 'Unknown'; ?> <li class='list-group-item text-right'><span class='pull-left'><strong>Position: </strong></span> <span class='text-muted'><?php echo Locality::run($position, $memberInfo->game_id); ?> </span></li> <?php $squadleader = property_exists($memberInfo, 'squad_leader_id') ? $memberInfo->squad_leader_id : null; ?> <?php if ($squadleader != 0) { ?> <a href="member/<?php echo $squadleader; ?> " class="list-group-item text-right"> <span class='pull-left'><strong>Squad Leader: </strong></span> <span class='text-muted'><?php
</div> </div> </div> </div> <?php } ?> <?php } ?> <div class='row'> <div class='col-md-8'> <div class='panel panel-primary'> <div class='panel-heading'>Currently Active <?php echo Locality::run('Platoons', $division->id); ?> </div> <div class='list-group'> <?php $platoons = Platoon::find_all($division->id); ?> <?php if (count($platoons)) { ?> <?php foreach ($platoons as $platoon) { ?> <?php $leader = Member::findByMemberId($platoon->leader_id); ?>
<div class="col-xs-4"> <div class="row"> <?php if ($squadCount < MAX_SQUADS_IN_PLT) { ?> <div class="col-xs-12"> <div class="panel panel-info"> <div class="panel-heading"><strong>New <?php echo Locality::run('Squad', $division->id); ?> </strong></div> <div class="panel-body"> <p>Would you like to add a new <?php echo Locality::run('Squad', $division->id); ?> ? <a data-platoon-id="<?php echo $platoon->id; ?> " data-division-id="<?php echo $division->id; ?> " class="btn btn-success btn-xs create-squad pull-right" href="create/squad"><i class="fa fa-plus"></i> Add</a></p> </div> </div> </div> <?php } ?>