Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how can we manage category and product in laravek

| id    | parent_id     | name          |
|----   |-----------    |-------------  |
| 1     | NULL          | Electronics   |
| 2     | 1             | Computers     |
| 3     | 2             | Accessories   |
| 4     | 3             | Keyboards     |
Comment

how can we manage category and product in laravek

| id    | category_id   | name          |
|----   |-------------  |-----------    |
| 1     | 2             | Product 1     |
| 2     | 3             | Product 2     |
| 3     | 4             | Product 3     |
Comment

how can we manage category and product in laravek

public function parent() {
    return $this->belongsTo(Category::class, 'parent_id');
}

public function childs() {
    return $this->hasMany(Category::class, 'parent_id');
}

public function products() {
    return $this->hasManyThrough(Product::class, Category::class, 'parent_id', 'category_id', 'id');
}
Comment

how can we manage category and product in laravek

public function categories() {
    return $this->belongsTo(Category::class, 'category_id');
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to auto increment id after delete value in php mysql 
Php :: old codestar radio field 
Php :: RequestCriteria laravel 
Php :: laravel view-model 
Php :: CURLAUTH_BEARER cannot find 
Php :: email with attcahment in joomla 
Php :: Hide products only show assigned products to certain user roles in WooCommerce 
Php :: php print array as string 
Php :: php google authenauthenticator 
Php :: submit form and send email in php 
Php :: executer page php via boutton 
Php :: if condition in laravel blade in select option 
Php :: SMARTY compose variable key array 
Php :: response in xml laravel 
Php :: laravel pass multipale provider 
Php :: Insert Data Into MySql Database Multiple Columns PHP Function 
Php :: php order array by specific key 
Php :: laravel file permission denied 
Php :: php get site metat tags 
Php :: laravel except route 
Php :: remove exact characters from string using php 
Php :: calculate 1 day interest 
Php :: carbon check sunday 
Java :: minecraft death counter 
Java :: spigot broadcast message 
Java :: what are the hibernate dependencies 
Java :: how to set the java_home in mac 
Java :: how to circular a bitmap android 
Java :: allow internet permission android 
Java :: spigot run task later 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =