Laravel Class 'Gate' not found - laravel-5

I have follow the upgrade guide but I can't manage to make the Authorization work.
AuthServiceProvider
<?php
namespace App\Providers;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* #var array
*/
/*protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];*/
protected $policies = [
Request::class => AnalysisPolicy::class,
];
/**
* Register any application authentication / authorization services.
*
* #param \Illuminate\Contracts\Auth\Access\Gate $gate
* #return void
*/
public function boot(GateContract $gate)
{
$this->registerPolicies($gate);
//
}
}
Analysis policy
<?php
namespace App\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
use App\User;
use App\Request;
class AnalysisPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* #return void
*/
public function __construct()
{
//
}
public function view(Request $analysis){
return true;
}
//
}
Controller
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
abstract class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
TestController
public function showTest()
{
$analysis= Request::find(1);
return view('test', ['analysis' => $analysis]);
}
Test.blade.php
Test page
#can('view', $analysis)
Hello world
#endcan
config\app
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Routing\ControllerServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Illuminate\Html\HtmlServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
I always get Class 'Gate' not found. I have laravel 5.1.23. I have tried to run composer update and artisan clear-compiled but nothing worked.

Here is my solution:
in
\vendor\laravel\framework\src\illuminate\Auth\AuthServiceProvider.php
update the provider
https://github.com/laravel/framework/blob/5.1/src/Illuminate/Auth/AuthServiceProvider.php

Related

Email is being pushed to laravel Queue but doesn't get sent

I am trying to implement a queue to send email in laravel. My .env file
MAIL_DRIVER = smtp
MAIL_HOST = smtp.gmail.com
MAIL_PORT = 587
MAIL_FROM_ADDRESS = from#gmail.com
MAIL_USERNAME = from
MAIL_PASSWORD = ********
MAIL_ENCRYPTION = tls
QUEUE_CONNECTION=database
My config/queue.php
'connections' => [
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
'after_commit' => false,
],
]
config/mail.php
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
]
My Job file
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
class SendSampleMail implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/**
* Create a new job instance.
*
* #return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* #return void
*/
public function handle()
{
Mail::send(['text' => 'mail'], ['name' => 'TestUser'], function ($message) {
$message->to('to#mailinator.com', 'testUserName')->subject('Test Laravel email');
$message->from('from#gmail.com', 'Test Mail');
});
}
}
In the controller, I am calling it like
$job = new SendSampleMail();
$this->dispatch($job);
The mail.blade.php
<p>Sending Mail from Laravel.</p>
When I run
php artisan queue:work
The jobs are queued but email fails to be sent.
I need to fix that issue. Any help would be appreciated. Thanks in advance.
As per the laravel document, create the jobs table in the database.
Run the below two command for the creating the table
php artisan queue:table
php artisan migrate

i'm connect multiple Database and i use Laravel Excel I can'n export. This is error "Database [mysql] not configured."

i'm connect multiple Database and i use Laravel Excel I can'n export. This is error "Database [mysql] not configured."
i'm use laravel 6.0 and phpmyadmin version 4.4.15.10
controller
public function exportExcel()
{
return Excel::download(new merakiExport, 'MerakiBluetooth.xlsx');
}
app/Exports
namespace App\Exports;
use App\MerakiBluetoothTemp;
use Maatwebsite\Excel\Concerns\FromCollection;
class merakiExport implements FromCollection
{
/**
* #return \Illuminate\Support\Collection
*/
public function collection()
{
return MerakiBluetoothTemp::all();
}
}
config/database
'meraki' => [
'driver' => 'mysql',
'host' => env('DB_HOST5', ''),
'port' => env('DB_PORT5', ''),
'database' => env('DB_DATABASE5', 'forge'),
'username' => env('DB_USERNAME5', 'forge'),
'password' => env('DB_PASSWORD5', ''),
'unix_socket' => env('DB_SOCKET5', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
env
DB_HOST5=sql.laravel.com
DB_PORT5=3306
DB_DATABASE5=time_sheet
DB_USERNAME5=*****
DB_PASSWORD5=*****
I succeeded too.
app/Exports
namespace App\Exports;
use App\MerakiBluetoothTemp;
use Maatwebsite\Excel\Concerns\FromCollection;
use App\Http\Controllers\Controller;
class merakiExport extends Controller implements FromCollection
{
/**
* #return \Illuminate\Support\Collection
*/
public function collection()
{
return MerakiBluetoothTemp::all();
}
}

BadMethodCallException Call to undefined method App\Student::generateToken()

I want to make auth with different table instead of default user table and I made with student table.
this is Student.php
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Student extends Authenticatable
{
use Notifiable;
protected $table='students';
protected $fillable=['full_name','email', 'password'];
protected $hidden = [
'password', 'remember_token',
];
public function getAuthPassword()
{
return $this->password;
}
}
auth.php
'defaults' => [
'guard' => 'web',
'passwords' => 'students',
],
'guards' => [
'students' => [
'driver' => 'eloquent',
'model' => App\Student::class,
],
//this is last
'students' => [
'provider' => 'students',
'table' => 'password_resets',
'expire' => 60,
],
],
'providers' => [
'students' => [
'driver' => 'eloquent',
'model' => App\Student::class,
],
],
'passwords' => [
'students' => [
'provider' => 'students',
'table' => 'password_resets',
'expire' => 60,
],
],
];
auth/RegisterController
<?php
namespace App\Http\Controllers\Auth;
use App\Student;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* #var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* #param array $data
* #return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'full_name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:students'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
protected function create(array $data)
{
$api_token=str_random(60);
return Student::create([
'full_name' => $data['name'],
'email' => $data['email'],
'api_token'=>$api_token,
'password'=>bcrypt($data['password']),
]
);
}
}
I can make register well but when I want to make login I am getting this error.
BadMethodCallException
Call to undefined method App\Student::generateToken()
From Laravel 5.7 l Helper 'str_random' became 'Str :: rondom'. and don't forget to be able to use the class "use Illuminate \ Support \ Str;"

