0

Greetings Sirs. Can somebody help me with this problem i'm stuck here on this problem for about 4 days no.

What i wanted to do is this..

Add a device named "Project C"
And Add a Location "000-0001"
Add another Location "Jake"

First Input: Assign the device to Location "000-0001" and save to pivot table named device_location
and then the availability of the Device will be "Assigned to 000-0001"
Dissociate the device "Project C" to location "000-0001"
and then the availability of the device will be "Available"

here's where my problem go.

Second Input: Assign the Device "000-0001" on Location "Jake" and save it on the device_location.
My problem is it also displays the first input and the second input instead of display only the second input.

Here's my Location Model

<?php

class Location extends Eloquent {

    protected $fillable = array(
        'id',
        'name'
    );

    public function devices() {
        return $this->hasOne('Device');
    }


My Model for Device:

class Device extends Eloquent {


    use SoftDeletingTrait;

    protected $dates = ['deleted_at'];
    protected $softDelete = true;
    protected $fillable = array(
        'item_id',
        'name'
    );

    public function item() {
        return $this->belongsTo('Item');
    }

    public function infos() {
        return $this->hasMany('Info');
    }

    public function locations() {
        return $this->belongsTo('Location');
    }


and here's how i display it.

@foreach($locs as $locations)
                            @foreach($locations->devices as $devList)
                                <tr>
                                    <td>{{ link_to('Device/Track/'.$devList->id , $devList->name, array('title' => "Click to check this device's tracks.", 'id' => $item->id))  }}</td>
                                    <?php 
                                        if("Available" != $devList->availability ) {

                                            echo "<td><a class='label alert radius' id='fontSize-Device' >".$devList->availability ." to </td>";   
                                        } else {
                                            echo "<td><a class='label success radius' id='fontSize-Device' >".$devList->availability."</a></td>";
                                        }
                                    ?>

                                    <td>{{ Form::label('', $devList->status, array('class' =>'label success radius', 'id' => 'fontSize-Device')) }}</a></td>
                                    <td>
                                        <?php
                                            if("Available" != $devList->availability ) {
                                                echo "<a href='#' class='button tiny large-5 radius' onclick='dissociateDeviceProperty($devList->id, \"$devList->name\");' data-reveal-id = 'unAssignModal'>Dissociate</a>";
                                        } else {
                                            echo "<a href='#' class='button tiny large-5 radius' onclick='assignDeviceProperty($devList->id, \"$devList->name\")' data-reveal-id = 'assignModal'>Assign</a>";
                                        }
                                        ?>
                                    {{ link_to('', 'Edit', array('onclick' => 'getDevProperty('. $devList->id .', "'. $devList->name .'")', 'class' => 'button tiny large-0 radius', 'title' => 'Edit a Device', 'data-reveal-id' => 'editDeviceModal')) }} 
                                    {{ link_to('Device/delete/'. $devList->id.csrf_token(), 'Delete', array('class' => 'button tiny radius delete_user', 'title' => 'Delete selected Device', 'id' => $devList->id . csrf_token())) }}
                                    </td>
                                </tr>
                            @endforeach
                        @endforeach
1
Contributor
1
Reply
11
Views
3 Years
Discussion Span
Last Post by Jake.20
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.