<?php

use App\Company;
use App\Invoice;
use App\Plan;
use App\Subscription;
use App\Repositories\PreferenceRepository;
use Carbon\Carbon;
use Faker\Factory as Faker;
use Illuminate\Database\Seeder;

class CompanySeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run() {
        factory(App\Company::class, 1)->create()->each(function(Company $c) {
            $c->subscriptions()->save($sub = factory(App\Subscription::class)->make([
                "start_date" => Carbon::now()
            ]));
            $sub->company_orders()->save($order = factory(App\CompanyOrder::class)->make([
                "company_id" => $c->id
            ]));

            //la factura es fa sola


            //Fem alguns news a nivell de companyia
            $c->news()->saveMany(factory(App\News::class, 5)->create());
        });
    }
}
