Esempio n. 1
0
    $account->vote()->associate($vote);
    $account->save();
    $account2 = new Account();
    $account2->username = '******';
    $account2->vote_id = 2;
    $account2->finish_at = "0000-00-00 00:00:00";
    $account2->vote()->associate($vote);
    $account2->save();
    $candidate = new Candidate();
    $candidate->cname = 'Naruto Uzumaki';
    $candidate->job_title = 'yy';
    $candidate->sex = '男';
    $candidate->vote_id = 49;
    $candidate->total_count = 2;
    $candidate->save();
    $candidate->accounts()->save($account);
    $candidate->accounts()->save($account2);
    // $account = Account::find(1);
    // $candidate = Candidate::find(10);
    // $candidate->accounts()->detach();
    // // return $candidate->accounts;
    // return Candidate::with('accounts')->find($candidate->id);
});
Route::get('/test2', function () {
    function GeraHash($qx)
    {
        //Under the string $Caracteres you write all the characters you want to be used to randomly generate the code.
        $Caracteres = 'ABCDEFGHIJKLMPQRSTUVXWYZ123456789';
        $QuantidadeCaracteres = strlen($Caracteres);
        $QuantidadeCaracteres--;
        $Hash = NULL;