Git
13 files changed +223 −10
Review
Insert
app/Http/Controllers/PullRequestController.php (+33 −0) added


  
1
<?php


  
2


      


  
3
namespace App\Http\Controllers;


  
4


      


  
5
use App\Services\RepositoryService;


  
6
use App\Models\PullRequest;


  
7
use App\Helpers\DiffRenderer;


  
8
use App\GithubConfig;


  
9


      


  
10
class PullRequestController extends Controller


  
11
{


  
12
    public function metadata($organizationName, $repositoryName)


  
13
    {


  
14
        [$organization, $repository] = RepositoryService::getRepositoryWithOrganization($organizationName, $repositoryName);


  
15


      


  
16
        $branches = $repository->branches()->get();


  
17
        $branchNames = $branches->pluck('name');


  
18


      


  
19
        $assignees = $repository->contributors()->with('githubUser')->get()->map(function ($contributor) {


  
20
            return $contributor->githubUser;


  
21
        });


  
22


      


  
23
        $master_branch = $repository->master_branch;


  
24
        $default_assignee = GithubConfig::USERID;


  
25


      


  
26
        return response()->json([


  
27
            'branches' => $branchNames,


  
28
            'assignees' => $assignees,


  
29
            'default_assignee' => $default_assignee,


  
30
            'master_branch' => $master_branch,


  
31
        ]);


  
32
    }


  
33
}