pllaguno

pllaguno

Member Since 9 Months Ago

Experience Points
1,190
Total
Experience

3,810 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
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

Level 1
1,190 XP
Jan
29
4 weeks ago
Activity icon

Started a new Conversation Combining Models For Api

I have a model named credit. This credit model has a State which has some requirements, these are meant to be files uploaded to the server. so i have another model named files to be saved in the DB.

My goal is to return a json object containing all of the files already uplaoded + the slots for the not uploaded ones because this are being placed under a table with the option to upload missing files.

the json response needs to have Name of the requirement, status, filename(might be blank if not uploaded yet), and comments;

The File Model has

the filename field, status, and comments. Whenever the file has not been uploaded i will return a blank filename and status of 0, but with the name of the required file;

Credito model:

class Credit extends Model
{
    protected $guarded = [];

    public function State(){
        return $this->belongsTo(State::class);
    }
    public function files(){
        return $this->hasMany(File::class);
    }
    
}

class State extends Model
{
    protected $guard = [];

    public function requirements(){
        return $this->belongsToMany(Requirement::class)->withTimestamps();
    }

}


class Requirement extends Model
{
    public function states(){
        return $this->BelongsToMany(State::class)->withTimestamps();
    }
}


class File extends Model
{
    public function credit(){
        return $this->belongsTo(Credit::class);
    }
}

I can grab the information needed, but I am stuck at how i should combine the two arrays to get the desired output, some kind of each requirement and check if the file exists, if it does make it equal to that file else, load the rest info as described at the beginning:

$requisitos = $credit->state->requirements;

$files = $credit->files;

Jan
21
1 month ago
Activity icon

Started a new Conversation Model Best Practices

More than a question i want to know other people thoughts on this.

I have a model where it has lots of fields, maybe 50. Is it a good practice to keep them all at the same model or would it be better to split it into other model that relate to it?

Ex. having a smaller model that has a address model, a contact model, a product detail model.

What are the pros and cons of each?

Activity icon

Replied to Controller Not Validating After First Error

@nakov that is true, what does that change do?

Activity icon

Replied to Controller Not Validating After First Error

@tray2 that helped, and after some more changes it is happening again, now when i submit, i dont get errors and only the form returns blank, how can i debug this? there is no log of whats happening?

Jan
20
1 month ago
Activity icon

Replied to Controller Not Validating After First Error

I am using old. the first submit it does work, not in the second

<div class="row">
                  <label class="col-sm-2 col-form-label">{{ __('Colonia') }}</label>
                  <div class="col-sm-7">
                    <div class="form-group{{ $errors->has('colonia') ? ' has-danger' : '' }}">
                      <input class="form-control{{ $errors->has('colonia') ? ' is-invalid' : '' }}" name="colonia" id="input-colonia" type="text"  placeholder="{{ __('Colonia') }}" value="{{ old('colonia') }}"  />
                      @if ($errors->has('colonia'))
                        <span id="colonia-error" class="error text-danger" for="input-colonia">{{ $errors->first('colonia') }}</span>
                      @endif
                    </div>
                  </div>
                </div>
Activity icon

Started a new Conversation Controller Not Validating After First Error

I have a form which i am trying to see if it will be error proof. When i submit the form with error i get the excepcted errors on the form. If i try to submit it again with the errors i don't get the form with the errors, i get it all erased, no old values.

this is my controller portion of the code.


public function store(){

        //dd(request());
        Credito::create($this->validatedData());
        
        return redirect('comercial.integracion.index');
    }


    protected function validatedData()
    {
        return request()->validate([
            'estado_id' => 'required|exists:estados',
            'venta' => 'required|integer|between:15,40',
            'municipio_id' => 'required|exists:municipios',
            'subcuenta' => 'required|numeric|min:80000',
            'gerente_id' => 'nullable|exists:users',
            'gerenteComision' => 'nullable',
            'ejecutivo_id' => 'nullable|exists:users',
            'ejecutivoComision' => 'nullable',
            'Coordinador_id' => 'nullable|exists:users',
            'CoordinadorComision' => 'nullable',
            'otro_id' => 'nullable|exists:users',
            'otroComision' => 'nullable',
            'nss' => 'required|numeric|digits_between:10,11|unique:App\Credito',
            'nombres' => 'required|string|max:100',
            'apellidoPaterno' => 'required|string|max:100',
            'apellidoMaterno' => 'required|string|max:100',
            'fechaNacimiento'=> 'required|date',
            'INE' => 'required|digits:13',


        ]);

    }
Jan
15
1 month ago
Activity icon

Replied to Getting Route To Work With Vue

@maverickchan thanks, made it work with the changes you suggested + some tinkering, what i don't understand is when to use the ':' for variables and when not to. what is the difference?

Activity icon

Replied to Getting Route To Work With Vue

i get invalid expression: Unexpected token ':' in doing that

Jan
14
1 month ago
Activity icon

Replied to Getting Route To Work With Vue

the component is loaded correctly atm i get the console log outpput as undefined, thats my issue, sorry if i was not clear

Activity icon

Started a new Conversation Getting Route To Work With Vue

i have a component inside another component. That component needs to have a button with a link to it. i am having a difficult time into getting it to work.

so in my blade file i got my component like this

<inscripcion-table route={{route('comercial.integracion.create')}}></inscripcion-table>   

and my inscripcion component has props like this and the passes it to the other component.

props:[
    'route'
  ],

<filter-bar route="this.route"></filter-bar>

where the button is suposed to work i have it like this

<button class="btn btn-secondary" @click.prevent="createNew(this.route)">Nuevo Expediente</button>

createNew: function (route){
        console.log(route);
        // window.location.href = route
      },

Jan
13
1 month ago
Activity icon

Started a new Conversation Conditional Relationship

I am not sure if something like this exists. i have searched the web and haven't find someone else trying to use something like this which might mean i am taking a wrong approach.

My user table has a column for 'role_id' so lets say role_id 1 is for admins and role_id 2 for managers. i want to have a relationship for admins and another for managers. is this doable? this relationship is for another model that is state(as in a country). with the relation i want to be able to get all admins of a certain state and all managers of that state too.

Jan
10
1 month ago
Activity icon

Replied to Can't Sync Many To Many Relation

hmmm, ill do some tinkering around, i did just copy and paste your suggestions though.

thanks

Jan
09
1 month ago
Activity icon

Replied to Can't Sync Many To Many Relation

both options gave me Method Illuminate\Database\Eloquent\Collection::sync does not exist.

but i fixed it with your explanation with this:

foreach ($Estados as $Estado) {
            $Estado->requisitos()->sync($requisitos);
        }

i do like more the way you suggested but i might be doing something else wrong.

thanks

Activity icon

Started a new Conversation Can't Sync Many To Many Relation

i have a many to many relation but when i try to sync it gives me an error.

Estado model has:


public function requisitos(){
        return $this->belongsToMany(Requisito::class)->withTimestamps();
    }

Requisito Model has:


public function estados(){
        return $this->BelongsToMany(Estado::class)->withTimestamps();
    }

and im doing the following sync, i basically want all requisitos to be synced to all estados.


$Estados = App\Estado::all();

        $requisitos = App\Requisito::all();

        $Estados->requisitos()->sync($requisitos);

but i get the error Method Illuminate\Database\Eloquent\Collection::requisito does not exist.

my table for sync is the following:


Schema::create('estado_requisito', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('estado_id');
            $table->unsignedBigInteger('requisito_id');
            $table->timestamps();
        });