service class not found error in laravel 4.2?

Attached Image shows exact my problem:
Given below is my app.php where providers array is defined.****This is laravel 4.2.
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Remote\RemoteServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'FanzoopMain\Theme\Provider\ThemeServiceProvider',
'Creolab\LaravelModules\ServiceProvider',
'FanzoopMain\Menu\MenuServiceProvider',
'FanzoopMain\Image\ImageServiceProvider',
'FanzoopMain\Hook\HookServiceProvider',
/**
* App base
*/
'App\Providers\ConfigurationServiceProvider',
'App\Providers\AddonServiceProvider',
'App\Providers\PhotoServiceProvider',
'App\Providers\AdmincpServiceProvider',
'App\Providers\ThemeManagerServiceProvider',
'App\Providers\NotificationServiceProvider',
'App\Providers\MentionServiceProvider',
'App\Providers\HashtagServiceProvider',
'App\Providers\MenuServiceProvider',
'App\Providers\EmoticonServiceProvider',
'App\Providers\ConnectionServiceProvider',
'App\Providers\PostServiceProvider',
'Artdarek\OAuth\OAuthServiceProvider',
'Maatwebsite\Excel\ExcelServiceProvider',
),
/*
|--------------------------------------------------------------------------
| Service Provider Manifest
|--------------------------------------------------------------------------
|
| The service provider manifest is used by Laravel to lazy load service
| providers which are not needed for each request, as well to keep a
| list of all of the services. Here, you may set its storage spot.
|
*/
'manifest' => storage_path().'/meta',
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Cache' => 'Illuminate\Support\Facades\Cache',
'ClassLoader' => 'Illuminate\Support\ClassLoader',
'Config' => 'Illuminate\Support\Facades\Config',
'Controller' => 'Illuminate\Routing\Controller',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File',
'Form' => 'Illuminate\Support\Facades\Form',
'Hash' => 'Illuminate\Support\Facades\Hash',
'HTML' => 'Illuminate\Support\Facades\HTML',
'Input' => 'Illuminate\Support\Facades\Input',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Paginator' => 'Illuminate\Support\Facades\Paginator',
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Seeder' => 'Illuminate\Database\Seeder',
'Session' => 'Illuminate\Support\Facades\Session',
'SSH' => 'Illuminate\Support\Facades\SSH',
'Str' => 'Illuminate\Support\Str',
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
'OAuth' => 'Artdarek\OAuth\Facade\OAuth',
'Addon' => 'App\Facades\Addon',
'ThemeManager' => 'App\Facades\ThemeManager',
'Excel' => 'Maatwebsite\Excel\Facades\Excel',
),
This is my another file, named ConfigurationServiceProvider.php, where I am using the error occuring code.
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Providers\ConfigurationServiceProvider;
/**
* Configuration service provider
*
* #author : Tiamiyu waliu kola
* #webiste: procrea8.com
*/
class ConfigurationServiceProvider extends ServiceProvider
{
public function register(){
}
public function boot(){
if (\Config::get('system.installed')) {
$repository = app('App\Repositories\ConfigurationRepository');
foreach($repository->getAll() as $configuration) {
\Config::set($configuration['slug'], $configuration['value']);
}
/**
* set image configuration
*/
\Config::set('image::max-size', \Config::get('image-max-size'));
\Config::set('image::save-original', \Config::get('keep-original-image'));
\Config::set('image::allow-animated-gif', \Config::get('allow-animated-gif'));
\Config::set('image::ext-allowed', \Config::get('image-allow-type', 'gif,png,jpg'));
/**Assets***/
\Config::set('theme::minifyAssets', \Config::get('minify-assets'));
}
}
}
Try
composer dump-autoload
Or
php artisan dump-autoload
Make sure you have registered your providers directory on composer.json
"autoload": {
"classmap": [
"app/providers"
]
},
Tty this steps
Temporary remove your providers and aliases
Type command composer update
Then add this providers and aliases
Because when you update composer he try to find this classes before adding in your project, After updating your composer add this classes

