Reputation: 165
I would like to create a folder inside Storage folder in Laravel 5.2, once you register and pick your username, a folder with that username will be created for you. For Example : if you create username : 'laraveluser' an folder will be create inside public folder named 'laraveluser'. But I can not understand how can do it. here my problems and code of UserController:
but it showing :
FatalErrorException in UserController.php line 28: Class 'App\Http\Controllers\File' not found
in UserController.php line 28
<?php
namespace App\Http\Controllers;
use Auth;
use App\Model\User;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Validator;
use Storage;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class UserController extends Controller
{
use AuthenticatesAndRegistersUsers;
public function __construct() {
$this->middleware('admin');
}
protected function create(array $data)
{
File::MakeDirectory(public_path($data['username']));
return User::create([
'fullname' => $data['fullname'],
'email' => $data['email'],
'phone_number' => $data['phone_number'],
'company_name' => $data['company_name'],
'website' => $data['website'],
'country' => $data['country'],
'username' => $data['username'],
'password' => bcrypt($data['password']),
'status' => $data['status'],
]);
//File::makeDirectory(public_path($data['username']));
// return $user;
}
protected $redirectPath = '/manage-user';
Upvotes: 1
Views: 93
Reputation: 3704
Add use Illuminate\Support\Facades\File;
after the namespace. Your file facade was not loaded.
Upvotes: 0