Giter Club home page Giter Club logo

Comments (9)

uyab avatar uyab commented on May 24, 2024

Which version did you use?

And also, could you provide the code when generating avatar?

from avatar.

robindirksen1 avatar robindirksen1 commented on May 24, 2024

Same problem here.

from avatar.

uyab avatar uyab commented on May 24, 2024

@robindirksen1 can you provide more valuable information: which version did you use, code snippet when generating avatar, and dump result from calling dd(config("laravolt.avatar")).

from avatar.

robindirksen1 avatar robindirksen1 commented on May 24, 2024

dd(config("laravolt.avatar"));

array:13 [▼
  "driver" => "gd"
  "generator" => "Laravolt\Avatar\Generator\DefaultGenerator"
  "ascii" => false
  "shape" => "square"
  "width" => 1000
  "height" => 1000
  "chars" => 2
  "fontSize" => 500
  "uppercase" => false
  "fonts" => array:2 [▶]
  "foregrounds" => array:1 [▼
    0 => "#FFFFFF"
  ]
  "backgrounds" => array:15 [▼
    0 => "#f44336"
    1 => "#E91E63"
    2 => "#9C27B0"
    3 => "#673AB7"
    4 => "#3F51B5"
    5 => "#2196F3"
    6 => "#03A9F4"
    7 => "#00BCD4"
    8 => "#009688"
    9 => "#4CAF50"
    10 => "#8BC34A"
    11 => "#CDDC39"
    12 => "#FFC107"
    13 => "#FF9800"
    14 => "#FF5722"
  ]
  "border" => array:2 [▼
    "size" => 1
    "color" => "foreground"
  ]
]

To create avatar:

<img src="{{ $a->create(Auth::user()->name)->toBase64() }}" class="changeable">

AppServiceProvider.php

public function boot()
    {
        Schema::defaultStringLength(191);

        $a = new Avatar();
        View::share('a', $a);
    }

from avatar.

uyab avatar uyab commented on May 24, 2024

Ah, so you are instantiate Avatar class manually, instead of using Facade. If that is what you want, you can take a look how Avatar internally created:

https://github.com/laravolt/avatar/blob/master/src/ServiceProvider.php#L25-L28

You need to pass config too.

Just curious, why dont you use register the alias 'Avatar' => Laravolt\Avatar\Facade::class so you can call it in view like this (just as documented):

Avatar::create('Joko Widodo')->toBase64();

from avatar.

robindirksen1 avatar robindirksen1 commented on May 24, 2024

I tried but that it says the follow:

Method Illuminate\View\View::__toString() must not throw an exception, caught ErrorException: Non-static method Laravolt\Avatar\Avatar::create() should not be called statically

from avatar.

robindirksen1 avatar robindirksen1 commented on May 24, 2024

Okay, it works. I removed Laravolt\Avatar\, forgot that it is assign as a Facade.

Avatar::create(Auth::user()->name)->toBase64()

from avatar.

sarthaksavvy avatar sarthaksavvy commented on May 24, 2024

use config in avatar class,
$avatar = new Avatar(config('laravolt.avatar'));
then use $avatar->create($name)->toBase64();

from avatar.

uyab avatar uyab commented on May 24, 2024

Thanks @sarthaksavvy , that sholud works if you dont use Laravel Facade

from avatar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.