-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2abe1c
commit 7a749dc
Showing
11 changed files
with
295 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ yarn-error.log | |
/.fleet | ||
/.idea | ||
/.vscode | ||
|
||
storage/repositories |
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,36 @@ | ||
<?php | ||
|
||
namespace App\Livewire; | ||
|
||
use App\Models\Repository; | ||
use CzProject\GitPhp\Git; | ||
use Illuminate\Support\Facades\Auth; | ||
use Livewire\Attributes\Validate; | ||
use Livewire\Component; | ||
|
||
class CreateRepository extends Component | ||
{ | ||
#[Validate('required')] | ||
public $title = ''; | ||
|
||
public function render() | ||
{ | ||
return view('livewire.create-repository')->extends('layouts.app'); | ||
} | ||
|
||
public function create() | ||
{ | ||
$this->validate(); | ||
|
||
$repository = new Repository(); | ||
$repository->title = $this->title; | ||
$repository->user_id = Auth::id(); | ||
$repository->save(); | ||
|
||
$git = new Git(); | ||
|
||
$git->init(storage_path('repositories/' . $this->title)); | ||
|
||
$this->redirect(route('home'), navigate: true); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace App\Livewire; | ||
|
||
use App\Models\Repository; | ||
use Livewire\Attributes\Computed; | ||
use Livewire\Component; | ||
|
||
class Repositories extends Component | ||
{ | ||
public function render() | ||
{ | ||
return view('livewire.repositories')->extends('layouts.app');; | ||
} | ||
|
||
#[Computed()] | ||
public function repositories() | ||
{ | ||
return Repository::all(); | ||
} | ||
|
||
public function create() | ||
{ | ||
return $this->redirect(route('repositories.create'), navigate: true); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Repository extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'title', | ||
'user_id', | ||
]; | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
database/migrations/2024_01_13_221907_create_repositories_table.php
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,29 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('repositories', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('title'); | ||
$table->foreignId('user_id')->constrained(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('repositories'); | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
@extends('layouts.base') | ||
|
||
@section('body') | ||
@yield('content') | ||
|
||
@isset($slot) | ||
{{ $slot }} | ||
@endisset | ||
<div class="flex flex-col min-h-screen py-12 bg-gray-100 sm:px-6 lg:px-8"> | ||
@yield('content') | ||
|
||
@isset($slot) | ||
{{ $slot }} | ||
@endisset | ||
</div> | ||
@endsection |
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,23 @@ | ||
<div class="bg-white w-full p-5"> | ||
<form wire:submit='create'> | ||
<h1 class="mb-2">Criar novo repositório</h1> | ||
<div class="mb-2"> | ||
<label for="title" class="block text-sm font-medium text-gray-700 leading-5"> | ||
Titulo do repositório | ||
</label> | ||
|
||
<div class="mt-1 rounded-md shadow-sm"> | ||
<input wire:model="title" id="title" name="title" type="text" required autofocus class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md placeholder-gray-400 focus:outline-none focus:ring-blue focus:border-blue-300 transition duration-150 ease-in-out sm:text-sm sm:leading-5 @error('email') border-red-300 text-red-900 placeholder-red-300 focus:border-red-300 focus:ring-red @enderror" /> | ||
</div> | ||
|
||
@error('title') | ||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p> | ||
@enderror | ||
</div> | ||
<div class="flex justify-end"> | ||
<button type="submit" class="flex justify-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 border border-transparent rounded-md hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:ring-indigo active:bg-indigo-700 transition duration-150 ease-in-out"> | ||
Criar | ||
</button> | ||
</div> | ||
</form> | ||
</div> |
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,15 @@ | ||
<div class="bg-white w-full p-5"> | ||
<div class="flex justify-between items-center mb-5"> | ||
<h1>Repositorios</h1> | ||
<button wire:click='create' type="button" class="flex justify-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 border border-transparent rounded-md hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:ring-indigo active:bg-indigo-700 transition duration-150 ease-in-out"> | ||
Criar novo repositorio | ||
</button> | ||
</div> | ||
@foreach ($this->repositories as $repository) | ||
<div class="flex justify-between bg-gray-100 mb-3 p-3"> | ||
<span> | ||
{{ $repository->title }} | ||
</span> | ||
</div> | ||
@endforeach | ||
</div> |
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