jeudi 12 novembre 2020

How to validate if an array of tokens are valid, using the stored tokens in a firebase node using laravel

i am new in laravel and php, but what i want to do is issue tokens/promotion codes, to my client, this i have generated them and saved in the firebase node, then i sent the client the tokens in csv file when the client upload the csv file with the tokens they should be validated to check if the supplied tokens are valid/not yet been used, and the the valid field should be changed to false in the database, so that if they try to use the tokens again, it would not work.

Bellow is my code in the controller

public function reedemTokens(){
    $serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/FirebaseKey.json');
    $firebase = (new Factory)
    ->withServiceAccount($serviceAccount)
    ->withDatabaseUri('https://mydatabse.firebaseio.com/')
    ->create();

        $database = $firebase->getDatabase();

        $ref = $database->getReference('Tokens');

        $tokens = $ref->getValue();

        foreach($tokens as $tokens)
          {
              $valid_tokens[] = $tokens;
          }

         return view('Dashboard/AdminDashboard', compact('valid_tokens'));
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire