IndexController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Module\Base;
  4. use Redirect;
  5. use DB;
  6. /**
  7. * 页面
  8. * Class IndexController
  9. * @package App\Http\Controllers
  10. */
  11. class IndexController extends Controller
  12. {
  13. public function __invoke($method, $action = '', $child = '')
  14. {
  15. $app = $method ? $method : 'main';
  16. if ($action) {
  17. $app .= "__" . $action;
  18. }
  19. if (!method_exists($this, $app)) {
  20. $app = 'main';
  21. }
  22. return $this->$app($child);
  23. }
  24. /**
  25. * 首页
  26. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  27. */
  28. public function main()
  29. {
  30. return view('main', ['version' => Base::getVersion()]);
  31. }
  32. /**
  33. * 接口文档
  34. * @return \Illuminate\Http\RedirectResponse
  35. */
  36. public function api()
  37. {
  38. return Redirect::to(Base::fillUrl('docs'), 301);
  39. }
  40. public function test(){
  41. $list = DB::table("project_task")->where('delete',0)->get()->toArray();
  42. foreach ($list as $k => $v){
  43. $subtasks = Base::string2array($v->subtask);
  44. if(count($subtasks) > 0){
  45. $subtasks_data = [];
  46. foreach ($subtasks as $key => $value){
  47. $item = [
  48. 'taskid' => $v->id,
  49. 'uname' => $value['uname'],
  50. 'indate' => $value['time'],
  51. 'status' => $value['status'],
  52. 'detail' => $value['detail']
  53. ];
  54. array_push($subtasks_data,$item);
  55. }
  56. DB::table('project_sub_task')->insert($subtasks_data);
  57. }
  58. }
  59. }
  60. }