<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
use Carbon\Carbon;
use App\Modules\Bookings\TaskFeedback;
use App\Console\Commands\AbstractCommand;

class FakeFeedback extends AbstractCommand
{
	/**
	 * A friendly name of the command that will be used when loggin messages.
	 *
	 * @var string
	 */
	protected $command_title = 'Fake Feedback';

	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'feedback:fakeit';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Creates fake feedback emails/notifications';

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

	/**
	 * Execute the console command.
	 *
	 * @return void
	 */
	public function fire()
	{
		$code = "00tQ7P2D32768M7WUC2VojTaVCP8LV0x";
		$feedback = TaskFeedback::findOrFail($code);

		$feedback->rating = 5;
        $feedback->reminder_sent = 0;
		$feedback->feedback = "great job test test test";

		if ($feedback->save()) {
			Event::dispatch('FeedbackReceived', $feedback);
			return $feedback;
		} else {
			return Response::json(['errors' => $feedback->errors->all()], 400);
		}
	}
}
