I am creating demo for Elastic search for Laravel using Laravel Scout.I have used this site for refernce= https://medium.com/#samogorm/basic-search-functionality-with-elasticsearch-laravel-scout-6ac182c99cbf. I have install
ElasticSearch , Java version to machine and follow step of above link, but when I run command
-php artisan scout:import “App\Account”
I got error
Symfony\Component\Debug\Exception\FatalThrowableError : Class
'app\Account' not found
at
/home/ashwinibhandare/Code/Elasticsearch/vendor/laravel/scout/src/Console/ImportCommand.php:35
31| public function handle(Dispatcher $events)
32| {
33| $class = $this->argument('model');
34|
35| $model = new $class;
36|
37| $events->listen(ModelsImported::class, function ($event) use ($class) {
38| $key = $event->models->last()->getScoutKey();
39|
Exception trace:
1
Laravel\Scout\Console\ImportCommand::handle(Object(Illuminate\Events\Dispatcher))
/home/ashwinibhandare/Code/Elasticsearch/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
2 call_user_func_array()
/home/ashwinibhandare/Code/Elasticsearch/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
Please use the argument -v to see more details.
I am not experience person, Can you please suggest me what is wrong
Related
I learn Laravel from the tutorial and there is use factory(). In my project show me an error, Undefined function factory. I know that in Laravel 9 factory() does not exist, but someone could help me how can I modify the below code that will run in Laravel 9.
public function run(Faker $faker)
{
factory(
Task::class,
$faker->numberBetween(25, 50)
)->create();
}
factory() was used until Laravel 8. In newer versions of Laravel model factories are used: https://laravel.com/docs/9.x/eloquent-factories#main-content
Installing Swagger for the First Time in laravel 6. https://github.com/DarkaOnLine/L5-Swagger.
composer require "darkaonline/l5-swagger"
php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
On generating command
php artisan l5-swagger:generate
Getting Error like:
php artisan l5-swagger:generate
Regenerating docs
ErrorException : Required #OA\Info() not found
at D:\XMAPP\htdocs\minidmsapi\vendor\zircote\swagger-php\src\Logger.php:39
35| $this->log = function ($entry, $type) {
36| if ($entry instanceof Exception) {
37| $entry = $entry->getMessage();
38| }
> 39| trigger_error($entry, $type);
40| };
41| }
42|
43| /**
Exception trace:
1 trigger_error("Required #OA\Info() not found")
D:\XMAPP\htdocs\minidmsapi\vendor\zircote\swagger-php\src\Logger.php:39
2 OpenApi\Logger::OpenApi\{closure}("Required #OA\Info() not found")
D:\XMAPP\htdocs\minidmsapi\vendor\zircote\swagger-php\src\Logger.php:71
Please use the argument -v to see more details.
please Help me for generating swagger documentation
Required #OA\Info() is required to initialize your swagger documentation and then use proper annotation to parse. Annotations are only parsed inside /** DocBlocks. Here you go for initial annotations swagger-php#usage
I wanted to create a custom cache driver using aerospike.
I have followed the instruction given in the document:
https://laravel.com/docs/5.8/cache#adding-custom-cache-drivers
Cache::extend('aerospike', function ($app) {
$config = $app['config'];
$server = $config['cache.stores.aerospike.servers'];
$aerospike = new \Aerospike($server);
$store = new AerospikeStore($aerospike, $config['cache.prefix'], $config['cache.stores.aerospike.namespace']);
return Cache::repository($store);
});
also created the AerospikeStore file.
When run php artisan serve it always says :
In CacheManager.php line 109:
Driver [aerospike] is not supported.
I'm using Doctrine for Laravel (Laravel 5.7) and I want to implement a global filter instead of adding manually to each query 'where active = true'.
I heard about the SQL filters and came up with this class :
namespace App\Doctrine\Filters;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query\Filter\SQLFilter;
class ActiveFilter extends SQLFilter
{
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
return sprintf('%s.active = %s', $targetTableAlias, $this->getParameter('active'));
}
}
Then, in my main Controller (all my controllers extend from this one) :
public function __construct($em)
{
$this->em = $em;
// Only display active rows.
$this->em->getFilters()
->enable('active_rows')
->setParameter('active', true);
}
I assume this is correct but then I'm not sure at all. As I have Doctrine for Laravel, i couldn't follow the tutorial I found here (symfonycasts). I didn't find anything in the documentation about it for Laravel.
So I edited my config/doctrine.php :
'filters' => [
'active_rows' => 'app\Doctrine\Filters\ActiveFilter'
],
When I try this code I got this :
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'app/Doctrine/Filters/ActiveFilter' not found
As required I provided the full namespace, I don't find the error. I think the path is correct. Am I missing something ?
Do you have an idea ?
Thanking you in advance,
public function listdata() {
$locale = Input::get('locale');
$pageSize = intval(Input::get('pageSize'));
$currentPage = intval(Input::get('currentPage'));
$column = Input::get('column');
$sort_type = Input::get('sort_type');
$search_key = Input::get('search_key');
$default_locale = Config('config.default_locale');
Paginator::currentPageResolver(function () use ($currentPage) {
return $currentPage;
});
$var = User::orderBy($column, $sort_type)->paginate($pageSize);
...further code
I was using this in laravel 5.2 and it was working fine. But after upgrading to laravel 5.4 I am getting the error in pagination everywhere in my project.
(1/1) BindingResolutionException
Unresolvable dependency resolving [Parameter #0 [ <required> $items ]] in
class Illuminate\Pagination\LengthAwarePaginator
I have seen many answers related to this problem but nothing helps me. Any help is appreciated and please don't write any link because I have already tried many.