felipesmendes

Member Since 4 Years Ago

Experience Points
1,110
Total
Experience

3,890 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

  • Community Pillar

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

Level 1
1,110 XP
Mar
11
1 month ago
Activity icon

Started a new Conversation Livewire Encountered Corrupt Data When Trying To Hydrate The

Hello,

I had a livewire component that works in my development but in production server gives this error:

Livewire encountered corrupt data when trying to hydrate the [despesas.add] component. Ensure that the [name, id, data] of the Livewire component wasn't tampered with between requests.

http://flareapp.io/share/KPgkJNXP

Someone could please help me to solve that?

Dev versions: PHP 7.4.11

"require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.12",
        "laravel/jetstream": "^2.1",
        "laravel/sanctum": "^2.8",
        "laravel/tinker": "^2.5",
        "livewire/livewire": "^2.0",
        "mediconesystems/livewire-datatables": "^0.4.3"
    },

Production versions: PHP 7.4.16

"require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.12",
        "laravel/jetstream": "^2.1",
        "laravel/sanctum": "^2.8",
        "laravel/tinker": "^2.5",
        "livewire/livewire": "^2.0",
        "mediconesystems/livewire-datatables": "^0.4.3"
    },

Livewire Component

<?php

namespace App\Http\Livewire\Despesas;

use App\Models\Categoria;
use App\Models\Despesa;
use App\Models\Fornecedor;
use App\Models\Tipo;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;

class Add extends Component
{
    public $tipos;
    public $categorias;
    public $fornecedores;
    public Despesa $despesa;

    protected $rules = [
        'despesa.nome' => 'required',
        'despesa.valor' => 'required',
        'despesa.categoria_id' => 'required',
        'despesa.tipo_id' => 'required',
        'despesa.fornecedor_id' => '',
        'despesa.data_vencimento' => 'required',
        'despesa.data_pagamento' => 'required',
    ];

    public function save()
    {
        $validatedData = $this->validate();
        $validatedData["despesa"]["tenant_id"] = Auth::user()->tenant_id;
        $validatedData["despesa"]["valor"] = str_replace(",", ".", str_replace(".", "", $validatedData["despesa"]["valor"]));
        Despesa::create($validatedData["despesa"]);

        $this->emit("refresh");
        $this->emit("refreshLivewireDatatable");
    }

    public function mount(Despesa $despesa)
    {
        $this->despesa = $despesa ?? new Despesa;
        // $this->despesas = Despesa::orderBy("created_at","asc")->get();
        $this->tipos = Tipo::orderBy("nome")->pluck("nome", "id");
        $this->categorias = Categoria::orderBy("nome")->pluck("nome", "id");
        $this->fornecedores = Fornecedor::orderBy("razao_social")->pluck("razao_social", "id");
    }
    public function render()
    {
        return view('livewire.despesas.add');
    }
}

<div class="p-8">
    <form class="mb-5" method="POST" wire:submit.prevent="save">
        @csrf

        <div>
            <x-jet-label for="despesa.nome" value="{{ __('Nome') }}" />
            <x-jet-input id="despesa.nome" wire:model.debounce.500ms="despesa.nome" class="block mt-1 w-full" type="text" name="despesa.nome" :value="old('despesa.nome')" required autofocus autocomplete="despesa.nome" />
        </div>
        <div>
            <x-jet-label for="despesa.valor" value="{{ __('Valor') }}" />
            <x-jet-input id="despesa.valor" wire:model.debounce.500ms="despesa.valor" class="block mt-1 w-full valor" type="text" name="despesa.valor" :value="old('despesa.valor')" required autofocus autocomplete="despesa.valor" />
        </div>
        <div>
            <x-jet-label for="despesa.categoria_id" value="{{ __('Categoria') }}" />
            <select id="despesa.categoria_id" wire:model="despesa.categoria_id" class="select2 form-select block mt-1 w-full " name="despesa.categoria_id" value="{{old('despesa.categoria_id')}}" required autofocus autocomplete="despesa.categoria_id">
                @foreach($categorias as $id => $nome)
                <option value="{{$id}}">{{$nome}}</option>
                @endforeach
            </select>
            @error('despesa.categoria_id')
            <p class="text-sm text-red-600">{{ $message }}</p>
            @enderror

        </div>
        <div>
            <x-jet-label for="despesa.tipo_id" value="{{ __('Tipo') }}" />
            <select id="despesa.tipo_id" wire:model="despesa.tipo_id" class="select2 form-select block mt-1 w-full" name="despesa.tipo_id" value="{{old('despesa.tipo_id')}}" required autofocus autocomplete="despesa.tipo_id">
                @foreach($tipos as $id => $nome)
                <option value="{{$id}}">{{$nome}}</option>
                @endforeach
            </select>
            @error('despesa.tipo_id')
            <p class="text-sm text-red-600">{{ $message }}</p>
            @enderror
        </div>
        <div>
            <x-jet-label for="despesa.fornecedor_id" value="{{ __('Fornecedor') }}" />
            <select id="despesa.fornecedor_id" wire:model="despesa.fornecedor_id" class="select2 form-select block mt-1 w-full " name="despesa.fornecedor_id" value="{{old('despesa.fornecedor_id')}}" autofocus autocomplete="despesa.fornecedor_id">
                @foreach($fornecedores as $id => $nome)
                <option value="{{$id}}">{{$nome}}</option>
                @endforeach
            </select>
            @error('despesa.fornecedor_id')
            <p class="text-sm text-red-600">{{ $message }}</p>
            @enderror
        </div>
        <div>
            <x-jet-label for="despesa.data_vencimento" value="{{ __('Data Vencimento') }}" />
            <x-jet-input id="despesa.data_vencimento" wire:model.debounce.500ms="despesa.data_vencimento" class="date block mt-1 w-full" type="text" name="despesa.data_vencimento" :value="old('despesa.data_vencimento')" autofocus autocomplete="despesa.data_vencimento" />
        </div>
        <div>
            <x-jet-label for="despesa.data_pagamento" value="{{ __('Data Pagamento') }}" />
            <x-jet-input id="despesa.data_pagamento" wire:model.debounce.500ms="despesa.data_pagamento" class="date block mt-1 w-full" type="text" name="despesa.data_pagamento" :value="old('despesa.data_pagamento')" autofocus autocomplete="despesa.data_pagamento" />
        </div>
        <input type="hidden" wire:model="despesa.tentant_id" />


        <div class="flex items-center justify-end mt-4">
            <x-jet-button class="ml-4">
                {{ __('Cadastrar') }}
            </x-jet-button>


        </div>
    </form>

    <livewire:despesas.index model="App\Models\Despesa" />
