carincon93

Experience

1,070

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

13th August, 2018

carincon93 started a new conversation Two Counts With Multiple Inner Join • 2 months ago

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
------------------------

12th August, 2018

carincon93 started a new conversation Create New Columns In A SQL Statement Using A Condition • 2 months ago

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"
]

7th August, 2018

carincon93 started a new conversation Import Fontawesome Css From Node_modules • 2 months ago

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?

28th July, 2018

carincon93 started a new conversation Prevent User To Change Form Action From Chrome Developer Tools • 2 months ago

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

26th July, 2018

carincon93 left a reply on I Need To Insert Data Array In Related Models • 2 months ago

@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 • 2 months ago

@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 • 2 months ago

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?

24th July, 2018

carincon93 started a new conversation Boolean Status With Input Radio - Vue • 2 months ago

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?

20th July, 2018

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

@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.

8th July, 2018

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

@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 • 3 months ago

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.

22nd May, 2018

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

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();

10th May, 2018

carincon93 left a reply on How Pass Variable To Flash Messages Without Concatenating • 5 months ago

with double quotes

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

carincon93 started a new conversation How Pass Variable To Flash Messages Without Concatenating • 5 months ago

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);

24th April, 2018

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

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"
]

21st April, 2018

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? • 6 months ago

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? • 6 months ago

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>

16th April, 2018

carincon93 left a reply on Two Nested Foreach Duplicate Options - Select Tag • 6 months ago

@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 • 6 months ago

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 • 6 months ago

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 • 6 months ago

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]);
}

7th April, 2018

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

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>


6th April, 2018

carincon93 started a new conversation Set Input Inside V-for • 6 months ago

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>

4th April, 2018

carincon93 left a reply on Input Checkboxes (checked) From Array Associative • 6 months ago

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

carincon93 started a new conversation Input Checkboxes (checked) From Array Associative • 6 months ago

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)

3rd April, 2018

carincon93 started a new conversation Input Array To Associative Json • 6 months ago

I need generate the following json through input array:

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

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

29th March, 2018

carincon93 left a reply on Dynamic Text Inside V-for • 6 months ago

@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 • 6 months ago

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>

´´´

27th March, 2018

carincon93 left a reply on [Vue - Laravel] V-for Dynamic With Input • 6 months ago

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 • 6 months ago

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.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.