If Model factroy is as below then how to use Trait getData() in here?
This code not worked.
<?php
use App\Working;
use App\Traits\Calculate;
...
$factory->define(App\Working::class, function (Faker\Generator $faker) {
...
$getData = $this->getData();
...
return['get_data' => $getData];
}
Error message:
Symfony\Component\Debug\Exception\FatalThrowableError : Call to undefined method Illuminate\Database\Eloquent\Factory::getData()
Exception trace:
1 Illuminate\Database\Eloquent\Factory::{closure}(Object(Faker\Generator), []) G:\test\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:263
2 call_user_func(Object(Closure), Object(Faker\Generator), []) G:\test\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:263
$this
refer to in your code? – nozzleman