本文整理汇总了PHP中Category::lists方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::lists方法的具体用法?PHP Category::lists怎么用?PHP Category::lists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::lists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* 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);
}
示例2: edit
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]);
}
示例3: edit
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'));
}
示例4: get_new
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);
}
示例5: create
/**
* 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');
}
示例6: editProduct
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
}
}
示例7: run
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()]);
}
}
示例8: run
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]);
}
}
示例9: __construct
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();
}
示例10: create
/**
* 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'));
}
示例11: getIndex
public function getIndex()
{
$categories = Category::lists('name', 'id');
return View::make('products.index')->with('products', Product::all())->with(compact('categories'));
}
示例12: getIndex
public function getIndex()
{
$products = Product::all();
$categories = Category::lists('name', 'id');
return View::make('products.index')->with('products', $products)->with('categories', $categories);
}
示例13: get_edit
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());
}
示例14: function
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');
}
}]);
示例15: subcategory
/**
*
* @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);
}
}