/** * Show the form for editing the specified resource. * GET /articles/{id}/edit * * @param string $slug * @return Response */ public function edit($slug) { $articles = Article::where('slug', $slug)->first(); $category = Category::lists('category', 'id'); $selected = Category::where('id', $articles->category_id)->first()->id; return View::make('article.editpost')->with('articles', $articles)->with('category', $category)->with('selected', $selected); }
public function edit($id) { if (Request::isMethod('post')) { $rules = array('title' => 'required|min:4', 'link' => 'required', 'meta_keywords' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to("admin/category/{$id}/edit")->withErrors($validator)->withInput(Input::except('')); } else { $table = Category::find($id); $table->title = Input::get('title'); $table->link = Input::get('link'); $table->content = Input::get('content'); $table->parent_id = Input::get('parent_id') ? Input::get('parent_id') : null; $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title; $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description; $table->meta_keywords = Input::get('meta_keywords'); $table->active = Input::get('active', 0); if ($table->save()) { $name = trans("name.category"); return Redirect::to("admin/category")->with('success', trans("message.edit", ['name' => $name])); } return Redirect::to("admin/category")->with('error', trans('message.error')); } } $self = Category::where('id', '=', $id)->first(); foreach (Category::lists('title', 'id') as $key => $value) { $child = Category::where('id', '=', $key)->first(); if (!$child->isSelfOrDescendantOf($self)) { $categories[$key] = $value; } } $categories = array(0 => 'Нет родительской категории') + $categories; return View::make("admin.shop.category.edit", ['item' => Category::find($id), 'categories' => $categories]); }
public function edit($id) { $post = Post::find($id); $this->authorOrAdminPermissioinRequire($post->user_id); $category_selects = Category::lists('name', 'id'); return View::make('posts.create_edit', compact('category_selects', 'post')); }
public function get_new() { $categories = Category::lists('name', 'id'); $accounts = Account::lists('name', 'id'); $data = array('new' => true, 'categories' => $categories, 'accounts' => $accounts); $view = View::make('donation.new'); return $view->nest('form', 'donation.form', $data); }
/** * Show the form for creating a new resource. * * @return Response */ public function create($username) { if (credentialsMatch($username)) { $categories = Category::lists('id', 'name'); return View::make('partials/_form', compact('categories')); } return Redirect::route('login'); }
public function editProduct($id) { if ($product = Product::find($id)) { $categories = Category::lists('name', 'id'); return View::make('admin.editProduct', compact('product'))->withCategories($categories); } else { # 404 error page } }
public function run() { $faker = Faker::create(); $users = User::lists('id'); $categories = Category::lists('id'); foreach (range(1, 100) as $index) { Post::create(['title' => $faker->sentence(), 'slug' => $faker->slug() . $index, 'body' => $faker->text(), 'body_original' => $faker->text(), 'user_id' => $faker->randomElement($users), 'category_id' => $faker->randomElement($categories), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]); } }
public function run() { DB::table('category_post')->truncate(); $post_ids = Post::lists('id'); $category_ids = Category::lists('id'); $now = date('Y-m-d H:i:s'); $faker = Faker::create(); foreach (range(1, 10) as $index) { DB::table('category_post')->insert(['post_id' => $faker->randomElement($post_ids), 'category_id' => $faker->randomElement($category_ids), 'created_at' => $now, 'updated_at' => $now]); } }
public function __construct(Ticket $tickets) { $this->tickets = $tickets; $this->beforeFilter('staff'); // Store attributes array to be used in the functions below. $this->attributes = ['staff_users_list' => User::lists('users_username', 'users_id'), 'support_users_list' => User::lists('users_username', 'users_id'), 'categories_list' => Category::lists('categories_name', 'categories_id'), 'priorities_list' => Priority::lists('priorities_name', 'priorities_id'), 'statuses_list' => Status::lists('statuses_name', 'statuses_id')]; // Add in an 'unassigned' item with an index of 0 to the support users list. // This is so we can display this in the view without having to have a database entry for 'unassigned'; $this->attributes['support_users_list'][0] = 'unassigned'; // Get current logged in user's auth level. $this->user_auth_level = Auth::user()->get_userlevel(); // Check if current logged in user is Support or Admin user. $this->support_check = Auth::user()->isSupport(); }
/** * Show the form for creating a new resource. * GET /membermateris/create * * @return Response */ public function create() { $categories = Category::lists('title', 'id'); return View::make('member.materi.create', compact('categories')); }
public function getIndex() { $categories = Category::lists('name', 'id'); return View::make('products.index')->with('products', Product::all())->with(compact('categories')); }
public function getIndex() { $products = Product::all(); $categories = Category::lists('name', 'id'); return View::make('products.index')->with('products', $products)->with('categories', $categories); }
public function get_edit($id) { $post = Post::find($id); return View::make('posts.edit')->with('title', $post->title . 'Edit - Mayaten.com Blog')->with('post', Post::find($id))->with('categories', Category::lists('name', 'id'))->with('recent_comments', Comment::order_by('created_at', 'desc')->get()); }
if (Auth::attempt(array('email' => $email, 'password' => $password))) { return Redirect::intended('blog/create'); } });*/ Route::group(['before' => 'auth', 'prefix' => 'admin'], function () { /*Route::get('admin/logout', 'AuthController@logout');*/ Route::get('/', 'AuthController@in'); Route::post('/', 'AuthController@out'); }); Route::get('users/register', 'UserController@getRegister'); Route::post('users/register', 'UserController@postRegister'); Route::get('login', 'UserController@getLogin'); Route::post('login', 'UserController@postLogin'); Route::get('logout', 'UserController@getLogout'); Route::get('blog/create', ['before' => 'auth', 'as' => 'blog.create', 'uses' => function () { $categories = Category::lists('name', 'id'); $user_id = Auth::user()->id; return View::make('blog/create')->with("categories", $categories)->with('user_id', $user_id); }]); Route::post('blog/create', ['before' => 'csrf|auth', 'as' => 'blog.post.create', 'uses' => function () { $post = Input::except('_token'); $rules = ['title' => 'required', 'body' => 'required', 'category_id' => 'required', 'user_id' => 'required']; $validator = Validator::make($post, $rules); if ($validator->fails()) { return Redirect::route('blog.create')->withInput()->withErrors($validator); } else { Post::create($post); return Redirect::to('blog/show'); } }]);
/** * * @param $subcategoryId int * @return nothing * @author Tremor */ public function subcategory($subcategoryId = 0) { $this->data['active'] = __FUNCTION__; if (isset($subcategoryId) && !empty($subcategoryId) && is_numeric($subcategoryId)) { $this->data['categoryList'] = Category::lists('name', 'id'); $this->data['subcategory'] = Subcategory::find($subcategoryId); return View::make('admin.subcategory.one')->with($this->data); } else { $this->data['subcategoryList'] = Subcategory::orderBy('sort', 'asc')->get(); return View::make('admin.subcategory.list')->with($this->data); } }
/** * Resource edit view * GET /resource/{id}/edit * @param int $id * @return Response */ public function edit($id) { $data = $this->model->find($id); $categoryLists = Category::lists('name', 'id'); $article = Article::where('slug', $data->slug)->first(); return View::make($this->resourceView . '.edit')->with(compact('data', 'categoryLists', 'article')); }
/** * 资源编辑页面 * GET /resource/{id}/edit * @param int $id * @return Response */ public function edit($id) { $data = $this->model->find($id); $categoryLists = Category::lists('name', 'id'); return View::make($this->resourceView . '.edit')->with(compact('data', 'categoryLists')); }
public function get_new() { return View::make('posts.new')->with('title', 'Add New Post!')->with('category', Category::lists('name', 'id')); }