Buy your loved one the ultimate gift. Lifetime gift certificates are $100 off.

nc1991

Experience

1,920

0 Best Reply Awards

  • Member Since 10 Months Ago
  • 17 Lessons Completed
  • 0 Favorites

7th October, 2017

nc1991 left a reply on Relationships, Get Products Where Relationship Table Belongs To The User • 2 months ago

I manage to get it to work via the hasthroughmany

/**
 * The products the user has sold
 */
public function sold()
{
    return $this->hasManyThrough('App\Models\Market\Purchases', 'App\Models\Market\Product');
}

5th October, 2017

nc1991 left a reply on Relationships, Get Products Where Relationship Table Belongs To The User • 2 months ago

Property [purchases] does not exist on this collection instance.

nc1991 left a reply on Relationships, Get Products Where Relationship Table Belongs To The User • 2 months ago

I'm not trying to get the items I've purchased :(, because I could just use Auth::user()->purchases, I'm just trying to get all rows from purchases where the product_id, belongs to a product I own

for example

    select * from purchases
left join products
    on products.id = purchases.product_id
where products.user_id = loggedin user's id

nc1991 left a reply on Relationships, Get Products Where Relationship Table Belongs To The User • 2 months ago

This gets the products that are purchased, but not a product that I own (user_id, auth)

https://i.imgur.com/mSwp9H4.png

https://i.imgur.com/zFjUVLY.png

nc1991 left a reply on Relationships, Get Products Where Relationship Table Belongs To The User • 2 months ago

Illuminate \ Database \ Eloquent \ RelationNotFoundException
Call to undefined relationship [product] on model [App\Models\Market\Product].

https://i.imgur.com/zKeyfpU.png

Also, the builder in case you need it: https://i.imgur.com/wiz3Hhc.png

nc1991 left a reply on Relationships, Get Products Where Relationship Table Belongs To The User • 2 months ago

So I am still getting that error, I have the relationships like so:

user.php

public function products()
{
    return $this->hasMany('App\Models\Market\Product');    
}

public function purchases()
{
    return $this->hasMany('App\Models\Market\Product');    
}

product.php

public function user()
{
    return $this->belongsTo('App\Models\Account\User');
}

public function purchases()
{
    return $this->belongsTo('App\Models\Market\Purchases');    
}

purchases.php

public function product()
{
    return $this->belongsTo('App\Models\Market\Product');    
}

public function user()
{
    return $this->belongsTo('App\Models\Account\User');    
}  

Any idea?

nc1991 left a reply on Relationships, Get Products Where Relationship Table Belongs To The User • 2 months ago

I seem to be getting an error doing that

Call to undefined relationship [product] on model [App\Models\Market\Product].

nc1991 started a new conversation Relationships, Get Products Where Relationship Table Belongs To The User • 2 months ago

So I have 2 tables products, and purchases, I am trying to get the purchases that belong to the owner of the product. Anyone can purchases, but only the user owns the product

I have my tables like so:

Schema::create('products', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('user_id');
    $table->string('title');
    $table->text('description');
    $table->string('category');
    $table->string('auction_type');
    $table->string('allow_offers');
    $table->string('condition');
    $table->integer('quantity');
    $table->integer('auctionlength');
    $table->decimal('buyitnow_price');
    $table->decimal('auction_price');
    $table->string('shipping');
    $table->decimal('shipping_cost');
    $table->integer('shipping_time');
    $table->string('international_shipping');
    $table->string('location');
    $table->string('allow_returns');
    $table->date('enddate');
    $table->timestamps();
    $table->softDeletes();           
});

Schema::create('purchases', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('user_id');
    $table->integer('product_id');
    $table->decimal('amount');
    $table->string('name');
    $table->string('address');
    $table->string('city');
    $table->string('state');
    $table->string('country');
    $table->string('postal');
    $table->string('email');
    $table->string('status');
    $table->timestamps();
    $table->softDeletes();
});

My two models are Purchases and Products, without raw query, how can I get the purcahse of products that belongs to user_id

15th February, 2017

nc1991 started a new conversation Is It Possible To Append A Package Resource To A Core Template • 9 months ago

For example, I have modules like so: polls, albums (pictures), now on my timeline I have hardcoded icons and javascript in my timeline:

I plan on creating modules for my scripts, so those modules won't installed by default, I can manually install the module via adding the views in the main layouts, but when I release my script, people won't know how to do it,

I've looked throughlaravel documentation to achieve this, but haven't found anything

For example, this is my status partials in a timeline modules:

<div class="box profile-info n-border-top">
    <form action="{{ route('CreateStatus') }}" method="post">
        {{csrf_field()}}
        <textarea class="form-control input-lg p-text-area" name="status" rows="2" placeholder="Whats in your mind today?"></textarea>
        <div class="box-footer box-form">
            <input type="submit" value="submit" class="btn btn-azure pull-right">
            <ul class="nav nav-pills">
                <li><a href="#"><i class="fa fa-map-marker"></i></a></li>
                <li><a href="#"><i class="fa fa-camera"></i></a></li>
                <li><a href="#"><i class=" fa fa-film"></i></a></li>
                <li><a href="#"><i class="fa fa-microphone"></i></a></li>
            </ul>
        </div>
    </form>
</div>

So, is there a way with packages to add partials from another module to another module automatically?

5th February, 2017

nc1991 started a new conversation My Vue Component Is Not Displaying • 10 months ago

I have a vue component, the /people is a json of all the people on the website like so:

        <div class="c-info">
            <strong>@{{ people.name }}</strong>
            <small></small>
        </div>

        <div class="c-footer">
            <button class="waves-effect"><i class="zmdi zmdi-person-add"></i> Add
            </button>
        </div>
    </div>
</div>

export default {
    data: function(){
        return {
            persons: []
        }
    },

    mounted: function()
    {
        this.getPeople();
    },

    methods:
    {
        getPeople: function() {
            axios.get("/people").then(function(response) {
                this.persons = response.data;
            }.bind(this));
        }
    }
}

That code is in Example.vue, and in my app.js I have the following code:

Vue.component('all-people', require('./components/Example.vue'));

const app = new Vue({ el: '#app', });

Now In my blade file I have the following HTML

@extends('layouts.main') @section('content')

    <div id="app">
        <all-people></all-people>
    </div>
</div>

@stop

When I load my page I'm getting no errors, but the template ins't displaying, here is the source:

How come it isn't working?

Edit Your Profile
Update

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