Created
May 28, 2018 16:52
-
-
Save heryvandoro/71710141f5552294076a23b985a48991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use Illuminate\Database\Eloquent\Model; | |
class Category extends Model | |
{ | |
protected $with = ["sub_categories"]; | |
public function sub_categories(){ | |
return $this->hasMany("App\Models\Category", "parent_id", "id"); | |
} | |
public function parent(){ | |
return $this->belongsTo("App\Models\Category", "parent_id", "id"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment