cmprovision
cmprovision copied to clipboard
access project selected scripts in API
I can access the projects in the api and the scripts in the api but is there a way to see what scripts are selected for a project and possible push a new script through the api for a specific project?
Not something supported out of the box.
Although you can modify api.php to get the scripts as well.
E.g. if you want all script information included change https://github.com/raspberrypi/cmprovision/blob/main/routes/api.php#L34:L36 to:
Route::middleware('auth:sanctum')->get('/projects', function (Request $request) {
return Project::orderBy('name')->with('scripts')->get();
});
Or if you just want script IDs:
Route::middleware('auth:sanctum')->get('/projects', function (Request $request) {
return Project::orderBy('name')->with(['scripts' => function($query) { $query->select('id'); }])->get();
});
awesome I'll give that a try