public function counter() { $collections = collect(['PeVerification' => 'P.e. Verification', 'Incomplete' => 'Incomplete Fill-Up', 'Approval' => 'Incomplete Approval', 'QaVerification' => 'Q.a. Verification'])->map(function ($status) { return Closure::statusCount($status); })->merge(['today' => Info::todayCount(), 'week' => Info::weekCount(), 'month' => Info::monthCount(), 'year' => Info::yearCount()]); return $collections; }
public function getQdnLinkAndData(Request $request) { return Closure::status($request->status)->map(function ($item) { array_add($item, 'action_link', static::actionLink($item)); array_add($item, 'gate', Gate::allows('mod-qdn', $item->info->slug)); return array_add($item, 'receiver_name', InvolvePerson::getInvolvePerson($item->info_id)); }); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('infos')->delete(); $faker = \Faker\Factory::create(); foreach (range(1, 20) as $index) { $employee = Employee::all(); $originator = $employee->random(); $close_by = Employee::where('station', 'quality assurance')->first(); $issuedTo = $employee->random(); $major = 'major'; $year = Carbon::now('Asia/Manila')->format('y'); $info = Info::create(['control_id' => $year . "-" . sprintf("%'.04d", $index), 'customer' => $faker->randomElement(array_flatten(Option::all('customer')->toArray())), 'package_type' => $faker->firstNameFemale, 'device_name' => $faker->address, 'lot_id_number' => $faker->randomDigit, 'lot_quantity' => $faker->randomNumber(4), 'job_order_number' => $faker->randomElement(['0', '1', '2']), 'machine' => $faker->randomElement(['at01', 'at02', 'at03', 'at04', 'at05']), 'station' => $faker->randomElement(['pl1', 'pl2', 'pl3', 'pl4', 'pl5']), 'created_at' => $faker->dateTimeThisMonth, 'major' => $major, 'disposition' => $faker->randomElement(['use as is', 'ncmr#', 'rework', 'split lot', 'shutdown', 'shipback']), 'problem_description' => $faker->paragraph(2), 'failure_mode' => $faker->randomelement(['assembly', 'environment', 'machine', 'man', 'material', 'method / process']), 'discrepancy_category' => $faker->randomelement(['MISSING UNIT(S)', 'LOW YIELD', 'WRONG TRANSACTION', 'CANT CREATE', 'FOREIGN MATERIAL', 'WRONG MERGING', 'DATECODE DISCREPANCY', 'MARKING PROBLEM', 'MIXED DEVICE', 'BENT LEAD', 'LEAD CONTAMINATION', 'LEAD DISCOLORATION', 'LEAD COPLANARITY']), 'quantity' => $faker->randomNumber(4)]); CauseOfDefect::create(['info_id' => $info->id, 'cause_of_defect' => $faker->randomElement(['PRODUCTION', 'PROCESS', 'MAINTENANCE', 'FACILITIES', 'QUALITY ASSURANCE', 'OTHERS']), 'cause_of_defect_description' => $faker->paragraph(2), 'objective_evidence' => 'N/A']); ContainmentAction::create(['info_id' => $info->id, 'what' => $faker->paragraph(2), 'who' => $faker->name('male' | 'female'), 'objective_evidence' => 'N/A', 'created_at' => $info->created_at]); CorrectiveAction::create(['info_id' => $info->id, 'what' => $faker->paragraph(2), 'who' => $faker->name('male' | 'female'), 'objective_evidence' => 'N/A', 'created_at' => $info->created_at]); PreventiveAction::create(['info_id' => $info->id, 'what' => $faker->paragraph(2), 'who' => $faker->name('male' | 'female'), 'objective_evidence' => 'N/A', 'created_at' => $info->created_at]); QdnCycle::create(['info_id' => $info->id, 'cycle_time' => '24', 'production_cycle_time' => '24', 'process_engineering_cycle_time' => '24', 'quality_assurance_cycle_time' => '24', 'other_department_cycle_time' => '24', 'created_at' => $info->created_at]); InvolvePerson::create(['info_id' => $info->id, 'station' => $originator->station, 'originator_id' => $originator->user_id, 'originator_name' => $originator->name, 'receiver_id' => $issuedTo->user_id, 'receiver_name' => $issuedTo->name, 'created_at' => $info->created_at]); Closure::create(['info_id' => $info->id, 'containment_action_taken' => $faker->randomElement(['yes', 'no']), 'corrective_action_taken' => $faker->randomElement(['yes', 'no']), 'close_by' => $close_by->name, 'date_sign' => Carbon::parse($info->created_at)->addDay(), 'production' => $employee->where('department', 'production')->random()->name, 'process_engineering' => $employee->where('department', 'process_engineering')->random()->name, 'quality_assurance' => $employee->where('department', 'quality_assurance')->random()->name, 'other_department' => $employee->where('department', 'other_department')->random()->name, 'status' => 'Closed', 'created_at' => $info->created_at]); } }
protected function getColumnMonthCreatedTimeAndClosingTime($month) { return Closure::CycleTimeForMonth($month)->map(function ($key) { return ['month' => $key->month, 'created' => strtotime($key->created_at), 'closed' => strtotime($key->date_sign)]; }); }
public static function CycleTimeForMonth($month) { return Closure::select(DB::raw("MONTH(created_at) as month"), 'created_at', 'date_sign')->where(DB::raw('MONTH(created_at)'), $month)->whereStatus('closed')->get(); }
protected function setQdnStatus() { Closure::whereInfoId($this->qdn->id)->update(['status' => 'p.e. verification']); }
protected function save() { Closure::where('info_id', $this->qdn->id)->update($this->setOfClosureCollection()); return $this; }
public static function getCount($status) { return Closure::where('status', $status)->count(); }