1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\model;
- use support\Model;
- class SmartDevicesCategory extends Model
- {
- protected $table = 'smart_devices_category';
- protected $primaryKey = 'category_id';
- protected $dateFormat = 'U';
- const CREATED_AT = 'category_add_time';
- const UPDATED_AT = 'category_update_time';
-
- public function getParent($pid)
- {
- $parent = self::where('category_id', $pid)->first();
- return $parent ? $parent->toArray() : [];
- }
-
- public function getDirectSub($id)
- {
- return self::where('category_pid', $id)->get()->toArray();
- }
-
- public function updatePath($id, $path)
- {
- return self::where('category_id', $id)->update(['category_path' => $path]);
- }
- }
|