Skip to content

Commit

Permalink
return to array instead object
Browse files Browse the repository at this point in the history
  • Loading branch information
martiendt committed May 17, 2020
1 parent 5e7b25d commit 0c69f8a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/Api/AuthUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ public function show(Request $request)
if ($request->has('plugin_id')) {
$userData['data'] = array_add($userData['data'], 'projects', Project::from('projects as project')
->join('project_user as project_user', 'project.id', '=', 'project_user.project_id')
->join('plugin_project as plugin_project', 'project.id', '=', 'plugin_project.plugin_id')
->join('plugin_project as plugin_project', 'project.id', '=', 'plugin_project.project_id')
->where('project_user.user_id', $user->id)
->where('plugin_project.plugin_id', $request->get('plugin_id'))
->select('project.*')
->get());
->get()
->toArray());
}

if ($request->get('tenant_code')) {
Expand Down
14 changes: 14 additions & 0 deletions database/seeds/PluginSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function run()
private function create($plugins)
{
foreach ($plugins as $array) {
if (!$this->isExists($array['name'])) {
continue;
}

$plugin = new Plugin;
$plugin->name = $array['name'];
$plugin->description = $array['description'];
Expand All @@ -75,4 +79,14 @@ private function create($plugins)
$plugin->save();
}
}

private function isExists($name)
{
$plugin = Plugin::where('name', $name)->first();
if ($plugin) {
return false;
}

return true;
}
}

0 comments on commit 0c69f8a

Please sign in to comment.