本文整理汇总了PHP中app\models\Categories::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Categories::all方法的具体用法?PHP Categories::all怎么用?PHP Categories::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Categories
的用法示例。
在下文中一共展示了Categories::all方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* @param $id
*/
public static function edit($id)
{
$post = Posts::findByPK($id);
if (!Request::is_authenticated()) {
Session::push('flash-message', 'You must login before!');
Response::redirect('login?next=post/edit/' . $id);
} else {
if (Request::user()->id !== $post['id_account']) {
Session::push('flash-message', 'You does not have permission to edit the other Member\'s post!');
Response::redirect('');
}
}
if ("POST" == Request::method()) {
$id_member = Request::user()->id;
$data = Request::POST()->post;
$title = Request::POST()->title;
$cat = Request::POST()->category;
Posts::edit($id, $id_member, $title, $data, $cat);
# set flash messages
Session::push('flash-message', 'Your post has changed successfully!');
Response::redirect('post/read/' . $id);
} else {
$users = Accounts::find(['type' => 2]);
$categories = Categories::all();
View::render('member/edit-post', ['post' => $post, 'users' => $users, 'categories' => $categories]);
}
}
示例2: edit
public function edit($post_id)
{
$post = Posts::with('tags')->find($post_id);
$data = ['categories' => Categories::all(), 'post' => $post, 'title' => $post->id . ' : Edit Post', 'save_url' => route('root-posts-store', ['post_id' => $post_id]), 'tags' => Tags::all()];
$this->title->prepend($data['title']);
View::share('menu_item_active', 'posts');
return view('root.posts.post', $data);
}
示例3: edit
public function edit($post_id)
{
$post = Posts::with('tags')->find($post_id);
Title::prepend('Edit Post');
Title::prepend($post->id);
$data = ['categories' => Categories::all(), 'post' => $post, 'title' => Title::renderr(' : ', true), 'save_url' => route('root-posts-store', ['post_id' => $post_id]), 'tags' => Tags::all()];
View::share('menu_item_active', 'posts');
return view('root.posts.post', $data);
}
示例4: profile
/**
* Render the profile page
* @param $username
*/
public static function profile($username)
{
# fetch account data by username
$account = Accounts::findByUsername($username);
# fecth all categories
$categories = Categories::all();
# fetch all of this member's post
$posts = Posts::find(['id_account' => $account['id']]);
# fetch all accounts
$users = Accounts::find(['type' => 2]);
View::render('member/profile', ['account' => $account, 'posts' => $posts, 'users' => $users, 'categories' => $categories]);
}
示例5: create
public function create(Request $request)
{
$qCategories = Categories::all();
$qTags = Tags::all();
$articleID = $request->aID ? $request->aID : 0;
if ($articleID) {
$qArticles = Articles::where("aID", $articleID)->first();
} else {
$qArticles = new Articles();
}
return view('admin.article.create', compact('qArticles', 'articleID', 'qCategories', 'qTags'));
}
示例6: run
public function run()
{
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
DB::table('orderitems')->truncate();
$faker = Faker::create();
$orders = \App\Models\Orders::all()->lists('id');
$vendors = \App\Models\Vendors::all()->lists('id');
$categories = \App\Models\Categories::all()->lists('id');
foreach (range(1, 20) as $index) {
$quantity = $faker->numberBetween(1, 20);
$price = $faker->randomFloat(2, 1, 5000);
$finalprice = $faker->randomFloat(2, 1, 5000);
DB::table('orderitems')->insert(['name' => $faker->name, 'order_id' => $faker->randomElement($orders), 'category_id' => $faker->randomElement($categories), 'vendor_id' => $faker->randomElement($vendors), 'description' => $faker->text(), 'url' => $faker->url, 'quantity' => $quantity, 'estimatedprice' => $price, 'estimatedtotal' => $price * $quantity, 'fixedprice' => $finalprice, 'fixedtotal' => $finalprice * $quantity, 'status' => 0]);
}
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
}
示例7: edit
public static function edit($id)
{
if (!Request::is_admin()) {
Response::redirect('');
}
if ("POST" == Request::method()) {
$id = Request::POST()->id;
$word = Request::POST()->word;
Badwords::update($id, $word);
# push a flash message
Session::push('flash-message', 'That badwords sensor has changed successfully!');
Response::redirect('badwords');
} else {
$badword = Badwords::findByPK($id);
$categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
View::render('badwords/add', ['badword' => $badword, 'categories' => $categories]);
}
}
示例8: edit
public static function edit($id)
{
if (!Request::is_admin()) {
Response::redirect('');
}
if ("POST" == Request::method()) {
$id = Request::POST()->id;
$name = Request::POST()->name;
$decsription = Request::POST()->description;
Categories::update($id, $name, $decsription);
# push flash-message
Session::push('flash-message', 'That category has changed successfuly!');
Response::redirect('categories');
} else {
$category = Categories::findByPK($id);
$categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
View::render('categories/add', ['category' => $category, 'categories' => $categories]);
}
}
示例9: index
public static function index()
{
# if user was login before and the session is still valid
if (Request::is_authenticated()) {
if (Request::is_admin()) {
AdminController::index();
} else {
MemberController::index();
}
} else {
$posts = Posts::all((new DbCriteria())->order_by('created_at')->DESC());
# set criteria
$criteria = (new DbCriteria())->order_by('viewers')->DESC()->LIMIT(5);
$hotposts = Posts::all($criteria)->fetchAll();
$users = Accounts::find(['type' => 2]);
$categories = Categories::all();
# /app/views/home.php
View::render('home', ['hotposts' => $hotposts, 'posts' => $posts, 'users' => $users, 'categories' => $categories]);
}
}
示例10: addMember
public static function addMember()
{
if ("POST" == Request::method()) {
$username = Request::POST()->username;
$email = Request::POST()->email;
$pass = Request::POST()->password;
$name = Request::POST()->name;
$type = Request::POST()->type;
$photo = File::upload('img', 'photo');
# if username has used by another member
if (Accounts::find(['username' => $username])) {
Session::push('flash-message', 'That username has used by other member, please use another!');
Response::redirect('accounts/add');
}
Accounts::create($username, $pass, $name, $email, $photo, $type);
# push flash-message
Session::push('flash-message', 'That members has successfuly added!');
Response::redirect('accounts');
} else {
$categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
View::render('admin/account-add', ['categories' => $categories]);
}
}
示例11: index
public function index()
{
$data['page_title'] = 'Data Kategori';
$data['categories'] = Categories::all();
return view('categories.index', $data);
}