Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api import Items #1423

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ public static function getApp($appid)
return $app;
}


/**
* @param $appName
* @return mixed|null
* @throws GuzzleException
*/
public static function findApp($appName)
{
return self::where('name', $appName)->first()->appid;
}

/**
* @param $appid
* @return mixed|null
Expand Down
15 changes: 14 additions & 1 deletion app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ public function edit(int $id): View
*/
public static function storelogic(Request $request, $id = null): Item
{
if ($request->input('optimistic')) {
$request->merge(['app' => Application::findApp($request->input('title'))]);
$request->merge((array)json_decode(ItemController::appload($request)));

# FIXME: I need to fix some param naming here to make it work
$request->merge([
/* 'pinned' => 1,*/
/* 'tags' => [0],*/
'icon' => $request->input('iconview'),
'appdescription' => $request->input('description'),
]);
}

$application = Application::single($request->input('appid'));
$validatedData = $request->validate([
'title' => 'required|max:255',
Expand Down Expand Up @@ -366,7 +379,7 @@ public function restore(int $id): RedirectResponse
*
* @throws GuzzleException
*/
public function appload(Request $request): ?string
public static function appload(Request $request): ?string
{
$output = [];
$appid = $request->input('app');
Expand Down
1 change: 1 addition & 0 deletions app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class VerifyCsrfToken extends Middleware
'order',
'appload',
'test_config',
'api/*',
//'get_stats'
];
}
Loading