Category.php 540 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Encore\Admin\Traits\AdminBuilder;
  5. use Encore\Admin\Traits\ModelTree;
  6. class Category extends Model
  7. {
  8. use ModelTree, AdminBuilder;
  9. public static function byIdGetChild($id)
  10. {
  11. return self::where('parent_id', $id)->pluck('title', 'id');
  12. }
  13. public static function getRoot()
  14. {
  15. return self::where('root', 'T')->pluck('title', 'id');
  16. }
  17. public static function byId($id)
  18. {
  19. return self::where('id', $id)->first();
  20. }
  21. }