public function addAction(rtRequest $request) { if ($request->isPost()) { $c = new Catagory(); $c->name = $request->getParameter('name'); $c->save(); $this->setFlash('notice', '成功添加分类'); $this->redirect("blog/index"); } }
public function productsBySubCatagory($id) { $query = Product::where('subcatagory_id', '=', $id)->paginate(12); $catagory = Catagory::all(); $subcatagory = Subcatagory::all(); return View::make('Products.ProductsByCatagory', ['catagories' => $catagory, 'products' => $query, 'subcatagories' => $subcatagory]); }
/** * Edit sub catagory page */ public function edit($slug) { $catagories = Subcatagory::where('slug', '=', $slug); if ($catagories->count() > 0) { return View::make('Subcatagories.Edit')->with('catagories', Catagory::all())->with('subcatagories', $catagories->get()); } else { App::abort(404); } }
public function newAction(rtRequest $request) { $this->catagories = Catagory::getAll(); if ($request->getMethod() == rtRequest::POST) { $post = new Post(); $post->title = $request->getParameter('title'); $post->content = $request->getParameter('content'); $post->catagory_id = $request->getParameter('catagory_id'); if ($post->isValid()) { $post->save(); $this->setFlash('notice', '成功发布博文:)'); $this->redirect('blog/index'); } } }
echo '</select><br><input type="hidden" name="eventcat" value="eventcat"/><input type="submit" value="Assign" /></form>'; } break; case 'rmcathead': // case -> remove catagory head if (isset($_POST['rmcathead'])) { if (isset($_POST['catname']) or isset($_POST['headname'])) { $c = new Catagory(); $h = new Head(); // add here } else { echo 'Please check your entries'; } } else { // displaying the list of all catagories and heads $c = new Catagory(); $h = new Head(); echo '<form method="POST" >Select a Catagory or Head<br><select name="catname">'; foreach ($c->getList() as $cat) { // name of all catagories from the DB echo '<option>', $cat['name'], '</option>'; } echo '</select><br><select name="headname">'; foreach ($h->getHeads('chead') as $head) { // name of all catagory heads from the DB echo '<option>', $head['username'], '</option>'; } // we set a hidden input cathead to rcathead, so that we know we want to assign a catagory to head echo '</select><br><input type="hidden" name="cathead" value="cathead"/><input type="submit" value="Assign" /></form>'; } break;
@if (Session::has('event')) {{ Session::get('event') }} @endif </div> <section> <div class="container"> {{ Form::open(array('url' => 'dashboard/addProduct', 'files' => true)) }} <div class="form-group"> <div class="row"> <div class="col-md-2"> <label for="catagory">Catagories</label> </div> <div class="col-md-6"> <?php $query = Catagory::all(); ?> <select name="catagory" id="catagory"> @foreach ($query as $row) <option value="{{ $row->id }}">{{ $row->catagory_name }}</option> @endforeach </select> </div> </div> </div> {{-- Sub catagory div --}} <div class="form-group" id="subcatagory_div" style="display: none;"> <div class="row"> <div class="col-md-offset-2 col-md-6"> <select class="form-control" name="subcatagory" id="subcatagory"></select>
</title> <link rel="stylesheet" href="main.css" type="text/css" /> <script src='js/jq.js' type='text/javascript'></script> <script src='js/function.js' type='text/javascript' ></script> </head> <body> <?php include "header.php"; include "sidebar.php"; ?> <?php include_once "class.inc.php"; if (isset($_GET['id'])) { echo '<div id="center"><center><table width="60%">'; $c = new Catagory(); $c->setId($_GET['id']); $cinfo = $c->getInfo($_GET['id']); $events = $c->getEvents(); $e = new Event(); echo '<tr><td>Catagory </td><td><b>', $c->escape(ucwords($cinfo['name'])), '</b></td></tr><tr><td>Info</td><td>', $c->escape($cinfo['info']), '</td></tr><tr><td>Catagory Head(s) </td><td>'; $count = 0; $cheads = $c->getHeads(); foreach ($cheads as $chead) { if ($count) { echo ", "; } echo "<a href='head.php?id={$chead['userid']}'>", $c->escape($chead['name']), "</a>"; $count++; } echo '</td></tr><tr><td><br><br></td></tr';
public function productsByCatagory($id) { $query = Product::where('catagory_id', '=', $id)->get(); $catagory = Catagory::all(); return View::make('users.products', ['query' => $catagory, 'products' => $query, 'cat_id' => $id]); }
} } else { if (isset($_POST['event']) and isset($_POST['delno']) and isset($_POST['confirm'])) { $e = new Event(); $e->setId($_POST['event']); $result = $e->addUser($_POST['delno']); if ($result) { // if we have a result if ($result == "regDone") { echo "Already Registered<br>" . $goBack; } else { echo "Done<br>" . $goBack; } } } else { $c = new Catagory(); //get the catagory info $catInfo = $c->getInfo($_GET['id']); if ($catInfo) { // if catagoty present display welcome message echo 'Welcome to <b>', ucwords($catInfo['name']), '</b> Registeration<br><br>'; $c->setId($_GET['id']); //get all events in catagory $events = $c->getEvents(); if ($events) { // if there are events display them echo "<form method='POST'><center><table>"; foreach ($events as $event) { echo "<tr><td><input type='radio' name='event' value='{$event['eventid']}' \\></td><td>{$event['name']}</td></tr>"; } echo '</table><input type="submit" name="go" value="Go" /></center></form>';
public function executeCatagory() { $this->catagories = Catagory::getAll(); }
public function updateCatagory($slug) { $validator = Validator::make(Input::all(), array('catagory_name' => 'required|unique:catagories'), array('required' => '<div class="col-md-3 alert alert-danger">Please write a catagory name</div>', 'unique' => '<div class="col-md-3 alert alert-danger"><b>' . Input::get('catagory_name') . '</b> alredy exists</div>')); if ($validator->fails() == TRUE) { return Redirect::route('add-catagory-page')->withErrors($validator)->withInput(); } else { $catagory = Catagory::where('slug', $slug); if ($catagory->count() > 0) { $update = $catagory->update(['catagory_name' => Input::get('catagory_name'), 'slug' => Str::slug(Input::get('catagory_name'))]); if ($update) { return Redirect::to('shop')->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Catagory updated successfully.</p>'); } else { return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error happened. Please try after sometime.</p>'); } } else { App::abort(404); } } }
<?php include_once 'class.inc.php'; $c = new Catagory(); echo '<div id="sidebar"><center>'; $main = new Project11(); if (isset($_GET['logout'])) { setcookie('user', 'Deleted', time() - 3600); setcookie('key', 'Deleted', time() - 3600); } $loginText = '</b><br><form method="POST">Username<br><input type="text" name="username"><br>Password<br><input type="password" name="password"><br><input type="submit" name="login" value="Login"></form>'; $level = ''; // we want to use level for level check if (!isset($_POST['login'])) { if (True) { if (isset($_COOKIE['user']) and isset($_COOKIE['key'])) { $userlevel = $main->checkAuth($_COOKIE['user'], $_COOKIE['key']); } else { $userlevel = 'error'; } if ($userlevel != 'error' and !isset($_GET['logout'])) { echo 'Hello <b>', $_COOKIE['user'], '</b><br><a href="index.php?logout=1">log out</a><br><br>'; } else { echo $loginText; } } else { echo $loginText; } $level = $userlevel; // for check outside sidebar } else {