jginorio

jginorio

Member Since 4 Months Ago

Experience Points
920
Total
Experience

4,080 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
920 XP
Jul
19
2 months ago
Activity icon

Replied to Choose Between HasMany And BelongsToMany Relationship

You read my mind! I'm planning on adding the default pay in the positions table but I wanted to solve this problem first. HAHA I feel like that a many to many is more flexible in that way but when trying to save a new record is a pain because of the specific formatting the sync() method needs to receive the data.

Activity icon

Started a new Conversation Choose Between HasMany And BelongsToMany Relationship

Background Information:

I'm building an event management system for a sound company. It will allow them to better allocate their personnel. The company can be hired to provide sound reinforcement for many events.

An event can have many shifts. A shift is for setting up the equipment, running the show, and taking down the equipment.

Then, a shift is fulfilled by users who can hold many positions in the shift.

The user, on the other hand, can hold many positions.

NOTE: A user is not limited to a single position in the shift.

What I want:

I hardcoded some HTML to get the output I desire. I will attach the pictures below.

shift1 shift2 shift3

Basically, I want the admins of the company to sign up a user into a shift. In order to fulfill the necessary positions.

The Problem:

I think I have the database design correct but I'm still debating where to use a belongsToMany relationship and hasMany relationship.

Here is my initial database design:

Initial database design

Jul
12
2 months ago
Activity icon

Replied to How To Sync A 3 Model Pivot Table

So a User belongToMany Positions. But when in a crew it can have many positions. Like you see in the picture User 5 holds positions 1 and 4 in that order.

Where do I put that relationship in this new schema that you are proposing?

Activity icon

Replied to How To Sync A 3 Model Pivot Table

Wait, This won't work because a User can belong to many crew

Activity icon

Replied to How To Sync A 3 Model Pivot Table

I can try this out and see where I end up! I'll let you know. Thank you

Activity icon

Replied to How To Sync A 3 Model Pivot Table

Yes. In general terms, I want: a User can hold multiple Position within the crew that belongs to an Order

Activity icon

Started a new Conversation How To Sync A 3 Model Pivot Table

I want to sync a 3 model pivot table. This is how I can receive the data from my form.

$data = array(
	1 => ['user_id' => [0 => 5, 1 => 14]],
	2 => ['user_id' => [0 => 15]],
	3 => ['user_id' => [0 => 6]],
	4 => ['user_id' => [0 => 5]],
	6 => ['user_id' => [0 => 8, 1 => 3, 2 => 14]],
	7 => ['user_id' => [0 => 1]],
);

This is how I wish to store the data:

$order->crew()->sync($data);

This is how the database needs to look after the data is saved:

How database should look

The problem:

How can I do this?

Jul
11
2 months ago
Activity icon

Started a new Conversation Sync A Pivot Table With 3 Models Relationships Many To Many And One To Many

Information:

  • A sound company has many employees.
  • The employee has many positions in the company.
  • The company has many events. And for every event, they need a crew.
  • A crew is composed of many employees holding certain positions. An employee can hold multiple positions in a crew.

For example:

The list of employees is:

  • Employee 1 is a Driver, Sound Engineer and Stage Hand
  • Employee 2 is a Driver, Sound Engineer
  • Employee 3 is a Sound Engineer and Stage Hand
  • Employee 4 is a Stage Hand
  • Employee 5 is a Stage Hand

The event is called: Event 1

  • The crew is:
    • For the position of Sound engineer:
      • Employee 1
      • Employee 2
    • For the position of Stage Hand:
      • Employee 3
      • Employee 4
      • Employee 5
    • For the position of Driver:
      • Employee 2
      • Employee 1

Problem:

I believe this is done by using a pivot table that holds the event_id, employee_id and position_id

But when I follow this approach, I get stuck on feeding the data and the methods to use to create new data.

Is there a different approach?

Jun
28
2 months ago
Activity icon

Started a new Conversation Create Route To Attach A Product Model To Order Model

Background Information

I'm building an invoicing system...

I created:

  • Product Model with a restful ProductController
  • Order Model with a restful OrderController

Relationships:

  • Product belongToMany Order
  • Order belongToMany Product

My Goal:

From my orders/show.blade.php I want to be able to add more products to that specific order.

What I've Tried:

I created a form in the orders/show.blade.php view that hits this route below

Route::patch('orders/{order:code}/products/add', '[email protected]')->name('orders.products.add');

My Problem / Doubts:

Does this violate the Laravel Restful controller? Should I create another controller called OrderProductController? Is there a better way of accomplishing this?

Jun
16
3 months ago
Activity icon

Started a new Conversation Should I Make Two Tables For Serialized And Bulk Asset Tracking?

