<?php

namespace App\Console\Commands;

use App\UserSocial;
use Carbon\Carbon;
use Illuminate\Console\Command;

class socialReset extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'social:reset';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Reset Social Media Details';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        $now = date('Y-m-d h:i:s');

        UserSocial::query()->get()->each(function ($sm) use (&$now){

            $length = Carbon::parse($sm->updated_at)->diffInDays($now);

            ($length > 40) ? $sm->forceDelete() : $this->info('timestamp okay');

        });

        return true;
    }
}