"Class datatables does not exist" Error when using "yajra" laravel datatables

I want to show a list of my posts table rows via datatables jquery plugin with laravel version 5.1 via yajra-laravel-datatables.
For that I do all instructions described in this Quick Start Giude in my project.
this is my Route only for get all data that are Necessary for dataTable:
Route::get('postsData', 'postController#testData');
and this is complete postController php file :
namespace App\Http\Controllers;
use App\Http\Requests;
use App\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use yajra\Datatables\Datatables;
class postController extends Controller
{
public function index ()
{
$allPosts = Post::all();
return \View::make('admin.pages.posts')->with('posts', $allPosts);
}
public function create ()
{
return \View::make('admin.pages.post_create');
}
public function store (Request $request)
{
$data = Input::all();
$rules = array (
'post_title' => 'required',
'post_desc' => 'required'
);
$validator = \Validator::make($data, $rules);
if ($validator->fails()) {
return \Redirect::to('/admin/posts/create')
->withErrors($validator)
->withInput();
} else {
$post = new Post();
$post->post_title = $data['post_title'];
$post->post_desc = $data['post_desc'];
$post->save();
return \Redirect::to('/admin/posts');
}
}
public function show ($id)
{
$post = Post::find($id);
return \View::make('admin.pages.show_post')->with('post', $post);
}
public function edit ($id)
{
$post = Post::find($id);
return \View::make('admin.pages.edit_post')->with('post', $post);
}
public function update (Request $request, $id)
{
$data = Input::all();
$rules = array (
'post_title' => 'required',
'post_desc' => 'required'
);
$validator = \Validator::make($data, $rules);
if ($validator->fails()) {
return \Redirect::to('post/create')
->withErrors($validator)
->withInput();
} else {
$post = Post::find($id);
$post->post_title = $data['post_title'];
$post->post_desc = $data['post_desc'];
$post->save();
return \Redirect::to('admin/posts');
}
}
public function destroy ($id)
{
$post = Post::find($id);
$post->delete();
return Redirect::to('admin/posts');
}
public function postsAll(){
return View::make('admin.pages.postsAll');
}
public function testData(){
return Datatables::of(Post::select('*'))->make(true);
}
}
also I add Service Provider and Facade to config/app.php :
return [
'debug' => env('APP_DEBUG', false),
'url' => 'http://localhost',
'timezone' => 'UTC',
'locale' => 'en',
'fallback_locale' => 'en',
'key' => env('APP_KEY', 'SomeRandomString'),
'cipher' => 'AES-256-CBC',
'log' => 'single',
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Routing\ControllerServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
yajra\Datatables\DatatablesServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Datatables' => yajra\Datatables\Datatables::class,
],
];
And this is Structure of yajra in vendor composer folder:
But when I open postsData path in browser this error shown:
ReflectionException in Container.php line 737:
Class datatables does not exist
What is Problem?
I found the solution after hours of googling and try different ways :
1.first rename your project to a new name.
2.use composer update
3.run php artisan config:cache
4.and run php artisan cache:clear
and try your Code again.
Try change in your controller
Remove:
use yajra\Datatables\Datatables;
Add
use Datatables;
config/app.php
You must have in providers:
yajra\Datatables\DatatablesServiceProvider::class,
and must have in aliases:
'Datatables' => yajra\Datatables\Datatables::class,
I manage to fix the same bugs.
In config/app.php
Yajra\DataTables\DatatablesServiceProvider::class,
Datatables' => Yajra\DataTables\Facades\Datatables::class,
Just make sure you capitalize 'T' in the '\DataTables\'
Ref. https://github.com/yajra/laravel-datatables/issues/986
same error has also happened if you don't have conf/datatables.php. try installing latest or above 7.x
composer require yajra/laravel-datatables-oracle
add these lines in config/app.php
Yajra\Datatables\DatatablesServiceProvider::class,
'Datatables' => Yajra\Datatables\Facades\Datatables::class,
php artisan config:cache
if you don't have file config/datables.conf. Try to paste these file there.
https://gist.github.com/hsali/1cab0d6c81020bf7bce043b65f94373a
Try this:
use Yajra\Datatables\Facades\Datatables;

Resources