I'm developing an inventory asset tracking application. In this application, you can have three types of products: Stocked, Serialized, and None.

  • Serialized tracked products are physical objects that are assigned a unique barcode to each unit because they have unique serial numbers and attributes on each unit.
  • Bulk tracked products are physical objects that have a unique barcode that references to the product whose quantity should be tracked.
  • None tracked products are assigned a unique barcode that references to the product but is not tracked by quantity, but you can assign costs and prices to them.

Option 1:

Creating products table:

id // Primary key
name
details
slug
brand_id
category_id
tracking // Enum ['serialized', 'bulk', 'none']
value
rental_price
is_active

Creating a stocks table:

id // Primary Key
product_id
barcode
quantity // For serialized tracking, it defaults to 1. For bulk tracking, it will have the total quantity
condition // Enum ['great', 'damaged', 'broken']

Option 2:

Creating products table:

id // Primary key
name
details
slug
brand_id
category_id
tracking // Enum ['serialized', 'bulk', 'none']
value
rental_price
is_active

Creating a stocked_stocks table:

id // Primary Key
product_id
barcode
quantity // It will have the total quantity
condition // Enum ['great', 'damaged', 'broken']

Creating a serialized_stocks table:

id // Primary Key
product_id
barcode
condition // Enum ['great', 'damaged', 'broken']

Option 3:

Creating products table:

id // Primary key
name
details
slug
brand_id
category_id
tracking // Enum ['serialized', 'bulk', 'none']
value
rental_price
quantity // It will have the total quantity
is_active

Creating a stocks table:

id // Primary Key
product_id
barcode
condition // Enum ['great', 'damaged', 'broken']

Which of these three options should I go for?

Jun
15
3 months ago
Activity icon

Replied to How To Design The Relational Database For Inventory Asset Tracking Of Serialized And Bulk Items

@martinbean The practical use case is to manage all of the company's assets. It's focused on sound rental companies... not retail. The application will be a central system where they can keep track of the different attributes like firmware versions, serial numbers of each stock, and etc... They will also be able to prepare detailed invoices and track repairs and replacement parts for each product. I'm on a very early stage of development... therefore I'm focusing on creating the relationships and making sure I can create, update and delete products with their stocks.

The approach that you suggest sounds great and simple but focused for retail applications. I feel it takes out the ability to track each item individually.

For example: I have a Product called: "L-Acoustics K2 Line Array Speaker". I have 60 of them... so there will be 60 records created in the Stock table with a unique barcode because each speaker has a different serial number. I'm using a barcode to identify the stock, instead of serial numbers, because I want to track other items that might not have serial numbers or that the serial number is not obtainable.

At the same time, there are other products like cables, that I only care about the quantity. Because they don't have individual attributes like serial numbers or firmware versions. But it still needs to have one barcode so that I can scan the barcode when preparing for an event and specify the number of cables prepared for the event.

This is when I run into problems... because I feel that the way I design my database only allows me to have one of the scenarios... bulk or serialized products, but I want to have both

Activity icon

Started a new Conversation How To Design The Relational Database For Inventory Asset Tracking Of Serialized And Bulk Items

Background Information:

I'm learning Laravel 7 by creating an inventory tracking application. I have two models: Product and Stock.

The Product can be Serialized, Bulk, or None tracked.

  • Serialized tracked products are objects that have a unique serial number and attributes on each unit.
  • Bulk tracked products are physical objects whose quantity should be tracked.
  • None tracked products are not tracked by quantity, but you can assign costs and prices to them.

The Stock is where the barcode will be stored.

  • For serialized products, there will be multiple records belonging to a Product
  • For bulk products, there will be one record with the quantity belonging to a Product

What I have tried:

Creating products table:

id // Primary key
name
details
slug
brand_id
category_id
tracking // Enum ['serialized', 'bulk', 'none']
value
rental_price
is_active

Creating a stocks table:

id // Primary Key
product_id
barcode
quantity // For serialized tracking, it defaults to 1. For bulk tracking, it will have the total quantity
condition // Enum ['great', 'damaged', 'broken']

The Problem:

I'm struggling to create a relational database design. I feel the approach I took can get messy and inefficient if the database grows.

Is this the correct way of doing this? Is there a smarter way to address this?

Should I instead, add two columns in the products table for barcode and quantity and only fill those columns when the tracking is bulk?

Jun
10
3 months ago
Activity icon

Started a new Conversation Sync A Many-to-Many Relationship With Pivots

Background Information:

I'm creating an Asset Tracking System in Laravel.

  • I have a product that has many attributes.
  • The values for those attributes don't belong to the product; it belongs to its stock.

Grafical Ilustration of what I mean https://i.stack.imgur.com/O7kMU.png

The Problem:

