Maintenance Gitlab - Jeudi 09 Décembre 2021 à partir de 10h - Mises à jour de sécurité

Commit 4ab0ff36 authored by SASSU Thomas's avatar SASSU Thomas
Browse files

script td4a

parent 8f2395b9
<?php
require_once dirname (__DIR__) . '/vendor/autoload.php';
session_start();
use \Slim\Slim as Slim;
use gp\modeles\Comment;
use gp\modeles\Game;
use gp\modeles\User;
use Illuminate\Database\Capsule\Manager as DB;
use \gp\controleurs\ControleurPrincipal as ControleurPrincipal;
use \gp\controleurs\ControleurScript as ControleurScript;
use Faker;
$db = new DB();
$db->addConnection(parse_ini_file('../conf/conf.ini'));
......@@ -14,16 +14,49 @@ $db->addConnection(parse_ini_file('../conf/conf.ini'));
$db->setAsGlobal();
$db->bootEloquent();
$db::table('user')->insert(
[],
[]
);
$db::table('comment')->insert(
[],
[],
[],
[],
[],
[]
);
\ No newline at end of file
// use the factory to create a Faker\Generator instance
$faker = Faker\Factory::create();
if(User::first()== null){
//all users
for($i=0; $i<2; $i++) {
$insert = false;
while (!$insert) {
try {
//fake data
$tmp = explode(' ', $faker->name);
$user['fname'] = $tmp[0];
$user['name'] = $tmp[1];
$user['address'] = $faker->address;
$user['email'] = $faker->email;
$user['tel'] = $faker->e164PhoneNumber;
$user['date'] = $faker->date('Y-m-d', '2005-01-01');
//insert
User::create($user['fname'], $user['name'], $user['email'], $user['address'], $user['tel'], $user['date']);
$insert = true;
} catch (PDOException $Exception) {
echo("Duplicate data : recreating new fake");
}
}
}
}
if(Comment::first()== null){
//all comments
$users = User::get();
$game = Game::where('id', '=', 12342)->first();
foreach($users as $user){
$insert = false;
while (!$insert) {
try {
//fake data
$title = $faker->text(50);
$content = $faker->text(200);
$date = $faker->date('Y-m-d', '2015-02-01');
//insert comment
Comment::create($game->id, $user->email, $title, $content, $date);
$insert = true;
} catch (PDOException $Exception) {
echo("Duplicate data : recreating new fake");
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment