<?php

namespace App\DBRealTestSupport\TransactionSupported;

use App\Modules\Shared\Application\Util;
use Faker\Factory;
use Illuminate\Support\Facades\DB;
use App\DBRealTestSupport\TableCreation as TC;

class TSCategoryTourMother
{

  public static function buildRandom($id = 1)
  {
    $faker = Factory::create();
    return [
      'Id_CategoryTour' => $id,
      'CategoryTour_Name' => $faker->text(rand(5, 250)),
      'CategoryTour_Status' => 2
    ];
  }

  public static function pushRandom($id = 1)
  {
    return self::push(self::buildRandom($id));
  }

  public static function push($object)
  {
    DB::insert(
      "INSERT INTO `t_category_tour` 
        (
            `CategoryTour_Name`,
            `CategoryTour_Status`
        )
        VALUES (?, ?)",
      [
        $object['CategoryTour_Name'],
        $object['CategoryTour_Status']
      ]
    );
    $object['Id_CategoryTour'] = DB::select('SELECT LAST_INSERT_ID() as `Id`')[0]->Id;
    return $object;
  }

  public static function tablesToClear()
  {
    return [TC::category_tour];
  }
}
