コード例 #1
0
ファイル: ApiKeyController.php プロジェクト: eveseat/api
 /**
  * Store a newly created resource in storage.
  *
  * @param \Seat\Web\Http\Validation\ApiKey $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(ApiKeyValidator $request)
 {
     // If we dont have a user_id, set it to 1
     // which is the admin user.
     if (!$request->has('user_id')) {
         $request['user_id'] = 1;
     }
     ApiKey::create($request->all());
     return response()->json(['ok']);
 }
コード例 #2
0
ファイル: KeyController.php プロジェクト: eveseat/web
 /**
  * @param \Seat\Web\Http\Validation\ApiKey         $request
  * @param \Seat\Eveapi\Helpers\JobPayloadContainer $job
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function addKey(ApiKey $request, JobPayloadContainer $job)
 {
     // Get or create the API Key
     $api_key = ApiKeyModel::firstOrNew(['key_id' => $request->input('key_id')]);
     // Set the current user as the owner of the key
     // and enable it.
     $api_key->fill(['v_code' => $request->input('v_code'), 'user_id' => auth()->user()->id, 'enabled' => true]);
     $api_key->save();
     // For *some* reason, key_id is 0 here after the
     // fill() and save(). So, set it again so that
     // the update job wont fail to give Pheal a
     // key_id from the model.
     $api_key->key_id = $request->input('key_id');
     // Prepare the JobPayloadContainer for the update job
     $job->scope = 'Key';
     $job->api = 'Scheduler';
     $job->owner_id = $api_key->key_id;
     $job->eve_api_key = $api_key;
     // Queue the update Job
     $job_id = $this->addUniqueJob(CheckAndQueueKey::class, $job);
     return redirect()->route('api.key')->with('success', trans('web::seat.add_success', ['jobid' => $job_id]));
 }