Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Non-static method Laravolt\Avatar\Avatar::create() cannot be called statically #178

@obahchimaobi

Description

@obahchimaobi

❗ Issue: create() Throws “Non-static method should not be called statically”

Description

When attempting to generate an avatar in a Blade template using the Laravolt Avatar package, the following error occurs:

Non-static method Laravolt\Avatar\Avatar::create() cannot be called statically

This happens when following older documentation examples that use:

Avatar::create('Name')->toBase64();

Cause

The create() method is an instance method, not static:

public function create(string $name): static

Calling it statically triggers a fatal error.

Environment

  • PHP 8.3.x
  • Laravel 12.x
  • Laravolt/Avatar (latest version)
  • Blade view rendering

Steps to Reproduce

  1. Install the package
  2. Use the following in a Blade file:
{{ Avatar::create('John Doe')->toBase64() }}
  1. Load the view
  2. Error is thrown

Expected Behavior

Using the Avatar facade should correctly resolve the service container instance and allow proxying the create() instance method.

Actual Behavior

The static call triggers:

Non-static method Laravolt\Avatar\Avatar::create() cannot be called statically

Workaround

This works correctly:

{{ app('avatar')->create('John Doe')->toBase64() }}

Suggested Fix

  • Ensure the facade proxies instance methods properly, or
  • Update the documentation to reflect the correct usage pattern, or
  • Adjust the API to support static usage for consistency with previous versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions