<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\ProjectController;
use App\Models\Project;

class SelectProjectController extends Controller
{
    /**
     * Provision a new web server.
     *
     * @param  int  $project_id
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function __invoke($project_id,Request $request)
    {
        if(Project::find($project_id)->exists())
        {
            $request->session()->put('project_id',$project_id);
        }
        else
        {
            $request->session()->forget('project_id');
        }
        return view('dashboard');
    }
}
