Browse Source

🚧 Ajoute les nouvelles pages

master
Shikiryu 4 years ago
parent
commit
8c48c8daa3
  1. 10
      app/Http/Controllers/Controller.php
  2. 18
      app/Http/Controllers/ExampleController.php
  3. 41
      app/Http/Controllers/HomeController.php
  4. 10
      resources/views/home.blade.php
  5. 113
      resources/views/layouts/app.blade.php
  6. 10
      resources/views/registered.blade.php
  7. 6
      resources/views/registration.blade.php
  8. 4
      routes/web.php

10
app/Http/Controllers/Controller.php

@ -1,10 +0,0 @@
<?php
namespace App\Http\Controllers;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
//
}

18
app/Http/Controllers/ExampleController.php

@ -1,18 +0,0 @@
<?php
namespace App\Http\Controllers;
class ExampleController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
}
//
}

41
app/Http/Controllers/HomeController.php

@ -3,12 +3,49 @@
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Laravel\Lumen\Routing\Controller as BaseController;
class HomeController extends Controller
class HomeController extends BaseController
{
public function home(Request $request)
{
return view('home');
}
}
public function iframe(Request $request)
{
$user = null;
try {
$errors = [];
$data = $this->validate($request, [
'email' => 'required|email|unique:users'
]);
$token = bin2hex(random_bytes(72));
$user = new User(['email' => $data['email']]);
$user->token = $token;
$user->save();
return view('registered', [
'user' => $user,
]);
} catch (ValidationException $e) {
$errors = $e->errors();
$data = [];
} catch (\Exception $e) {
$errors = ['email' => 'Impossible de générer le token'];
$data = [];
}
return view('registration', [
'data' => $data,
'errors' => $errors
]);
}
}

10
resources/views/home.blade.php

@ -1,13 +1,5 @@
@extends('layouts.app')
@section('title', 'Page Title')
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@endsection
@section('content')
<p>This is my body content.</p>
@include('registration')
@endsection

113
resources/views/layouts/app.blade.php

File diff suppressed because one or more lines are too long

10
resources/views/registered.blade.php

File diff suppressed because one or more lines are too long

6
resources/views/registration.blade.php

@ -0,0 +1,6 @@
<form name="bookmarkletGenerator" action="<?php echo url('/register'); ?>" method="POST">
<input type="email" name="email" id="email" value="<?php echo $data['email'] ?? ''; ?>" placeholder="email@example.com" />
<?php echo isset($errors) && array_key_exists('email', $errors) ? implode(' | ', $errors['email']) : ''; ?>
<input type="checkbox" id="html" value="on" name="html" /><label for="html">Clip web page (experimental)</label>
<input type="submit" value="Generate!" id="submit"/>
</form>

4
routes/web.php

@ -10,9 +10,11 @@
| and give it the Closure to call when that URI is requested.
|
*/
/** @var \Laravel\Lumen\Routing\Router $router */
$router->get('/', 'HomeController@home');
$router->post('/register', 'HomeController@iframe');
$router->post('/api/{token}', function($token) {
});
Loading…
Cancel
Save