laravel 5 uuid generation code errors - laravel-5

I am trying to use UUid in laravel 5. I have added the following code :
$fileUniqueName = Uuid::generate();
and at top :
use Uuid;
But I am getting the following error :
FatalErrorException in FlyersController.php line 427:
Class 'Uuid' not found
How can I solve this problem ?

It seems you're not use-ing the correct namespace for the Uuid class. You should have at the top of your file something like this for webpatser's uuid generator:
use Webpatser\Uuid\Uuid;
If you want to use Uuid in Laravel 5, I've put together some simple traits to use in your models. You can find the source code on github.

Related

When I try to create any Livewire component I always obtain «syntax error, unexpected token "[", expecting "{"»

When I run
php artisan make:livewire mycomponent
I always obtain:
ParseError
syntax error, unexpected token "[", expecting "{"
at app/Http/Livewire/Mycomponent.php:5
1▕ <?php
2▕
3▕ namespace App\Http\Livewire;
4▕
➜ 5▕ use App\Models\[Normally the Last Word of the Namespace in Singular, for example «User»]
6▕ use Livewire\Component;
7▕
8▕ class Mycomponent extends Component
9▕ {
+1 vendor frames
2 [internal]:0
Composer\Autoload\ClassLoader::loadClass()
+1 vendor frames
4 [internal]:0
Livewire\LivewireComponentsFinder::Livewire\{closure}()
Then, the files are created, but they contain garbage, piece of code of other components, instead of a fresh void component.
Does someone know why is not working the creation of the components?
Thanks and best regards.
As Qirel suggested in his comment, the problem was with the stubs. I deleted all the stubs related to Livewire, and it worked again.
Thank you very much #Qirel!

Upgrading Laravel 7 to 8, seeder issue

I am seeing a lot of issues with the upgrade path from Laravel 7 to 8, but I encounter a different problem for which I cannot find an answer.
It is this one
Seeding: Database\Seeders\UsersTableSeeder
Error
Call to undefined method Database\Factories\UserFactory::new()
at vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factories/Factory.php:737
733▕ public static function factoryForModel(string $modelName)
734▕ {
735▕ $factory = static::resolveFactoryName($modelName);
736▕
➜ 737▕ return $factory::new();
738▕ }
739▕
740▕ /**
741▕ * Specify the callback that should be invoked to guess factory names based on dynamic relationship names.
+1 vendor frames
2 database/seeders/UsersTableSeeder.php:17
App\User::factory()
+7 vendor frames
10 database/seeders/DatabaseSeeder.php:15
Illuminate\Database\Seeder::call()
You have probably read in the Upgrade Guide from 7 to 8 that Factories and Seeders are changed in Laravel 8.
If you don't have many Factories and Seeders you can write them from scratch.
I extended the wrong Factory class.
The one I was using was Faker\Factory but instead I must use Illuminate\Database\Eloquent\Factories\Factory.
It was probably because I used the 'import class' function of PHPStorm too quickly.

Why #this cannot work in my laravel-livewire(mapbox)?

I try to get the long and lat data from the class, but this "#this" is not working
This is the class:
This is the error:
I'm new in livewire and Json. Your help is a gold for me.
First: You can apply #this on the livewire blade file only
Your Error Path: vpet\resouces\views\customer\location.blade.php (This will definitely give an error)
According to your class right path is: vpet\resouces\views\livewire\map-location.blade.php

Laravel Gettext Error Class 'App\Http\Controllers\LaravelGettext' not found

I followed these steps for installing Gettext with laravel
https://github.com/Belphemur/laravel-gettext
However, I am getting Class 'App\Http\Controllers\LaravelGettext' not found
error.
If I include the namespace with classes, it says, that the method is not defined as static, which is true after checking the code.
Am I missing something?
Error place (copied from the gettext plugin page)
public function changeLang($locale=null) {
LaravelGettext::setLocale($locale);
return Redirect::to(URL::previous());
}
Make sure to add use Path\to\LaravelGettext; at the top of your file outside the class.
I am not sure what's the path to LaravelGettext. Maybe it is Xinax\LaravelGettext\Facades\LaravelGettext

phmagick class not found on laravel 4

After installing phmagick using composer I'm getting a class not found error. I think it's because of how the Action classes are being loaded, but is there a fix for it?
Have a look in vendor/francodacosta/phmagick/docs/index.html for actual documentation about phMagick. Here's one of the examples which works for me...
$phMagick = new \phMagick\Core\Runner();
$action = new \phMagick\Action\Convert($this->originalFile, $this->newFile);
// optimize the image
$action->optimize();
// sets image quality
$action->quality(70);
// execute the convert action
$phMagick->run($action);

Resources