public function run() { $faker = Faker\Factory::create(); for ($i = 0; $i < 70; $i++) { $user = User::where('roles', 'applicant')->get()->shuffle()->first(); $board = null; while (null == $board) { $day_type = array('internal' => self::INTERNAL_DAYS, 'external' => self::EXTERNAL_DAYS, 'union' => self::UNION_DAYS); $type = $faker->randomElement(['internal', 'external', 'union']); $days = $day_type[$type] - 1; $from = date_format($faker->dateTimeBetween('-3 months', '+3 months'), 'Y-m-d'); $end = date('Y-m-d', strtotime("{$from} + {$days} days")); $board = Board::where('type', '!=', 'large')->isEmpty($from, $end)->get()->shuffle()->first(); } ApplyRecord::create(array('board_id' => $board->id, 'user_id' => $user->id, 'event_name' => $faker->company(), 'event_type' => $type, 'post_from' => $from, 'post_end' => $end)); } for ($i = 0; $i < 30; $i++) { $user = User::where('roles', 'applicant')->get()->shuffle()->first(); $board = null; while (null == $board) { $type = $faker->randomElement(['internal', 'external', 'union']); $days = self::LARGE_POSTER_DAYS - 1; $from = date_format($faker->dateTimeBetween('-3 months', '+3 months'), 'Y-m-d'); $end = date('Y-m-d', strtotime("{$from} + {$days} days")); $board = Board::where('type', 'large')->isEmpty($from, $end)->get()->shuffle()->first(); } ApplyRecord::create(array('board_id' => $board->id, 'user_id' => $user->id, 'event_name' => $faker->company(), 'event_type' => $type, 'post_from' => $from, 'post_end' => $end)); } }
/** * Get landing pages * @return mixed */ public function index(Request $request) { // $members = Venue::where('status', '=', 1)->paginate(15); if ($request->has('column') && $request->has('value')) { $members = Board::where($request->get('column'), 'like', $request->get('value'))->where('status', '=', 1)->paginate(15); } else { $members = Board::where('status', '=', 1)->paginate(15); } return view('blupl/venue::printing.list-printing', compact('members')); }
public function getList() { $page = \Input::get('page', 1); $limit = 10; $offset = ($page - 1) * $limit; $count = \Board::where('status', '=', '1')->count(); $columns = array('id', 'name', 'topic', 'count_num', \DB::raw("date_format(created_at,'%Y-%m-%d') as d")); $boards = \Board::where('status', '=', '1')->skip($offset)->take($limit)->orderBy('created_at', 'desc')->get($columns); $widgetParam = array('currPage' => $page, 'total' => $count, 'length' => $limit, 'URL' => route('frontend.board.list'), 'qs' => ''); return \View::make('aesthetics.board.view_list', array('boards' => &$boards, 'wp' => &$widgetParam)); }
public function getIndex() { $boards = \Board::where('status', '=', '1')->orderBy('created_at', 'desc')->skip(0)->take(10)->get(array('id', 'name', 'topic', 'count_num', \DB::raw("date_format(created_at,'%Y-%m-%d') as d"))); if ($boards === null) { $boards = array(); } $newses = \Article::where('status', '=', '1')->where('category', '=', '3')->where('open_at', '<=', date('Y-m-d'))->orderBy('sort', 'desc')->orderBy('open_at', 'desc')->orderBy('created_at', 'desc')->skip(0)->take(10)->get(array('id', 'title', 'open_at')); if ($newses === null) { $newses = array(); } return \View::make('aesthetics.index.index', array('boards' => &$boards, 'newses' => &$newses)); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { # Config $config = Config::get('poster'); $event_types = $config['event_types']; $days = $config['days']; # Form Validation $rules = array('code' => 'required|exists:boards,code', 'program' => 'required|between:3,32', 'type' => 'required|in:' . implode(',', $event_types), 'from' => 'required|date_format:Y-m-d', 'end' => 'required|date_format:Y-m-d'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Response::json(['success' => false, 'messages' => $validator->errors()]); } if (Input::get('from') > Input::get('end')) { $msg = 'Begin date is later than end date.'; return Response::json(['success' => false, 'messages' => $msg]); } # Poster Status Validation $board = Board::where('code', Input::get('code'))->first(); $from = Input::get('from'); $end = Input::get('end'); $days_diff = round((strtotime($end) - strtotime($from)) / 60 / 60 / 24); if ($board->getUsingStatus($from, $end)) { $msg = 'Board has been applied.'; return Response::json(['success' => false, 'messages' => $msg]); } # Days Validation if ($board->type == 'large' and $days_diff > $days['large_poster']) { $msg = "You can't applied over {$days['large_poster']} days!"; return Response::json(['success' => false, 'messages' => $msg]); } if ($days_diff > $days[Input::get('type')]) { $msg = "You can't applied over {$days[Input::get('type')]} days!"; return Response::json(['success' => false, 'messages' => $msg]); } # Times Validation $boards = Board::where('type', $board->type)->lists('id'); $records = ApplyRecord::date($from, $end)->where('user_id', Auth::id()); $amount = $records->whereIn('board_id', $boards)->count(); $quota = Config::get('poster.meanwhile_quota')[$board->type]; if ($amount >= $quota) { return Response::json(['success' => false, 'messages' => 'You can\'t apply more than ' . $quota . ' times in same time.']); } # Continuously Validation if ($board->type != 'stairs') { $cold_down = Config::get('poster.cold_down'); $from_cd = date('Y-m-d', strtotime($from . " - {$cold_down} days")); $end_cd = date('Y-m-d', strtotime($end . " + {$cold_down} days")); $record_cd = ApplyRecord::where('board_id', $board->id)->date($from_cd, $end_cd)->where('user_id', Auth::id())->count(); if ($cold_down != 0 and 0 < $record_cd) { $msg = 'You can\'t apply same board continuously.'; return Response::json(['success' => false, 'messages' => $msg]); } } # Create ApplyRecord::create(['board_id' => $board->id, 'user_id' => Auth::id(), 'event_name' => Input::get('program'), 'event_type' => Input::get('type'), 'post_from' => $from, 'post_end' => $end]); return Response::json(['success' => true]); }
public function showBoard($query, $id = NULL, $presentation = NULL) { Asset::add('//cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.0.0/isotope.pkgd.min.js', 'footer'); Asset::add('//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.min.js', 'footer'); Asset::add('/js/libs/jquery.dropdown.js', 'footer'); //Asset::add('/js/posts.js', 'footer'); Asset::add('/js/posts-new.js', 'footer'); //check if board exists if (strlen($query) > 2) { $query = explode(' ', trim($query)); $result = preg_replace('/#([\\w-]+)/i', '$1', $query[0]); $query = Sanitize::string($result); } else { App::abort(404); } if (isset($id)) { $board = Board::find($id); if (!is_null($board)) { if ($board->hashtag != $query || $board->config()->first()->user_id == 0) { App::abort(404); } } else { App::abort(404); } } else { $board = Board::where('hashtag', '=', $query)->whereHas('config', function ($q) { $q->where('user_id', '=', 0); })->first(); if (is_null($board)) { $board = Board::create(array('hashtag' => $query)); $visit = Visit::create(array('ip' => Request::ip())); $config = BoardConfig::create(array('board_id' => $board->id)); } } if ($board->config()->first()->is_active == 1) { if (!is_null($board->cover_file_name)) { $data['layout'] = $this->layout->cover = 'with-cover'; } else { $data['layout'] = $this->layout->cover = 'no-cover'; } if (Auth::check()) { $user = Auth::user(); $data['username'] = preg_replace('/@.*?$/', '', $user->email); $data['userBoards'] = Board::byUserId($user)->orderBy('created_at', 'asc')->get(); $data['user'] = $user; if ($user->id == $board->config()->first()->user_id) { $userOwned = true; } if (!is_null($user->provider()->first()) && $user->provider()->first()->provider == 'facebook') { $data['avatar'] = '<img src="http://graph.facebook.com/' . $user->provider()->first()->provider_id . '/picture?type=small" alt="avatar" />'; } } if (Session::get('session-stat') != $board->id) { $stats = Stat::firstOrCreate(array('board_id' => $board->id))->increment('hits'); Session::put('session-stat', $board->id); } $data['board'] = $board; $data['boardData'] = $this->layout->boardData = $board; $data['title'] = $this->layout->title = $board->hashtag; $data['bodyClass'] = $this->layout->bodyClass = $board->hashtag . (isset($userOwned) ? ' user-owned' : ''); if (isset($presentation) && $presentation != 'live') { App::abort(404); } if (isset($id) && $presentation == 'live' && $board->config()->first()->presentation == 1) { $data['bodyClass'] = $this->layout->bodyClass = $board->hashtag . (isset($userOwned) ? ' user-owned' : '') . ' board-presentation'; $this->layout->content = View::make('boards.board-presentation', $data); } else { $this->layout->content = View::make('boards.index', $data); } } else { App::abort(404); } }