lundi 27 mai 2019

How get record from DB in Laravel (user Avatar)?

I'm beginner in Laravel.

I have problem with create new user.

I have this code:

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;
    use cms\Presenters\UserPresenter;

    public static $roles = [];


    protected $fillable = ['company_id', 'enable', 'name', 'surname', 'email', 'email_verified_at', 'password', 'enable_map', 'remember_token', 'created_at', 'updated_at', 'last_login_at' ];

    protected $hidden = [
        'password', 'remember_token',
    ];


    public function hasRole(array $roles)
    {

        foreach($roles as $role)
        {

            if(isset(self::$roles[$role]))
            {
                if(self::$roles[$role])  return true;

            }
            else
            {
                self::$roles[$role] = $this->roles()->where('name', $role)->exists();
                if(self::$roles[$role]) return true;
            }

        }
        return false;
    }

}



Schema::create('uploaded_files', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('company_id')->unsigned();
            $table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
            $table->boolean('enable')->default(0);
            $table->string('photoable_type', 150);
            $table->integer('photoable_id');
            $table->string('path', 255);
            $table->string('ip', 25);
            $table->bigInteger('number')->default(0);
            $table->timestamps();
            $table->engine = "InnoDB";
        });

How can I get user avatar from this DB?

I would like to download a picture (Avatar) of the user. Parameters of the image, which is an avatar:

photoable_type = 'UserAVATAR' photoable_id = id User

How can I do it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire