92 lines
2.5 KiB
PHP
92 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\GitRepos\StoreGitRepoRequest;
|
|
use App\Http\Requests\GitRepos\UpdateGitRepoRequest;
|
|
use App\Models\GitRepo;
|
|
|
|
class GitRepoController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$git_repos = GitRepo::all();
|
|
return view('git-repos.index', compact('git_repos'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('git-repos.create');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\GitRepos\StoreGitRepoRequest $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(StoreGitRepoRequest $request)
|
|
{
|
|
$git_repo = new GitRepo();
|
|
$git_repo->fill($request->validated());
|
|
if ($git_repo->saveOrFail()) {
|
|
return redirect()->route('git-repos.edit', compact('git_repo'))
|
|
->with('success', trans('Dépôt Git créé.'));
|
|
}
|
|
|
|
return \back();
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\Models\GitRepo $git_repo
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit(GitRepo $git_repo)
|
|
{
|
|
return view('git-repos.edit', ['git_repo' => $git_repo]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\GitRepos\UpdateGitRepoRequest $request
|
|
* @param \App\Models\GitRepo $git_repo
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(UpdateGitRepoRequest $request, GitRepo $git_repo)
|
|
{
|
|
$git_repo->fill($request->validated());
|
|
if ($git_repo->saveOrFail()) {
|
|
return redirect()->route('git-repos.edit', compact('git_repo'))
|
|
->with('success', trans('Dépôt Git mis à jour.'));
|
|
}
|
|
return \back();
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Models\GitRepo $git_repo
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(GitRepo $git_repo)
|
|
{
|
|
if ($git_repo->deleteOrFail()) {
|
|
return redirect()->route('git-repos.index')
|
|
->with('warning', trans('Dépôt Git supprimé.'));
|
|
}
|
|
return \back();
|
|
}
|
|
}
|