38 lines
885 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Node extends Model
{
use HasFactory;
protected $fillable = [
'name', 'pid', 'controller', 'action'
];
public static function getRouteUriById($arr) {
if (empty($arr) || !is_array($arr)) {
return [];
}
$res = self::select( 'route_uri')->whereIn('id', $arr)->get();
if ($res){
return $res->toArray();
}else{
return [];
}
}
public static function getNodeById($id) {
if (empty($id) || !is_numeric($id)) {
throw new \Exception('参数有误', ERROR_CODE_PARAM_INVALID);
}
$res = self::where('id', $id)->first();
if (!$res){
return [];
}
return $res->toArray();
}
}