romulo27

romulo27

Fortaleza

Member Since 4 Months Ago

Experience Points 6,580
Experience
Level
Lessons Completed 36
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

22 Jan
9 hours ago

romulo27 started a new conversation Laravel With Crud Traits

Guys, I need some help. I have a Product and a template for it, the template of these products may just have a price attached to it. When I create a price for the model I need to check if it already has the price, if it has I redirect it to update. How to make?

16 Jan
6 days ago

romulo27 left a reply on I Need To Show Array Of An Array

the dd ($ menu) returns me all the data up to the submenus, but I wanted to grab each menu index and check if it has submenu in it, if it has, just list the title of it.

romulo27 left a reply on I Need To Show Array Of An Array

@JLRDW - Like this?

 $keys = array_keys($menu['submenu']);
        for ($i = 0; $i < count($keys); ++$i) {
            echo $keys[$i] . ' ' . $menu['menu'][$keys[$i]];
        }

romulo27 left a reply on I Need To Show Array Of An Array

@MANELGAVALDA - No, Because the submenu is not an object

romulo27 left a reply on I Need To Show Array Of An Array

@MANELGAVALDA - But the $ menu is not an object

romulo27 left a reply on I Need To Show Array Of An Array

WebsiteMenuItem corresponds to the submenus that the Menu has, in this example the menu "Consorcio"

romulo27 started a new conversation I Need To Show Array Of An Array

Hi guys. I'm developing a CMS, which uses yaml files to manipulate the theme. My problem is that I need to list the Submenus of a Menu. I access for example the Header menu where I can change the contents of it, but in that Header has submenus, I just want to list them.

I have a service that does a search

Since the data is an array, how do I print it on the screen?

public function query() {

        /* @var $request Request */
        $request = app('request');

        /* @var $website Site */
        $website = $request->route('website');
        $menu = $request->route('submenu');

        // Carega configurações do site
        $this->service->loadWebsite($website->slug);
        /*
        - title: menu1
          submenu:
           - title: submenu 1.1
           - title: submenu 1.2
        - title: menu2
          submenu:
           - title: submenu 2.1
        */


        /*
        - title: menu1
        - title: - submenu 1.1
        - title: - submenu 1.2
        - title: menu2
        - title: - submenu 2.1
        */
        // puxa os menus da configuração do site
        $menus = $this->service->getWebsiteConfig($website->slug, 'menu.' . $menu . '.menu');

        dd($menus);
        return $menus;
    }


protected function toWebisteMenuItemCollection(string $menu, array $rows) { return collect($rows)->map(function (array $data, string $key) use ($menu) { $data['id'] = $menu . '.' . $key; if(isset($data['submenu']) && is_array($data['submenu'])) { $data['submenu'] = $this->toWebisteMenuItemCollection($data['id'], $data['submenu']); }

        return new WebsiteMenuItem($data);
    });
}

dd($menu)

 #attributes: array:3 [
        "title" => "Consórcio"
        "submenu" => Collection {#647
          #items: array:3 [
            0 => WebsiteMenuItem {#642
              #keyType: "string"
              #fillable: array:7 [
                0 => "id"
                1 => "title"
                2 => "label"
                3 => "imagem"
                4 => "website_image"
                5 => "icons"
                6 => "submenu"
              ]
              #connection: null
              #table: null
              #primaryKey: "id"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: false
              +wasRecentlyCreated: false
              #attributes: array:2 [
                "title" => "Planos de Consórcio"
                "id" => "header_submenu_menu.2.0"
              ]
              #original: []
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: []
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #guarded: array:1 [
                0 => "*"
              ]
            }
            1 => WebsiteMenuItem {#645
              #keyType: "string"
              #fillable: array:7 [
                0 => "id"
                1 => "title"
                2 => "label"
                3 => "imagem"
                4 => "website_image"
                5 => "icons"
                6 => "submenu"
              ]
              #connection: null
              #table: null
              #primaryKey: "id"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: false
              +wasRecentlyCreated: false
              #attributes: array:2 [
                "title" => "Portal do Consorciado"
                "id" => "header_submenu_menu.2.1"
              ]
              #original: []
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: []
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #guarded: array:1 [
                0 => "*"
              ]
            }
            2 => WebsiteMenuItem {#646
              #keyType: "string"
              #fillable: array:7 [
                0 => "id"
                1 => "title"
                2 => "label"
                3 => "imagem"
                4 => "website_image"
                5 => "icons"
                6 => "submenu"
              ]
              #connection: null
              #table: null
              #primaryKey: "id"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: false
              +wasRecentlyCreated: false
              #attributes: array:2 [
                "title" => "Como Funciona o Consórcio"
                "id" => "header_submenu_menu.2.2"
              ]
              #original: []
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: []
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #guarded: array:1 [
                0 => "*"
              ]
            }
          ]
        }
