Exemple #1
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         // Ensure a unique API token is generated
         $token = new Token();
         $apiToken = $token->generateUnique();
         $model->api_token = $apiToken;
     });
 }
 /**
  * Update the specified resource in storage.
  * @return \Illuminate\Http\Response
  * @internal param Request $request
  * @internal param int $id
  */
 public function update()
 {
     // Generate new token
     $token = new Token();
     $apiToken = $token->generateUnique();
     $user = Auth::user();
     $user->api_token = $apiToken;
     $user->update();
     return redirect('dashboard')->with('success', ['Your API token has been regenerated.']);
 }