public function run() { if (class_exists('Faker\\Factory')) { $faker = Faker\Factory::create(); $scans = Scan::all()->all(); $images = ['/img/eusthenopteron_foordi.jpg', '/img/iridotriton_hechti.jpg', '/img/sipalocyon_sp.jpg', '/img/teinolophos_trusleri.jpg']; foreach ($scans as $scan) { for ($i = 1; $i <= 500; $i++) { Image::create(['filePath' => '/' . $faker->word, 'fileName' => $faker->word . $faker->randomNumber(2) . '.tif', 'fileUrl' => $faker->randomElement($images), 'scanId' => $scan->id]); } } } }
public function run() { if (class_exists('Faker\\Factory')) { $faker = Faker\Factory::create(); $specimens = Specimen::all()->all(); $museums = Museum::all()->all(); $authors = Author::all()->all(); $animalGroups = AnimalGroup::all()->all(); for ($i = 1; $i <= 500; $i++) { Scan::create(['scanId' => $faker->randomNumber(5), 'scanQuality' => $faker->randomElement(['low', 'medium', 'high']), 'fileDirectory' => '//scan' . $faker->randomNumber(2), 'location' => $faker->country, 'scanTime' => $faker->dateTime, 'voltage' => $faker->randomFloat(2, 1, 20), 'voxelSize' => $faker->randomFloat(1, 0, 1) . 'mm', 'imageCount' => $faker->randomNumber(4), 'current' => '120v', 'sequence' => $faker->randomNumber(4), 'specimenId' => $faker->randomElement($specimens)->id, 'museumId' => $faker->randomElement($museums)->id, 'authorId' => $faker->randomElement($authors)->id, 'animalGroupId' => $faker->randomElement($animalGroups)->id]); } } }
public function run() { if (class_exists('Faker\\Factory')) { $faker = Faker\Factory::create(); $images = ['img/eusthenopteron_foordi.jpg', 'img/iridotriton_hechti.jpg', 'img/sipalocyon_sp.jpg', 'img/teinolophos_trusleri.jpg']; $scans = Scan::all()->all(); $mediaTypes = MediaType::all()->all(); foreach ($scans as $scan) { $count = $faker->randomDigit; for ($i = 1; $i <= $count; $i++) { Media::create(['filePath' => '/' . $faker->word, 'fileName' => $faker->word . $faker->randomNumber(2) . '.' . $faker->randomElement(['stl', 'vgl', 'mov', 'dct']), 'fileUrl' => $faker->randomElement($images), 'scanId' => $scan->id, 'mediaTypeId' => $faker->randomElement($mediaTypes)->id]); } } } }
/** * post_scans_by_period function. * * @description Devuelve las estadísticas de escaneos por mes * @access public * @param mixed $id (default: null) * @return void */ public function postScansByPeriod($id = null) { $id = Input::get('id', array(0)); $period = Input::get('period', date("m/Y", time())); $period = join("-", array_reverse(explode("/", $period))) . "-01"; $scans = Scan::where('created_at', '>=', $period); $scans->whereIn('coupon_id', $id); $scans = $scans->groupBy('coupon_id')->groupBy('day')->get(array('coupon_id', DB::raw('COUNT(`id`) as qty'), DB::raw('DATE_FORMAT(`created_at`,"%Y-%m-%d") AS day'))); $data = array(); foreach ($scans as $scan) { $data[$scan->coupon_id][$scan->day] = $scan->qty; } return Response::json(array("data" => $data, "period" => $period)); }
/** * scan function. * * @access public * @return void */ public function postScan() { $qr = Input::get('qr', ""); $coupon = Coupon::where("qr", "=", $qr)->first(); if (!$coupon || trim($qr) == "") { return Response::json(array("service" => __FUNCTION__, "status" => true, "error" => true, "message" => "Coupon not found")); } $user_id = Auth::user()->id; $count = Scan::where("user_id", "=", $user_id)->where("created_at", ">", date("Y-m-d", time()))->count(); if ($count > 1) { return Response::json(array("service" => __FUNCTION__, "status" => true, "error" => true, "message" => "Scan error")); } $scan = new Scan(); $scan->user_id = $user_id; $scan->coupon_id = $coupon->id; $scan->value = 5; $scan->save(); $redems = Scan::where("coupon_id", "=", $coupon->id)->count(); //$user->register->scans()->sum("value") $data = array("added" => 5, "total" => 0, "redems" => $redems); return Response::json(array("service" => __FUNCTION__, "status" => true, "data" => $data)); }