09 Jan
1 week ago

romulo27 started a new conversation How To Read Yaml Files In Laravel?

In the project I'm working on, it's a CMS, and within it I manage brand website themes. My question is I need to read the header of the file, how do I do this inside the controller?

Below is the file template that is to be read and uploaded, I want to load this

  • header:
  • header_submenu_menu
  • header_submenu_models
  • footer_mobile:
  • footer_desktop:
  • footer_socialmedia:
header:
    title: 'Menu do Topo do Site'
    hierarchical: false
    icons: true
    icon_preview: 'fonticons/menu-{icon}.svg'
    icon_list:
    - amburger
    - amburger-vert
    - assessoria
    - blog
    - concessionaria
    - concessionarias
    - consorcio
    - home
    - institucional
    - links
    - motos
    - ofertas
    - pecas
    submenus:
    - menu:
          title: 'Menu Principal'
    - modelos:
          title: 'Modelos'

header_submenu_menu:
    title: 'Submenu do Topo do Site'
    hierarchical: true
    icons: true
    icon_preview: 'fonticons/{icon}.svg'
    icon_list:
    - amburger
    - amburger-vert
    - assessoria
    - blog
    - concessionaria
    - concessionarias
    - consorcio
    - home
    - institucional
    - links
    - motos
    - ofertas
    - pecas

header_submenu_modelos:
    title: 'Submenu dos Modelos de Motos do Topo do Site'
    hierarchical: false
    images: true
    images_hover: true

footer_mobile:
    title: 'Menu do Rodapé Mobile'
    hierarchical: true

footer_desktop:
    title: 'Menu do Rodapé Desktop'
    hierarchical: true

footer_socialmedia:
    title: 'Menu de Redes Sociais'
    hierarchical: false
    icon_preview: 'sprites/f-sm-{icon}.png'
    icon_list:
    - facebook
    - instagram
    - twitter
    - youtube

romulo27 left a reply on Integrity Constraint Violation: 1062 Duplicate Entry

@LOSTDREAMER_NL - I use a BaseValidator, how to put a static class inside another?

protected $rules = [
        ValidatorInterface::RULE_CREATE => [
            'parent_id' => 'required_if:exists:site_contents,id',
            'slug' => [
                'string' , 'required',  rule::unique('site_contents', 'site_id')->where('site_id', $request()->get('set_id'))
                ],
            'title' => 'required|string'
        ],
        ValidatorInterface::RULE_UPDATE => [
            'parent_id' => 'required_if:exists:site_contents,id',
            'slug' => 'string|unique:site_contents',
            'title' => 'required|string'
        ],
    ];

romulo27 started a new conversation Integrity Constraint Violation: 1062 Duplicate Entry

Hi Devs. I need help. Stock developing a project that is a CMS. Then in case the mark creates a content for the site, withTitle, Identifier of the page (slug) , Content`.

If I make two validations, one more external: the same slug can be used by another brand, ex: site_id = 3, slug = home, site_id = 4, slug = home, this can, but if the same site_id = 4 for create the same slug for it, it check if it has and send a message, how to validate this second part?

03 Jan
2 weeks ago

romulo27 left a reply on The Current Request Does Not Have A File In A Key Named `emblem`

when I use the edit, I passing the empty image field it does not show me that error.

romulo27 left a reply on The Current Request Does Not Have A File In A Key Named `emblem`

@MANELGAVALDA - ' MediaCollectionDictionary::EMBLEM` is dictionary

romulo27 left a reply on The Current Request Does Not Have A File In A Key Named `emblem`

@MANELGAVALDA - So, i remove this? MediaCollectionDictionary::EMBLEM

romulo27 started a new conversation The Current Request Does Not Have A File In A Key Named `emblem`

When trying to register a variation of motorcycle without sending emblem and / or highlighted image causes failure, please correct.

The same does not occur when during the editing step.

  protected function syncImage(Request $request, Model $model)
    {
        $model->addMediaFromRequest(MediaCollectionDictionary::EMBLEM)
            ->toMediaCollection(MediaCollectionDictionary::EMBLEM);

        $model->addMediaFromRequest(MediaCollectionDictionary::FEATURED_IMAGE)
            ->toMediaCollection(MediaCollectionDictionary::FEATURED_IMAGE);
    }
14 Dec
1 month ago

romulo27 left a reply on Request Unique

Try

romulo27 left a reply on Request Unique

Query?

romulo27 started a new conversation Request Unique

I'm having a problem with my application. I have a CRUD where I choose a product and assign it nutrients to it, currently I only have 5 nutrintes. I am registering the nutrient and its value correctly, the problem is when I register a nutrinte repeated, instead of showing me an error to the user saying that nutrinte already was, he tries to register and the stick in the bank.

