Error Call to undefined function storage_patch () when I run a seeder in laravel

0

I'm trying to run a seeder but I get the error: Call to undefined function storage_patch() I could not find the one.

I have a table in migration called user with the sgts fields:

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');

    }
}

The factory for the users I have them like this:

<?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),
    ];
});

When I get the error, it tells me the picture field in the file UserFactory

specifically this line:

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

What I have thinking is that I have another table that also needs images and does not generate an error.

    
asked by Juanzu 26.10.2018 в 21:08
source

1 answer

2

It's a typographical error.

Change this line:

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

for this one:

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

The name of the helper is storage_path() , not storage_patch() .

  

storage_path()

     

The storage_path function returns the fully qualified route to   directory storage . You can also use the function storage_path   to generate a fully qualified route to a specific file   inside the storage directory:

$path = storage_path();

$path = storage_path('app/file.txt');
    
answered by 27.10.2018 / 14:48
source