Eloquent, Make items upgradable

Posted 10 months ago by Stank0V01

Hello i have some idea to ranks be upgradable! So i have categories products and orders!

So i want to make something like this

First i will give you some code and migrations:

Product structure:

        Schema::create('products', function (Blueprint $table) {

Orders structure:

        Schema::create('orders', function (Blueprint $table) {

So i will explain what column : required_product_id column must have id of product that must purchase first to purchase it! Second is max_buys

if max_buys is 1 product can be buyable only once , if its 0 it can purchased many times that i want.

If you want some example: http://iplexmc.eu/p/1 (It will ask you for username enter some random username and click here http://prntscr.com/k6qzby

(All products are in category so it is hasMany rel)


namespace App\Http\Controllers;

use App\Product;
use Illuminate\Http\Request;
use App\Category;
use App\User;
use App\Order;
use Illuminate\Support\Facades\DB;

class CategoriesController extends Controller
     * @param Category $category
     * @param User $user
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
    public function showProducts(Category $category, User $user)
        $products = $category->products();

        return view('products.category',['products'=>$products]);


Please help me , i don't know how to do that (I want products var to return and producta that be only once purchased) (When user purchase rank that is onlyOnce it will removed from the list)

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.