I tried to use unique, being that it bar any nutrinente that I try to register, even if it is new in this product.

How do I check if this nutrinente already exists?

I'm using the Backpack package.

12 Dec
1 month ago

romulo27 left a reply on Add Message For User

the button is this.

romulo27 left a reply on Add Message For User

methods: {
      handleDesactive() {
        if ( this.typeShow != 6 ) {
          axios.get(`/atas/${this.id}/desativar`)
            .then( res => eventHub.$emit('removeCard', this.id) );
          alert('desativado');
        } else {
          axios.get(`/atas/${this.id}/ativar`)
            .then( res => eventHub.$emit('removeCard', this.id) );
        }
      }
    }

romulo27 started a new conversation Add Message For User

has an option to enable and disable documents, it is working. In case I want to trigger a message to the user when it activates or deactivates the document. how to make?

11 Dec
1 month ago

romulo27 started a new conversation How Do I Pass The Value Of The Token Inside The Transformer?

I have a method where the user logs in, but I want to pass his token on the user transfomer, how to do?

// Authcontroller

 public function authenticate(Request $request){

        // grab credentials from the request
        $credentials = $request->only('email', 'password');

        try {
            // attempt to verify the credentials and create a token for the user
            if (!$token = JWTAuth::attempt($credentials)) {
                return $this->response->errorUnauthorized('dados incorretos');
            }
        } catch (JWTException $e) {
            // something went wrong whilst attempting to encode the token
            return $this->response->withError('could_not_create_token', 500);
        }

        $user = getAuthUser();

        if (!$user->active) {
            return $this->response->errorUnauthorized('usuário não ativo');
        }
        $user = $user->token;

        // all good so return the token
        return $this->response->withItem($user, new UserTransformer());
    }
//UserTransformer

    public function transform(User $user)
    {
        return [
            'id' => (int)$user->id,
            'name' => $user->name,
            'email' => $user->email,
            'photo_url' => $user->photo_url,
            'active' => $user->active,
            'phone_number' => $user->phone_number,
            'company_id' => $user->company_id,
            'token' => $user->token,
         ];
    }
30 Nov
1 month ago

romulo27 left a reply on Invite New User To The Company

The company_id, $invite->company_id

29 Nov
1 month ago

romulo27 started a new conversation Invite New User To The Company

I'm in a module where I invite users to my company. Today what I have is the following, The company sends the Token to the user's email, but at the moment he will register, but still without the id of the company. I want to get this id of the company that I invite, because when he signs up for the invitation the user has the company id already linked to him.

Invite Controller

public function accept(UserRequest $request, $token)
    {
        $invite = $this->invite->where('token', $token)->first();

        if (!$invite){
            return $this->response->errorNotFound('convite já foi usado ou não existe');
        }

        // Cria o usuário e Notifica.
        try{
            $data = $request->all();
            $data['role_id'] = 5;
            $data['activation_token'] = str_random(60);

            $member = $this->user->create($data);
            $member->notify(new RegisterActive());

            /* Notification: Membro cadastrado(user) */

            /* Notification: Membro da empresa cadastrado(company) */

            $invite->delete();

        }catch (\Error $error){
            $member->delete();
            return $this->response->withError('não foi possivel notificar o usuário', 502);
        }

        return $this->response->withItem($data, new UserTransformer);
    }

MIgrate Invite

Schema::create('invites', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable();
            $table->string('email')->unique();
            $table->string('token')->unique();
            $table->unsignedInteger('company_id');
            $table->foreign('company_id')->references('id')->on('companies');
            $table->timestamps();
        });

Invite Model

public function company()
    {
        return $this->hasOne(Company::class);
    }

Company Model

public function invite()
    {
        return $this->hasMany(Invite::class);
    }
17 Nov
2 months ago

romulo27 started a new conversation Conditional On Request

In my system I have a validation in the request, but I want this validation to be active or not depending on the type of product that I will register in ADMIN.

For example, product mode A has full cadastre with determined field, but product mode B not product type andcategory, all are consumed in the same request, how to do that product mode verification within the request?

I'm using the BACKPACK package

if (!$this->modality == ProductModalityDictionary::MARMITA){
            $this->crud->addField([
                'name' => 'product_type_id',
                'label' => 'Tipo de produto',
                'type' => 'select',
                'model' => 'App\ProductType',
                'entity' => 'productType',
                'attribute' => 'name',
            ]);

            $this->crud->addField([
                'name' => 'categories',
                'label' => 'Categoria',
                'type' => 'select2_multiple',
                'model' => 'App\ProductCategory',
                'entity' => 'productCategory',
                'attribute' => 'name',
                'pivot' => true,
            ]);
        }
