-
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
db7e4c9
commit bb2b404
Showing
462 changed files
with
401,690 additions
and
19 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,34 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use App\Models\User; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Laravel\Fortify\Contracts\CreatesNewUsers; | ||
|
||
class CreateNewUser implements CreatesNewUsers | ||
{ | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and create a newly registered user. | ||
* | ||
* @param array $input | ||
* @return \App\Models\User | ||
*/ | ||
public function create(array $input) | ||
{ | ||
Validator::make($input, [ | ||
'name' => ['required', 'string', 'max:255'], | ||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | ||
'password' => $this->passwordRules(), | ||
])->validate(); | ||
|
||
return User::create([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
'password' => Hash::make($input['password']), | ||
]); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use Laravel\Fortify\Rules\Password; | ||
|
||
trait PasswordValidationRules | ||
{ | ||
/** | ||
* Get the validation rules used to validate passwords. | ||
* | ||
* @return array | ||
*/ | ||
protected function passwordRules() | ||
{ | ||
return ['required', 'string', new Password, 'confirmed']; | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Laravel\Fortify\Contracts\ResetsUserPasswords; | ||
|
||
class ResetUserPassword implements ResetsUserPasswords | ||
{ | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and reset the user's forgotten password. | ||
* | ||
* @param mixed $user | ||
* @param array $input | ||
* @return void | ||
*/ | ||
public function reset($user, array $input) | ||
{ | ||
Validator::make($input, [ | ||
'password' => $this->passwordRules(), | ||
])->validate(); | ||
|
||
$user->forceFill([ | ||
'password' => Hash::make($input['password']), | ||
])->save(); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Laravel\Fortify\Contracts\UpdatesUserPasswords; | ||
|
||
class UpdateUserPassword implements UpdatesUserPasswords | ||
{ | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and update the user's password. | ||
* | ||
* @param mixed $user | ||
* @param array $input | ||
* @return void | ||
*/ | ||
public function update($user, array $input) | ||
{ | ||
Validator::make($input, [ | ||
'current_password' => ['required', 'string'], | ||
'password' => $this->passwordRules(), | ||
])->after(function ($validator) use ($user, $input) { | ||
if (! Hash::check($input['current_password'], $user->password)) { | ||
$validator->errors()->add('current_password', __('The provided password does not match your current password.')); | ||
} | ||
})->validateWithBag('updatePassword'); | ||
|
||
$user->forceFill([ | ||
'password' => Hash::make($input['password']), | ||
])->save(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
server/app/Actions/Fortify/UpdateUserProfileInformation.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,59 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use Illuminate\Contracts\Auth\MustVerifyEmail; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\Rule; | ||
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; | ||
|
||
class UpdateUserProfileInformation implements UpdatesUserProfileInformation | ||
{ | ||
/** | ||
* Validate and update the given user's profile information. | ||
* | ||
* @param mixed $user | ||
* @param array $input | ||
* @return void | ||
*/ | ||
public function update($user, array $input) | ||
{ | ||
Validator::make($input, [ | ||
'name' => ['required', 'string', 'max:255'], | ||
'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], | ||
'photo' => ['nullable', 'image', 'max:1024'], | ||
])->validateWithBag('updateProfileInformation'); | ||
|
||
if (isset($input['photo'])) { | ||
$user->updateProfilePhoto($input['photo']); | ||
} | ||
|
||
if ($input['email'] !== $user->email && | ||
$user instanceof MustVerifyEmail) { | ||
$this->updateVerifiedUser($user, $input); | ||
} else { | ||
$user->forceFill([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
])->save(); | ||
} | ||
} | ||
|
||
/** | ||
* Update the given verified user's profile information. | ||
* | ||
* @param mixed $user | ||
* @param array $input | ||
* @return void | ||
*/ | ||
protected function updateVerifiedUser($user, array $input) | ||
{ | ||
$user->forceFill([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
'email_verified_at' => null, | ||
])->save(); | ||
|
||
$user->sendEmailVerificationNotification(); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace App\Actions\Jetstream; | ||
|
||
use Laravel\Jetstream\Contracts\DeletesUsers; | ||
|
||
class DeleteUser implements DeletesUsers | ||
{ | ||
/** | ||
* Delete the given user. | ||
* | ||
* @param mixed $user | ||
* @return void | ||
*/ | ||
public function delete($user) | ||
{ | ||
$user->deleteProfilePhoto(); | ||
$user->tokens->each->delete(); | ||
$user->delete(); | ||
} | ||
} |
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 | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Document; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Http\Request; | ||
|
||
class DocumentController extends Controller | ||
{ | ||
public function listAllDocuments() | ||
{ | ||
// $documents = Auth::user()->document()->orderBy('updated_at', 'DESC')->get(); | ||
|
||
return view("dashboard"); | ||
} | ||
|
||
public function show($documentId) | ||
{ | ||
$document = Document::findOrFail($documentId); | ||
|
||
return view('document.show', ['document' => $document]); | ||
} | ||
|
||
public function createNewDocument() | ||
{ | ||
|
||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire; | ||
|
||
use Livewire\Component; | ||
|
||
class Dashboard extends Component | ||
{ | ||
public $message; | ||
|
||
protected $listeners = ['flashMessage']; | ||
|
||
public function flashMessage($message) | ||
{ | ||
$this->message = $message; | ||
} | ||
|
||
public function mount() | ||
{ | ||
$this->message = ""; | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.dashboard'); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire\Document; | ||
|
||
use Livewire\Component; | ||
use App\Models\Document; | ||
|
||
class Create extends Component | ||
{ | ||
public $isCreating = false; | ||
public $name = ""; | ||
public $message = ""; | ||
|
||
public function confirmCreating() | ||
{ | ||
$this->isCreating = true; | ||
} | ||
|
||
public function createNewDocument() | ||
{ | ||
try { | ||
$document = Document::create([ | ||
'name' => $this->name | ||
]); | ||
|
||
$document->user()->attach(auth()->user()); | ||
} catch (\Exception $e) { | ||
$this->emitTo('dashboard', 'flashMessage', "Oluşturma işlemi başarısız oldu!"); | ||
} | ||
$this->emitTo('dashboard', 'flashMessage', $this->name . " isimli doküman başarıyla eklendi!"); | ||
|
||
$this->emitTo('document.show', 'newDocumentCreated'); | ||
$this->isCreating = false; | ||
$this->name = ""; | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.document.create'); | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire\Document; | ||
|
||
use Livewire\Component; | ||
|
||
class Show extends Component | ||
{ | ||
public $documents; | ||
|
||
protected $listeners = ['newDocumentCreated']; | ||
|
||
public function newDocumentCreated() | ||
{ | ||
$this->documents = auth()->user()->document()->orderBy('updated_at', 'DESC')->get(); | ||
} | ||
|
||
public function mount() | ||
{ | ||
$this->documents = auth()->user()->document()->orderBy('updated_at', 'DESC')->get(); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.document.show'); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class CheckIfUserOwnsDocument | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \Closure $next | ||
* @return mixed | ||
*/ | ||
public function handle(Request $request, Closure $next) | ||
{ | ||
$id = $request->route('documentId'); | ||
if ($id) | ||
{ | ||
if (Auth::user()->document()->find($id) === null) | ||
{ | ||
return redirect(route('dashboard')); | ||
} | ||
} | ||
|
||
return $next($request); | ||
} | ||
} |
Oops, something went wrong.