Esempio n. 1
0
 /**
  * @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]);
     }
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 /**
  * 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]);
 }
Esempio n. 5
0
 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'));
 }
Esempio n. 6
0
 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');
 }
Esempio n. 7
0
 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]);
     }
 }
Esempio n. 8
0
 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]);
     }
 }
 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]);
     }
 }
Esempio n. 10
0
 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]);
     }
 }
 public function index()
 {
     $data['page_title'] = 'Data Kategori';
     $data['categories'] = Categories::all();
     return view('categories.index', $data);
 }