-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new samples to public projects
fixes #1167
- Loading branch information
Showing
7 changed files
with
258 additions
and
11 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
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,28 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Project; | ||
use App\Models\User; | ||
|
||
class UserController extends Controller | ||
{ | ||
/** | ||
* Retrieve the names of public projects owned by the user | ||
*/ | ||
public function retrieveProjects(User $user) | ||
{ | ||
return Project::where('owner_id', $user->id) | ||
->where('is_public', true) | ||
->get(['id', 'name', 'description', 'license_id']) | ||
->map(function ($project) { | ||
return [ | ||
'id' => $project->id, | ||
'name' => $project->name, | ||
'description' => $project->description, | ||
'license_id' => $project->license_id, | ||
]; | ||
}) | ||
->toArray(); | ||
} | ||
} |
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.