</div>
@push('scripts')
<script>
    $(document).ready(() => {
        $('.select2').select2();
        $('.valor').mask('000.000.000.000.000,00', {
            reverse: true
        });
        $(".date").flatpickr({
            "locale": pt
        });



    })
</script>
@endpush
Mar
05
1 month ago
Activity icon

Replied to How To Protect Register Route And View In Jestream For Guest

Right, but in my file of routes (web.php) there is no route for register...

<?php

use App\Http\Controllers\CategoriasController;
use App\Http\Controllers\DespesasController;
use App\Http\Controllers\FornecedoresController;
use App\Http\Controllers\TiposController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return redirect('login');
});

Route::middleware(['auth:sanctum', 'verified'])->group(function () {
    Route::get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');

    Route::resource('tipos', TiposController::class);
    Route::resource('categorias', CategoriasController::class);
    Route::resource('fornecedores', FornecedoresController::class);
    Route::resource('despesas', DespesasController::class);

});
Activity icon

Replied to How To Protect Register Route And View In Jestream For Guest

Exacly! Taking advantage, could you give me an example of code using gate or police?

Activity icon

Replied to How To Protect Register Route And View In Jestream For Guest

Its not registering again, its registering another user.

Activity icon

Started a new Conversation How To Protect Register Route And View In Jestream For Guest

Hello,

I need to protect the register view and route to just logged user can register a new user.

How do I do that in jetstream?

Thank you all.

Feb
04
2 months ago
Feb
03
2 months ago
Activity icon

Started a new Conversation Import Select2 Installed By Npm And Use In Laravel

I'm trying to import select2 in my project but i'm gotting this error in the view:

jquery-3.5.1.min.js:2 Uncaught TypeError: $(...).select2 is not a function
    at HTMLDocument.<anonymous> (create:764)
    at e (jquery-3.5.1.min.js:2)
    at t (jquery-3.5.1.min.js:2)

I runned npm install select2

then added the require in my app.js

require('./bootstrap');

require('alpinejs');
require('jquery');
require('datatables.net');
window.ApexCharts = require('apexcharts');
window.Swal = require('sweetalert2')
require('select2');

After that I runned npm run dev and got the error when accesss the view.

What I'm doing wrong?

Jan
29
2 months ago
Activity icon

Replied to Erro In LiveWire Binding Directly To Model

@tykus Thank you, that's right!

Now it worked without the error

Activity icon

Replied to Erro In LiveWire Binding Directly To Model

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Cadastrar Tipo') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
                <livewire:add-tipo />
            </div>
            <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
                <livewire:list-tipo />
            </div>
        </div>
    </div>
</x-app-layout>
Activity icon

Replied to Erro In LiveWire Binding Directly To Model

I just follow this part of documentation, in this example they don't assigning nothing to the attribute

Binding Directly To Model Properties

If I'm doining it wrong please send me a example how I need to do

Activity icon

Started a new Conversation Erro In LiveWire Binding Directly To Model

Hello Guys,

I'm starting with livewire in my projects then I have one simple component that I will save one record.

Everything its ready as the livewire documentation but when I try to submit the record I'm gotting this error:

Typed property App\Http\Livewire\AddTipo::$tipo must not be accessed before initialization

Here is my blade form:

<div class="">
        <form method="POST" wire:submit.prevent="save">
            @csrf

            <div>
                <x-jet-label for="tipo.nome" value="{{ __('Nome') }}" />
                <x-jet-input id="tipo.nome" wire:model="tipo.nome" class="block mt-1 w-full" type="text" name="tipo.nome" :value="old('tipo.nome')" required autofocus autocomplete="tipo.nome" />
            </div>
            <input type="hidden" wire:model="tipo.tentant_id"/>


            <div class="flex items-center justify-end mt-4">
            <x-jet-button class="ml-4">
                    {{ __('Register') }}
                </x-jet-button>

              
            </div>
        </form>
</div>

Here is my Model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Tipo extends Model
{
    use HasFactory;
    protected $table="tipos";
    protected $guarded = [];
}


Here is my Lirewire Component:

<?php

namespace App\Http\Livewire;

use App\Models\Tipo;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;

class AddTipo extends Component
{
    public Tipo $tipo;

    protected $rules = [
        'tipo.nome' => 'required',
    ];
    public function save()
    {
        $this->validate();
        dd($this->tipo);
        $this->tipo->tentant_id = Auth::user()->tentant_id;
        $this->tipo->save();
    }
    public function render()
    {
        return view('livewire.add-tipo');
    }
}

Thank you for support.