Skip to content

Commit

Permalink
feat: implementd protected urls & routing redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
stevan06v committed Jan 23, 2024
1 parent 2d25f5f commit 88da702
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 827 deletions.
7 changes: 5 additions & 2 deletions app/Livewire/JoinProjectForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Hash;
use Livewire\Attributes\Rule;
use Livewire\Component;
use Session;

class JoinProjectForm extends Component
{
Expand All @@ -23,12 +24,14 @@ public function save(){
'time' => 2,
'threads' => 2,
]);

Project::create([
$project = Project::create([
"project_url" => $this->projectUrl,
"project_hash" => $projectHash,
"user_id" => Auth::user()->id
]);

Session::put('project',$project);
$this->redirect('/projects');
}else{
$this->redirect('/register');
}
Expand Down
23 changes: 23 additions & 0 deletions app/Livewire/ShowProject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace App\Livewire;

use App\Models\Project;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
use Session;

class ShowProject extends Component
{
public $project;

public function mount(){
$this->project = Session::get("project");
}

public function render()
{
return view('livewire.show-project',[
"name" => $this->project->id
]);
}
}
2 changes: 1 addition & 1 deletion app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @var string
*/
public const HOME = '/dashboard';
public const HOME = '/projects';

/**
* Define your route model bindings, pattern filters, and other route configuration.
Expand Down
3 changes: 3 additions & 0 deletions resources/views/livewire/show-project.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
{{$name}}
</div>
19 changes: 19 additions & 0 deletions resources/views/projects.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.png" type="image/x-icon">

<title>Propromo</title>

@vite(['resources/css/app.css', 'resources/js/app.js'])

</head>
<body>

<h1>Projects</h1>

</body>
</html>
Loading

0 comments on commit 88da702

Please sign in to comment.