carincon93

carincon93

Member Since 9 Months Ago

Experience Points 1,230
Experience
Level
Lessons Completed 0
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.

27 Dec
2 weeks ago

carincon93 started a new conversation Insert Multiple Data In JSON

I need to generate the next JSON, the events save the month, day and year of all the projects in the db.

How do I pass the data inside the json?

public function make_json()
    {
        $projects = Project::orderBy('created_date')->get();

        $data = [
            "events" => [[
                "start_date" => [
                    "month" => "8",
                    "day" => "19",
                    "year" => "1963"
                ],
                "start_date" => [
                    "month" => "4",
                    "day" => "9",
                    "year" => "1968"
                ],
                "start_date" => [
                    "month" => "4",
                    "day" => "4",
                    "year" => "1972"
                ],
            ]],
        ]
13 Dec
1 month ago

carincon93 started a new conversation Create Input Hidden When The Check Box Is Checked

When I selected a check box, at the same time it creates a hidden input type in the form

// If I selected the two check boxes, these elements are created within the form.
<input type="checkbox" value="1">
<input type="checkbox" value="2">


<form action="index.php" method="POSTS">
    <input type="hidden" name="ids[]" value="1">
    <input type="hidden" name="ids[]" value="2">
</form>
24 Nov
1 month ago

carincon93 left a reply on Pass Response Data To The Parameters Of Another AJAX Request With AXIOS

@walidabou well, I made a method with the second axios.get and then in the (then) of the first axios call this method and pass the data that I need, it worked

carincon93 started a new conversation Pass Response Data To The Parameters Of Another AJAX Request With AXIOS

I have two axios.get in a method and I need to pass response data from first axios to the parameters of the second axios

Code

// Vue

data: function() {
    return: {
        schedule: {
            classroom_id: '',
            hour: '',
        }
    }
},
methods: {
    getClassroom() {
        
        axios.get('/get-schedule', params {
            day: 'monday',
        }).then(response => {

            //this response data has classroom_id and I want to send it to the second axios.get
            this.schedule = response.data;
        })

        axios.get('/get-classrooms', params {
            // HERE - I need to receive the classroom_id from first axios.get, 
but in this way the this.schedule.classroom_id does not set the parameter
            classroom_id: this.schedule.classroom_id

        }).then(response => {
            console.log(response.data);
        })

    }
}
13 Aug
5 months ago

carincon93 started a new conversation Two Counts With Multiple Inner Join

I have 3 tables with relationships

Projects ProjectEvaluations => project_id Observations => project_id

I need to generate two counts, one for qty of project evaluations and other one for observations

Like this

How can I do?

-----------.------------
count 1 |  count 2 |
    10                3
------------------------
12 Aug
5 months ago

carincon93 started a new conversation Create New Columns In A SQL Statement Using A Condition

I need to create new columns with the condition in a SQL statement, depending the user's profession, it's possible?

$project->users()->select('name, 'email', 'profession')->get()->toArray();

array:2 [▼
[
    "name" => "Juan Mejía"
    "email" => "[email protected]"
    "profession" => "Engineer"
]
[
    "name" => "Maicol"
    "email" => "[email protected]"
    "profession" => "Student"
]

If proffession is Engineer, the first new column "contractType1" changes to "yes", and the second new column changes to "no"

array:2 [▼
[
    "name" => "Juan Mejía"
    "email" => "[email protected]"
    "profession" => "Engineer"
    "contractType1" => "yes"
    "contractType2" => "no"
]
[
    "name" => "Maicol"
    "email" => "[email protected]"
    "profession" => "Student"
    "contractType1" => "no"
    "contractType2" => "yes"
]
07 Aug
5 months ago

carincon93 started a new conversation Import Fontawesome Css From Node_modules

I installed fontawesome with the npm command, and I want to use the css files from node_modules

Do I import it into the app.js or the app.scss?

app.js it works.

// app.js
require('./bootstrap');
require('chart.js');

import business from 'moment-business';
import 'datatables.net-bs4/css/dataTables.bootstrap4.css';
import '@fortawesome/fontawesome-free/css/all.css';

But in the app.scss, it does not work

// Variables
@import "variables";

// Bootstrap
@import '~bootstrap/scss/bootstrap';

@import '@fortawesome/fontawesome-free/css/all.css';

What is the right way?

28 Jul
5 months ago

carincon93 started a new conversation Prevent User To Change Form Action From Chrome Developer Tools

I tried to change the id of a form edit with Google Chrome development tools and after saving, the data has been updated.

edit.blade.php

<form action="{{ route('projects.update', $project->id) }}" method="POST">
        @csrf
        @method('PUT')
    <input name="description" type="text">

    <button type="submit">Update</button>
</form>

Form action - html

<form action="http://localhost:8000/panel/projects/3" method="POST">

And I changed the id in the forma action with google chrome development tools

<form action="http://localhost:8000/panel/projects/4" method="POST">

When I saved the form, all project data with ID 4 were updated

26 Jul
5 months ago

carincon93 left a reply on I Need To Insert Data Array In Related Models

@staudenmeir

The update still don't have code. How can I do update the objectives?

thx

carincon93 left a reply on I Need To Insert Data Array In Related Models

@staudenmeir

This code insert and associate but I don't know how can I do the Update

    $project = new Project();

    $project->projectName = $request->get('projectName');
    $project->save();

        if ( $request->get('objectiveDescription') ) {
            $countObjectives       = count(($request->get('objectiveDescription'));
            $objectiveDescription = $request->get('objectiveDescription');

            for($i = 0; $i < $countObjectives ; $i++) {
                $data = array(
                    'objectiveDescription '            => $descripcion[$i],
                    'project_id'            => $project->id,
                );

                $insertDataObjective[] = $data;
            }

            Objective::insert($insertDataObjective);
        }

carincon93 started a new conversation I Need To Save Related Models

I have this form:

<form action="{{ route('projects.store) }}" method="POST">
    <input name="projectName" type="text">

    <textarea name="objectiveDescription[]"></textarea>
    <textarea name="objectiveDescription[]"></textarea>
    
    <button type="submit">Save</button>
</form>

I need save the above form in two table at same time (projects and objectives).

// Projects table
id => 1
projectName => Example

// Objectives table
id => 1
objectiveDescription => text example
project_id => 1

id => 2
objectiveDescription => text example 2
project_id => 1
// Project model

public function objectives()
{
    return $this->hasMany('App\Objective');
}
// Objective model

public function project()
{
    return $this->belongsTo('App\Project');
}

How can I do?

24 Jul
5 months ago

carincon93 started a new conversation Boolean Status With Input Radio - Vue

I need to generate 3 radio input, when I checked the first, the status change to true, but when I checked the other 2 radio input, the status change to the false

// radio 1  => true
// radio 2 => false
// radio 3 => false
<input type="radio" name="tipoProyecto" value="" :checked="isChecked" required>
<input type="radio" name="tipoProyecto" value="" :checked="isChecked" required>
<input type="radio" name="tipoProyecto" value="" :checked="isChecked" required>
const app = new Vue({
    el: '#app',
    data: function () {
        return {
            isChecked: false,
        }
    },
})

How can I do?

20 Jul
5 months ago

carincon93 left a reply on I Need To Generate A Code With A Auto-increment Number

@lostdreamer_nl I found a problem, if I have 31 registered projects, the last code will be SIPRO-00032-2019, but if I delete a project, the last code will be the same SIPRO-00032-2019, I need the unique code.

08 Jul
6 months ago

carincon93 left a reply on MethodNotAllowedHttpException When I Enter The Url Of The 'ROUTE'::PUT In The Web Browser

@Cronix because the resource routes are:

Route::get('/posts/create', 'PostController');
Route::post('/posts', 'PostController');

Route::get('/posts/{id}', '[email protected]');

Route::get('/posts/{id}/editar', '[email protected]');
Route::put('/posts/{id}', '[email protected]');

The post, put and destroy routes are associated with get routes. For example, if I when entering to the put route to validate that there is no error, will show me the edit view:

I would have to create a route::get to associate the route::put

Route::get('/{idProject}/send', '[email protected]')

carincon93 started a new conversation MethodNotAllowedHttpException When I Enter The Url Of The 'ROUTE'::PUT In The Web Browser

This route is from an edit form and work correctly, but when I enter the url manually in the browser, I get the following error MethodNotAllowedHttpException.

I need to mask it in a 'Route::get' or how can I solve it?

Route::put('/{idProject}/send', '[email protected]')

thanks.

22 May
7 months ago

carincon93 started a new conversation I Need To Generate A Code With A Auto-increment Number

I need to generate a project code, with an auto-increment number, like this:

// SIPRO-00001-2018
// SIPRO-00002-2018
// SIPRO-00003-2018

But, when the year changes, the project code should be this (restart the auto-increment number):

// SIPRO-00001-2019
// SIPRO-00002-2019

My code. But when the year changes, if I have 200 projects, the code be SIPRO-00201-2019

$lastProject        =   Project::orderBy('created_at', 'desc')->first();

$project = new Project();

if (isset($lastProject)) {
    // Sum 1 + last id
            $project->code        = 'SIPRO-0000'.($lastProject->id + 1).'-'.date('Y');
        } else {
            $project->code        = 'SIPRO-00001-'.date('Y');
        }

$project->save();

10 May
8 months ago

carincon93 left a reply on How Pass Variable To Flash Messages Without Concatenating

with double quotes

"The user {$user->name} has been added"

carincon93 started a new conversation How Pass Variable To Flash Messages Without Concatenating

I need to pass a variable to a flash message, but without concatenating

return redirect()->route('users.index')
            ->with('status', 'The user ' .$user->name.' has been added');

I need something like this, it's possible?

return redirect()->route('users.index')
            ->with('status', 'The user {userName} has been added', $user->name);
24 Apr
8 months ago

carincon93 started a new conversation Print Old Data From A JSON In Multiple Textarea Into A Vue Component

I have multiple textareas in a vue component, and I need to print old data from a json, in the respective textarea

Description.vue

<div v-for="(invoice, index) in qty">
    <textarea name="description[]">{{ olddata }}</textarea>
</div>

// this code show each textarea with the following data
                    {{-- [
                    "text 1",
                    "text 2",
                    "text 3",
                    "text 4"
                    ] --}}

<script type="text/javascript">
export default {
    props: ['oldata'],

    data: function () {
        return {
            qty: 4,
        }
    }
}
</script>

Pass old data to the component

<description :oldata="{{ json_encode(old('description')) }}> </description>

JSON

[
  "text 1",
  "text 2",
  "text 3",
  "text 4"
]
21 Apr
8 months ago

carincon93 left a reply on How To Concatenate Index (v-for) In The 'id' Of Several Textareas And In The 'for' Attr Of The Label?

Solved:

<div v-for="(n, index) in 2">
    <label for="'item'+index">Item Nro. {{ index + 1 }}</label>
    <textarea id="'item'+index" name="itemName[]" rows="8" cols="80"></textarea>
</div>

carincon93 started a new conversation How To Concatenate Index (v-for) In The 'id' Of Several Textareas And In The 'for' Attr Of The Label?

I need to generate this text area with its respective id and the label with the correct 'for'

<label for="item1">Item Nro. 1</label>
<textarea id="item1" name="itemName[]" rows="8" cols="80"></textarea>

<label for="item2">Item Nro. 2</label>
<textarea id="item2" name="itemName[]" rows="8" cols="80"></textarea>

This is the v-for

<div v-for="(n, index) in 2">
    <label for="item">Item Nro. {{ index + 1 }}</label>
    <textarea id="item" name="itemName[]" rows="8" cols="80"></textarea>
</div>
16 Apr
9 months ago

carincon93 left a reply on Two Nested Foreach Duplicate Options - Select Tag

@Sergiu17 your code only show the roles assigned to user, I need to show all roles selecting the assigned to user

carincon93 started a new conversation Two Nested Foreach Duplicate Options - Select Tag

I need to select the options with user roles

<select class="form-control" name="role_user">
// foreach - all roles
    @foreach ($roles as $role)
// foreach - roles user
        @foreach($usuario->roles as $userRole)
        <option value="{{ $role->id }}" {{$role->id == $userRole->id ? 'selected' : ''}} >{{ $role->name }}</option>
        @endforeach

    @endforeach
</select>

The previous code shows the following duplicate options:

student student admin admin

carincon93 left a reply on Update Records In Pivot Table

thanks @bobbybouwmann, I did not know the function of updateExistingPivot, I solved it with

$proyecto->semilleros()->sync($semilleros);

carincon93 started a new conversation Update Records In Pivot Table

I need to update multiple record in a pivot table, but not work

Code:

<select class="form-control" name="role_user">
    @foreach ($roles as $role)
        @foreach($user->roles as $userRole)
        <option value="{{ $rol->id }}" {{$rol->id == $userRole->id ? 'selected' : ''}} >{{ $role->name }}</option>
        @endforeach
    @endforeach
</select>
// Array roles
$idRole  = $request->get('rol_user');
// Update existing pivot
foreach ($user->roles as $userRole) {
    $user->roles()->updateExistingPivot($userRole->id, ['rol_id' => $idRol]);
}
07 Apr
9 months ago

carincon93 started a new conversation Set V-bind:value Dynamically Of An Input, Using V-for

How can I simplify that code, I need to set the v-bind-value="diff1" associates with v-model="startDate1" and v-model="endDate1", same for diff2 with dates startDate2 and endDate2.

<h1>C01</h1>
<div class="form-group">
    <label>Star Date</label>
    <input type="date" name="startDate[]" class="form-control" v-model="startDate1">
</div>
<div class="form-group">
    <label>End date</label>
    <input type="date" name="endDate[]" class="form-control" v-model="endDate1" @change="moment1(startDate1, endDate1)">
</div>
<div class="form-group">
    <label>Duration (days)</label>
    <input type="number" name="duration[]" class="form-control" readonly v-bind:value="diff1">
</div>

<h1>C02</h1>
<div class="form-group">
    <label>Start date</label>
    <input type="date" name="starDate[]" class="form-control" v-model="startDate2">
</div>
<div class="form-group">
    <label>End date</label>
    <input type="date" name="endDate[]" class="form-control" v-model="endDate2" @change="moment2(startDate2, endDate2)">
</div>
<div class="form-group">
    <label>Duration (days)</label>
    <input type="number" name="duration[]" class="form-control" readonly v-bind:value="diff2">
</div>

<script type="text/javascript">
export default {
    data: function () {
        return {
            starDate1: [],
            enDate1: [],
            diff1: [],
            startDate2: [],
            endDate2: [],
            diff2: [],
        }
    },
    methods: {
        moment1: function (starDate1, fechaFina) {
            var self = this;
            var date1 = moment(starDate1, 'YYYY/MM/DD');
            var date2 = moment(fechaFina, 'YYYY/MM/DD');
            
            self.diffa = date2.diff(date1, 'days');
        },
        moment2: function (startDate2, endDate2) {
            var self = this;
            var date1 = moment(startDateb, 'YYYY/MM/DD');
            var date2 = moment(endDateb, 'YYYY/MM/DD');
            
            self.diff2 = date2.diff(date1, 'days');
        }
    },
}
</script>


06 Apr
9 months ago

carincon93 started a new conversation Set Input Inside V-for

I need inside that v-for set duration input with your respective diff days between start date and end date.

<div v-for="(qty, index) in 4">
    <div class="form-group">
                <label for="[object Object]">Start Date</label>
                <input type="date" name="startDate[]" class="form-control" v-model="startDate">
            </div>
            <div class="form-group">
                <label for="[object Object]">End Date</label>
                <input type="date" name="endDate[]" class="form-control" v-model="endDate" @change="moment(startDate, endDate)">
            </div>
            <div class="form-group">
                <label>Duration (days)</label>
                <input type="number" name="duration[]" class="form-control" readonly v-bind:value="diff">
    </div>
</div>

<script type="text/javascript">
export default {
    data: function () {
        return {
            startDate: [],
            endDate: [],
            diff: [],
        }
    },
    methods: {
        moment: function (startDate, endDate) {
            var self = this;
            var date1= moment(startDate, 'YYYY/MM/DD');
            var date2= moment(endDate, 'YYYY/MM/DD');

            self.diff = date2.diff(date1, 'days');
        }
    },
}
</script>
04 Apr
9 months ago

carincon93 left a reply on Input Checkboxes (checked) From Array Associative

@Cinek thanks, and this input editar-rol was a mistake

carincon93 started a new conversation Input Checkboxes (checked) From Array Associative

I need to checked multiple input checkbox from an array

this $rol->permisos show this array:

array:2 [▼
 "editar-usuario" => true
 "editar-rol" => true
]
@foreach ($rol->permisos as $key => $permiso)
                           <input type="checkbox" name="" value="" {{ $key == 'editar-rol' ? 'checked' : ''}}>1
                           <input type="checkbox" name="" value="" {{ $key == 'crear-rol' ? 'checked' : ''}}>2
                           <input type="checkbox" name="" value="" {{ $key == 'editar-rol' ? 'checked' : ''}}>3
@endforeach

but this code show 6 input (it multiplies the quantity items in the array)

03 Apr
9 months ago

carincon93 started a new conversation Input Array To Associative Json

I need generate the following json through input array:

{"crear-proyecto": true, "editar-proyecto":true}

´´´ {{ __('crear-proyecto') }} {{ __('editar-proyecto') }} ´´´

29 Mar
9 months ago

carincon93 left a reply on Dynamic Text Inside V-for

@topvillas I need v-model="message1" write p {{ message1 }}, v-model="message2" on p {{ message2 }} ....

carincon93 started a new conversation Dynamic Text Inside V-for

I need to create 10 input, each with a different v-model to write to the corresponding

<div v-for="(n, index) in 10">

   <input type="text" v-model="message">
   <div>
       <p>
           {{ message }}
       </p>
   </div>
   
</div>

´´´
27 Mar
9 months ago

carincon93 left a reply on [Vue - Laravel] V-for Dynamic With Input

Solution: v-model.number

<input type="number" v-model.number="qty" @onchange="crateItems">

carincon93 started a new conversation [Vue - Laravel] V-for Dynamic With Input

I need to make a list of items with a dynamic v-for.

In an input type number, a specific number is placed and from that number a list of html elements is built.