headDesk2

Member Since 2 Years Ago

Experience Points
200
Total
Experience

4,800 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
200 XP
Jan
29
3 months ago
Activity icon

Replied to Unit Tests - RuntimeException : A Facade Root Has Not Been Set.

Martin, if you're still out there... :)

use App\Models\Fees\UsersSubscription;
use App\User;
use Faker\Generator as Faker;
use Illuminate\Support\Str;

$factory->define(UsersSubscription::class, function (Faker $faker) {
    return [
            'user_id' => User::Factory(),
            'fee_id' => Fee::Factory(),
            'active' => '1',
            'renew' => '1',
            'tcs_version' => '1',
            'existing_customer' => 1
    ];
});

My factories are 7.x style now. But when I do this...

        $user = factory(User::class)
            ->create()
            ->each(function ($u) {
                $u->usersSubscription()->save(factory(UsersSubscription::class)->make());
            });

I get this

BadMethodCallException : Call to undefined method App\User::Factory()

...but it works if I do this...

        $user = factory(User::class)
            ->create();

I should have been a lumberjack...

Activity icon

Replied to Unit Tests - RuntimeException : A Facade Root Has Not Been Set.

version 7.x here - I must have not checked the version of the docs before I started taking bits.

Thanks !

Activity icon

Replied to Unit Tests - RuntimeException : A Facade Root Has Not Been Set.

Thanks Martin, I am very much new to this so appreciate your help.

I now get the following error :

InvalidArgumentException : Unable to locate factory for [App\User].

I have this in database\factories\UserFactory.php


namespace Database\Factories;

use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\Str;
use App\User;

class UserFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = User::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
            'first_name' => $this->faker->name,
            'last_name' => $this->faker->name,
            'email' => $this->faker->unique()->safeEmail,
            'email_verified_at' => now(),
            'password' => 'yIXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
            'remember_token' => Str::random(10),
        ];
    }
}

Any further help would get me out of trouble, many thanks.

Activity icon

Replied to Unit Tests - RuntimeException : A Facade Root Has Not Been Set.

Hi Martin

Sorry for my imprecise language, assuming that I want to do this as a feature test, and I still get this error, what should I do then ?

Activity icon

Started a new Conversation Unit Tests - RuntimeException : A Facade Root Has Not Been Set.

Hi, I'm trying to create a factory to use in a unit test.

        $user = factory(User::class, 1)->create()->each(function($u) {
            $u->usersSubscription()
                ->save( factory(UsersSubscription::class)->make() )
                ->each(function($p){
                    $p->usersSubscriptionFeesCollection()->save(factory(UsersSubscriptionFeesCollection::class)->make());
                });
        });

and I get this error :

RuntimeException : A facade root has not been set.

Any help would be gratefully received.

Jan
22
3 months ago
Activity icon

Replied to Eloquent - Where Clause In Anonymous Function Not Behaving As Expected

It turns out you were right ! Once I'd added the where into the second clause, all was working.

Many thanks for your help.

Jan
21
3 months ago
Activity icon

Started a new Conversation Eloquent - Where Clause In Anonymous Function Not Behaving As Expected

Hi, I was hoping to get some advice on this innocuous piece of eloquent :

	    $users = User::with(['usersSubscriptionFeesCollection' => function ($q) use ($value) {
                $q->where('settled','=','0');
            }])
            ->with(['usersSubscription' => function ($q) use ($value) {
                $q->('active', '=', '1');
            }])
            ->where('active', '=', '1')
            ->get();

I expect the output of this to be the active users, the active userSubscriptions for the users, and the unsettled (settled = 0) usersSubscriptionFeesCollection for the userSubscriptions.

For some reason the output for this collection includes usersSubscriptionFeesCollection records with settled = 1 aswell as settled = 0. Oddly, the second with clause does behave as expected (only giving active usersSubscriptions.

If any patient developers can explain why this might happen, I'd be extremely grateful.