/** * Projects list * @route GET projects all * @param type $token */ public function all_get($token) { $token_entry = new Token(); $token_entry->get_by_valid_token($token)->get(); if ($token_entry->exists()) { $projects = new Project(); $projects->order_by('name', 'ASC'); $projects->get(); $response = array(); foreach ($projects as $project) { $p = new stdClass(); $p->id = $project->id; $p->name = $project->name; $p->customer_name = $project->Customer->get()->customer_name; if (!$p->customer_name) { $p->customer_name = '-'; } $p->closed = $project->closed ? TRUE : FALSE; $p->gitlab_project_id = $project->gitlab_project_id; array_push($response, $p); } $this->response($response); } else { $response = new stdClass(); $response->status = false; $response->error = 'Token not found or session expired'; $this->response($response); } }
function index() { $data['title'] = 'Scholars Information Database Home'; $p = new Project(); $p->order_by('updated', 'desc')->get(10); $data['posts'] = $p; $this->load->view('home_index', $data); }
public static function question() { $faker = Faker\Factory::create(); $p = Project::order_by(\DB::raw('RAND()'))->first(); $v = Vendor::order_by(\DB::raw('RAND()'))->first(); $q = new Question(array('project_id' => $p->id, 'question' => $faker->paragraph(3))); // Answer 1/2 of the questions if (rand(0, 1) === 0) { $q->answer = rand(0, 1) === 0 ? $faker->sentence : $faker->paragraph; $q->answered_by = $p->owner()->id; } $q->vendor_id = $v->id; $q->save(); }