How can I update the values for the attributes? I think I have my relationships correct because I went to the database and created each record individually and it works (as you can see in the previous picture). But I have no idea how to build the code to create them through the browser.

My Code:

Here is a photo of the relationships https://i.stack.imgur.com/W54ZO.png

This is my Product Model:

// Product.php
class Product extends Model {
	public function stocks()
	{
		return $this->hasMany(Stock::class)->orderBy('barcode', 'asc');
	}

	public function attributes()
	{
		return $this->hasMany(Attribute::class);
	}
}

This is my Attribute Model:

// Attribute.php
class Attribute extends Model {
	public function getValueByBarcode($stock)
	{
		return $this->values()->whereBarcode($stock)->first()->value ?? '';
	}

	public function product()
	{
		return $this->belongsTo(Product::class);
	}

	public function stocks()
	{
		return $this->belongsToMany(Stock::class);
	}

	public function values()
	{
		return $this->belongsToMany(Stock::class)->select('value');
	}

This is my Stock Model:

// Stock.php
class Stock extends Model {
	public function product()
	{
		return $this->belongsTo(Product::class);
	}

	public function attributes()
	{
		return $this->belongsToMany(Attribute::class)->withPivot('value');
	}
May
24
4 months ago
Activity icon

Started a new Conversation Should I Use Pipelines For Searching, Filtering, Sorting And Paginate

Goal:

I'm creating an inventory system in Laravel 7. I want to create a way to search, filter, limit, and paginate the products in my index.blade.php view. Very similar to what e-commerce pages have... Where you can filter by categories, active or inactive products, and search by the product's name or product id.

I already have the pagination by using Laravel's paginate function, but I still need to get the dynamic limit...

Problem:

I know there are several ways to accomplish this... Like creating pipelines, create methods in a Repository file and etc... Is there a Laravel way of doing this?

May
20
4 months ago
Activity icon

Started a new Conversation Is Having A Polymorphic Table For Storing My Image Information More Efficient Than A Separate Table For Each Model

Background Information:

In Laravel 7, I have many Models like Product, Variant, User, Container, and Package that can have an Image.

Problem:

Should I create a polymorphic table called images to store the images for all of the models?

Or is it more efficient to have separate tables to store the images of that specific model?

  • For example product_images, variant_images, user_images and etc...

Notes:

  • The Product has approximately 600 records.

  • The Variant has approximately 200 records.

  • The User has approximately 10 records.

  • The Container has approximately 300 records.

  • The Package has approximately 200 records.

Activity icon

Replied to How To Model My Data Efficiently

@bugsysha I'm sorry I'm lost. I don't know which table you want to get rid off or if you want to get rid of the variants table and just create a new product for each variation.

May
19
4 months ago
Activity icon

Replied to How To Model My Data Efficiently

Yeah, barcode references the variant, but I'm still not sure I understand why do you need to keep serial numbers in your database. Also you will not have one product/variant scattered in different locations in your warehouse? Repair should be based on serial number which has a reference to a product/variant and from there you track repairs.

@bugsysha Ahhh I see what you are trying to do... you want to replace the barcodes for serial numbers. I can give you a couple of reasons why this won't work.

  • I already have my data collected and there are two different stock (item) that have the same serial number.
  • I have a QR Code reader that acts like a keyboard and not all stocks (items) have the ability to scan the serial number because they might be 10 years old. The ones who have the ability might also be in a place where the scanner can't reach.
  • I have times where not all the stocks of the product have a serial number. This is for many reasons... the sticker might be washed away or broken or fell off. So if I have a total of 30 stocks, 10 of those stocks might have this problem.
  • I already made the investment of purchasing a total of 3,500 QR Codes and attached them to each stock.

Here is an image of an example. I still haven't added the attributes for Serial Number, Location, Last Repair and etc... but the should be on a column for each attribute between barcode and condition. https://drive.google.com/file/d/1LD9VL64BNuNeV0UFIAjG0CufKUuhedrS/view?usp=sharing

Activity icon

Replied to How To Model My Data Efficiently

@bugsysha I'm going to give you an example of why the stocks table is necessary and it can't be replaced by a column on the variants or products table. In my inventory, there is a Product called "L-Acoustics K2 Modular WST Line Source". I have a total of 60 of that product. All 60 of that product have different attributes specific to that item like Serial Numbers, location in the warehouse, if it has been repaired before, the condition it is, when it was bought and etc... Another product in my inventory is "Microphone cable" this product comes in many lengths (i.e. 25 feet, 50 feet, 100 feet and etc...). Therefore, it has many variants. In this case, not all cables have a specific barcode attach to it. This is why there's a column called quantity in the stocks table. In this case, the barcode will reference the variant. So when I'm preparing an order I can scan the variant's barcode and specify a quantity the order requires.

What would be your solution to modeling the data for this scenario?

Activity icon

Replied to How To Model My Data Efficiently

@bugsysha I care about the barcodes because each item in the inventory (i.e. speakers, cables, consoles, etc...) has a unique barcode. When performing inspections you can scan the item and log that you performed the inspection in that item (stock) and when creating an order, you can assign to the order a product with a quantity of 20. When you go to prepare the order, you scan each item and you know that that item went to that specific order... In other words, the barcode is like an SKU...

Activity icon

Replied to How To Model My Data Efficiently

@bugsysha Yes! I feel like this would be the case for when the product have different lengths or color or sizes; like cables... but when the product is something like a speaker, then it kind of becomes a group of stocks.

Activity icon

Replied to How To Model My Data Efficiently

@bugsysha No, because the stocks table holds the barcodes. For example: If the company has 60 speakers, there will be 60 records in the stocks table with a unique barcode pointing to that product or speaker.

Activity icon

Started a new Conversation How To Model My Data Efficiently

Project Specifications:

I'm building an inventory system focused on sound companies in Laravel 7. So far I have 3 models: Product, Variant, and Stock.

