<?php
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Model\Job;
use App\Model\Project;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Session;

class CommonController extends Controller
{


    public function upload()
    {

        if (Input::hasFile('Filedata')) {

            $file = Input::file('Filedata');

            $entension = $file->getClientOriginalExtension();

            $newName = date('YmdHis') . mt_rand(100, 999) . '.' . $entension;

            $file->move(base_path() . '/public/img', $newName);

            return 'img/' . $newName;

        }

    }

    public function __construct()
    {

        $user = session('user');
        $project = Project::where('display', 1)->get();
        $role = Job::where('id', $user['role_id'])->first();

        View::share('user', $user);
        View::share('project', $project);
        View::share('role', $role);
    }

}