0

Estoy intentando ejecutar un seeder pero me sale el error: Call to undefined function storage_patch() No he podido dar con el.

tengo una tabla en migracion llamada user con los sgts campos:

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {   

        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            //llave foranea rol por defecto con  default estudiante
            $table->unsignedInteger('role_id')->default(\App\Role::STUDENT);
            $table->string('name');
            $table->string('last_name')->nullable();
            $table->string('slug');
            //puede ser nulo el campo
            $table->string('picture')->nullable();
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');


            //cashier columns
            $table->string('stripe_id')->nullable();
            $table->string('card_brand')->nullable();
            $table->string('card_last_four')->nullable();
            $table->timestamp('trial_ends_at')->nullable();

            $table->rememberToken();
            $table->timestamps();

            $table->foreign('role_id')->references('id')->on('roles');
        });

    }
    public function down()
    {
        Schema::dropIfExists('users');

    }
}

La factoria para los users las tengo asi:

<?php

use Faker\Generator as Faker;

$factory->define(App\User::class, function (Faker $faker) {
    //definicion de variables
    $name=$faker->name;
    $last_name=$faker->lastName;
    return [
        'name' => $faker->name,
        'role_id'=>\App\Role::all()->random()->id,
        'last_name'=>$last_name,
        'slug'=>str_slug($name." ".$last_name,'-'),
        'picture'=>\Faker\Provider\Image::image(storage_patch().'/app/public/users',200,200,'people',false),
        'email' => $faker->unique()->safeEmail,
        'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
        'remember_token' => str_random(10),
    ];
});

Cuando me genera el error me señala el campo picture del archivo UserFactory

especificamente esta linea:

'picture'=>\Faker\Provider\Image::image(storage_patch().'/app/public/users',200,200,'people',false),

Lo que me tiene pensando es que tengo otra tabla que tambien necesita imagenes y no me genera error.

1 respuesta 1

2

Es un error tipográfico.

Cambia esta línea:

'picture'=> \Faker\Provider\Image::image(storage_patch().'/app/public/users', /** */),

por esta otra:

'picture'=> \Faker\Provider\Image::image(storage_path().'/app/public/users', /** */),

El nombre del helper es storage_path(), no storage_patch().

storage_path()

La función storage_path devuelve la ruta totalmente cualificada al directorio storage. También puede utilizar la función storage_path para generar una ruta totalmente cualificada a un archivo determinado dentro del directorio storage:

$path = storage_path();

$path = storage_path('app/file.txt');

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.