  • The product model is for creating the product itself.
  • The variant model is because the same product, lets say a cable can have many lengths.
  • The stock model is where the barcodes of each product are stored and you know the quantity of each product you have.

A product can take two paths:

product --> [hasMany] stocks

or

product --> [hasMany] variants --> [hasMany] stocks

As you can see, both paths end up having stocks.

The problem:

I want to be able to show the available quantity that each product has. If the product has variants, I want to be able to show the available quantity per variant.

What is the most efficient way to model this data? Should I use polymorphic relationships on the Stock Model? Should I create two stocks table (1 table for the Variant and 1 table for the Product)? Or should I use a hasManyThrough relationship with Variant and Stock?

What I've tried:

I created a polymorphic relationship for the Stock model. So that both Product and Variant models can have Stock. But I don't think this is the most efficient way.

Here is my database design https://drawsql.app/wsp/diagrams/wsp/embed

May
16
4 months ago
Activity icon

Started a new Conversation How To Display A Breadcrumb From Root The Category To The Product's Category

Goal:

On my product's detail page I want to display a breadcrumb of all the parent categories that my product has.

For example, if there is a product that is assigned a category_id pointing to a SubSubCategory; I want the breadcrumb to be:

Root Category / SubCategory / SubSubCategory

Problem:

Some products might a category_id that points to the root category (has no children) and other products might have a category_id that points to a category that is 2 levels deep (has two parents). How do I handle these scenarios?

What I have tried:

This is my https://i.stack.imgur.com/anCRh.png

This is my https://i.stack.imgur.com/g1iHS.png

So far, if I wanted to get the category breadcrumb of a specific product I would do it like this:

{{$product->category->parent->name}} / {{$product->category->name}}

But it quickly had errors with the products that had a root category assigned to them. Because I was trying to get a relationship that didn't exist.

May
14
4 months ago
Activity icon

Started a new Conversation How To Build A Database Schema For An Inventory System With Product Stock, Variation And Attributes?

Background Information:

I'm trying to learn how to build an inventory tracking system for a sound company. I'm new to this and have no experience but I'm a fast learner, so please go easy on me. Before I start building the application, I want to make sure that I have the correct relational database design.

Design Requirements:

Each product has a stock that can be tracked individually (each stock has its own barcode) or bulk (stock has one barcode). Bulk tracking is mostly for cables because it's hard to put a barcode for each cable and scan each cable when it goes to an event.

Where I'm stuck on:

The product may have different variations. For example: "Cable Lenght", "Container Size", "Color", "Microphone Gain" and etc... The company can have the same cable in different lengths. Or have the same container in different sizes. Instead of creating a product for each length, I want to create a product variation.

In addition, each product may have different attributes. For example: "Frequency Band", "Serial Number", "Container Dimensions", "Firmware Version" and etc... A wireless microphone has attributes like Frequency Band, Firmware Version, and Serial Number. While there are products like containers that only have dimensions.

I already have a database design but I'm sure it is not correct and there can be a lot of improvements

Notes:

  • Not every product has a variation.
  • So far, if the product has a variation is only one type that applies to that product.
  • Not every product has all of the attributes. Some may only have Serial Number and some may have none.
  • The main reason for creating a variation, instead of an attribute, is because I want to track the quantity of each product variation.

Information:

Database design I have in mind https://drawsql.app/wsp/diagrams/wsp/embed

Populated products table https://i.stack.imgur.com/XlUOk.jpg

Populated stocks table https://i.stack.imgur.com/qtz9V.jpg