ajsmith_codes
6 months ago
869
4
Laravel

View missing after rename. Laravel 7 - TDD app

Posted 6 months ago by ajsmith_codes

After completing Episode 27, Get into the Refactor Flow, my app is broken. I'm still very new so I'm not certain how to debug or find what's going wrong.

Originally, the view was named updated.blade.php. During this episode, he has us rename it to updated_project.blade.php. It's in the folder resources\views\projects\activity.

I did what I thought was a safe refactor when I renamed it, but I guess not.

Here is the error:

View [projects.activity.updated] not found. (View: C:\xampp\php\crm_clone\resources\views\projects\activity\card.blade.php)

Any suggestions on where to start looking? I tried doing a search (I'm using phpstorm) and couldn't find any usages of updated.blade.php. However, I may not be searching correctly.

Here is the RecordsActivity.php (trait) file just in case:

{

public $oldAttributes = [];

/*
 * Boot the trait
 */
public static function bootRecordsActivity()
{

   foreach (self::recordableEvents() as $event) {
        static::$event(function ($model) use ($event) {
            $model->recordActivity($model->activityDescription($event));
        });


        if ($event === 'updated'){
            static::updating(function ($model) {
                $model->oldAttributes = $model->getOriginal();
            });
        }

   }

}

protected function activityDescription($description){

       return "{$description}_" . strtolower(class_basename($this)); //created_

}

/**
 * @return array
 */
protected static function recordableEvents(): array
{
    if (isset(static::$recordableEvents)) {
        return static::$recordableEvents;
    }
    return ['created', 'updated', 'deleted'];

}


/**
 * Record activity for a project.
 *
 * @param $description
 */
public function recordActivity($description)
{
    $this->activity()->create([
        'description' => $description,
        'changes' => $this->activityChanges(),
        'project_id' => class_basename($this) === "Project" ? $this->id : $this->project_id
    ]);
}


protected function activityChanges()
{
    if ($this->wasChanged()) {

        return [
            'before' => arr::except(array_diff($this->oldAttributes, $this->getAttributes()), 'updated_at'),
            'after' => arr::except($this->getChanges(), 'updated_at')
        ];
    }
}


/**
 * The activity feed for the project.
 *
 * @return \Illuminate\Database\Eloquent\Relations\MorphMany
 */
public function activity()
{
    return $this->morphMany(Activity::class, 'subject')->latest();
}

}

Please sign in or create an account to participate in this conversation.