-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for item updates, add clockwork and add the graphcontroller
- Loading branch information
Showing
15 changed files
with
401 additions
and
213 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Item; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Session; | ||
use Inertia\Inertia; | ||
|
||
class GraphController extends Controller | ||
{ | ||
public function index(Request $request) | ||
{ | ||
$query = Item::query() | ||
->select('json_items', 'id', 'title', 'photo') | ||
->without('attributes'); | ||
$pythonItem = $query->clone() | ||
->where('id', env('PYTHON_ID')) | ||
->firstOrFail(); | ||
$items = $query->clone(); | ||
$selected = Session::get('selected'); | ||
if ($selected) { | ||
$items = $items | ||
->whereIn('id', $selected) | ||
->whereNot('id', env('PYTHON_ID')) | ||
->get(); | ||
} else { | ||
$items = $items->whereNot('id', env('PYTHON_ID')) | ||
->get(); | ||
} | ||
|
||
$nodes = $query->clone() | ||
->whereIn('id', $items->pluck('json_items')->flatten()->unique()) | ||
->whereNotIn('id', $items->pluck('id')->toArray()) | ||
->get(); | ||
return Inertia::render('Test', [ | ||
'items' => $items, | ||
'python' => $pythonItem, | ||
'nodes' => $nodes, | ||
]); | ||
} | ||
|
||
public function syncSelected(Request $request) | ||
{ | ||
$selected = $request->input('selected'); | ||
// add the selected items to the selected items in this session | ||
$request->session()->put('selected', $selected ?? []); | ||
} | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Oops, something went wrong.