|
-<?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()
{
$file = Input::file('Filedata');
if($file){
$realPath = $file->getRealPath();
$entension = $file->getClientOriginalExtension();
$newName = date('YmdHis').mt_rand(100,999).'.'.$entension;
$path = $file->move(base_path().'/public/img',$newName);
$filepath = 'img/'.$newName;
return $filepath;
}
}
public function __construct()
{
$user = session('user');
$project = Project::where('display',1)->get();
// $role = Job::where('role',$user->role)->first();
// dd($user);
View::share('user',$user);
View::share('project',$project);
// View::share('role',$role);
}
}
|
|
|
|
|
|
+<?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()
{
$file = Input::file('Filedata');
if($file){
$realPath = $file->getRealPath();
$entension = $file->getClientOriginalExtension();
$newName = date('YmdHis').mt_rand(100,999).'.'.$entension;
$path = $file->move(base_path().'/public/img',$newName);
$filepath = 'img/'.$newName;
return $filepath;
}
}
public function __construct()
{
$user = session('user');
$project = Project::where('display',1)->get();
$role = Job::where('role',$user['role'])->first();
// dd($user);
View::share('user',$user);
View::share('project',$project);
View::share('role',$role);
}
}
|