Support the ongoing development of Laravel.io →
posted 6 months ago
Last updated by @tvbeek 6 months ago.
0

You need to use faker like this:

$this->faker->sentence()

Last updated by @wobbienl 6 months ago.
0

I put the code in and got this error

class ListingFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition()
    {
        return [
            'title' => $this-&gt;faker-&gt; sentence(),
            // 'tags' => 'Laravel, API, Backend',
            // 'company' => $this->faker()->company(),
            // 'location' => $this->faker()->city(),
            // 'email' => $this->faker()->companyemail(),
            // 'website' => $this->faker()->url(),
            // 'description' => $this->faker()->paragraph(5),
        ];
    }
}

ParseError

syntax error, unexpected token "&"

at database\factories\ListingFactory.php:20 16▕ */ 17▕ public function definition() 18▕ { 19▕ return [ ➜ 20▕ 'title' => $this->faker-> sentence(),

Commented out several lines just trying to limit until I get some code working

Last updated by @tvbeek 6 months ago.
0
moderator

@rkellogg12 I see in your code that you have a -&gt; (the html attribute) and not the arrow -> that result in the error. If you change it I suspect that it will work.

Ps. I have updated your posts to have clear codeblocks.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Roger rkellogg12 Joined 12 Oct 2023

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.