16 Nov
2 months ago

romulo27 left a reply on Call To Undefined Method Illuminate\\Database\\Eloquent\\Builder::getFilter()

@SHUSHKIN - make a dynamic filter, along with paging, for the front to consume the api

romulo27 started a new conversation Call To Undefined Method Illuminate\\Database\\Eloquent\\Builder::getFilter()

I created a filter with pagination inside of laravel, but when I use it in a query it shows me an error.

What's wrong? "message": "Call to undefined method Illuminate\\Database\\Eloquent\\Builder::getFilter()",

public function getFilter($filter = null, $field = null, $paginate = null){
        if($filter && $field){
            if($paginate){// se houver paginação
                return $this->where($filter, "LIKE", "%{$field}%")->paginate($paginate);
            }
            // caso a paginação venha vazia
            return $this->where($filter, "LIKE", "%{$field}%")->get();
        }
        if($paginate){ // Verifica novamente a paginação
            return $this->paginate($paginate);
        }
        return $this->get();
    }

romulo27 left a reply on Laravel PDF

Send more information...

08 Nov
2 months ago

romulo27 left a reply on Problem With $fillable

Oh shit! just hahaha tks

romulo27 started a new conversation Problem With $fillable

Every time I make a seed, it shows me this error in Model / Company. What is the solution to this error?


   Symfony\Component\Debug\Exception\FatalThrowableError  : syntax error, unexpected 'protected' (T_PROTECTED), expecting identifier (T_STRING) or namespace (T_NAMESPACE) or \ (T_NS_SEPARATOR)

  at /home/vagrant/Projetos/src/pc4-champs-backend/app/Models/Company.php:39
    35| 
    36|     use Notifiable,
    37| 
    38| 
  > 39|      protected $fillable = [
    40|         'name',
    41|         'slug',
    42|         'cnpj',
    43|         'display_name',

  Exception trace:

  1   Composer\Autoload\includeFile("/home/vagrant/Projetos/src/pc4-champs-backend/vendor/composer/../../app/Models/Company.php")
      /home/vagrant/Projetos/src/pc4-champs-backend/vendor/composer/ClassLoader.php:322

  2   Composer\Autoload\ClassLoader::loadClass("App\Models\Company")
      [internal]:0

  Please use the argument -v to see more details.
`` `

class Company extends BaseModel {

use Notifiable,


 protected $fillable = [
    'name',
    'slug',
    'cnpj',
    'display_name',
    'description',
    'resume',
    'email',
    'site_url',
    'address',
    'photo_url',
    'phone_number',
    'phone_mobile',
    'address_number',
    'address_complement',
    'district',
    'zip_code',
    'city_id',
    'user_id',
    'profile_id',
];```
06 Nov
2 months ago

romulo27 started a new conversation Fractal API Transformer

I'm learning about Fractal and I saw this in the documentation, and I wanted to know, what's the difference between them?

        'author'
    ];
protected $defaultIncludes = [
        'author'
    ];
26 Oct
2 months ago

romulo27 left a reply on I Am Unable To Update The Logged-in User Profile

Before, in my route I was put and put in the we.php, and so it did not work, but when I switched to post in the two worked.

romulo27 left a reply on I Am Unable To Update The Logged-in User Profile

I switched to Post and it worked!

romulo27 left a reply on I Am Unable To Update The Logged-in User Profile

I solved it, it was the method in postman, Post! : D

romulo27 left a reply on I Am Unable To Update The Logged-in User Profile

public function update(UpdateUserRequest $request)
    {
        $user = Auth::user();
        $user->name = request()->input('name');
        $user->phone_number = request()->input('phone_number');
        $user->save();
    }

Request

 public function rules()
    {
        $user = getAuthUser();
        return [
            'name' => 'required',
            'phone_number' => 'required|min:11',
            //'photo_url' =>  'required|file'
        ];
    }

    public function messages()
    {
        return [
            'name.required' => 'Digite seu nome',
            'phone_number.required' => 'Adicione um numero para contato',
            'phone_number.min' => 'Seu número para contato deve conter 11 digítos',
//            'photo_url.required' =>  'Adicione um imagem ao seu perfil',
//            'photo_url.file' =>  'Adicione um arquivo de imagem',
        ];
    }

romulo27 left a reply on I Am Unable To Update The Logged-in User Profile

name and number comes empty yet, I created a request for it.

romulo27 left a reply on I Am Unable To Update The Logged-in User Profile

@Snapey , fields, name and phone_number

romulo27 left a reply on I Am Unable To Update The Logged-in User Profile

@tykus Are you talking about the headers?

romulo27 left a reply on I Am Unable To Update The Logged-in User Profile

in the postman. key: name value: 'romulo alves' key: photo_number value: '123456789'