Skip to content

Riffca case #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
94b344d
copy lavavel files to project
riffca Sep 22, 2016
0ca68f9
add webpack config, frontend folder, home html page with main.js src
riffca Sep 23, 2016
fe624c7
let laravel send one index page for any request
riffca Sep 23, 2016
3c7d18f
make webpack work together with php through browser-sync
riffca Sep 23, 2016
ad822b9
make structure of client
riffca Sep 23, 2016
08e2691
fix issues to start work on client project
riffca Sep 23, 2016
74cdf88
add simple logo
riffca Sep 23, 2016
eb79e1c
install JWTAuth
riffca Sep 23, 2016
606f844
add migrations
riffca Sep 24, 2016
c970663
add message model
riffca Sep 24, 2016
cf0f26a
simple structure of api routes
riffca Sep 24, 2016
23af2a6
add simple create user and message routes functionality
riffca Sep 24, 2016
9915641
update routes logic
riffca Sep 24, 2016
92f9752
add get jwt token to login-user api
riffca Sep 24, 2016
b946b2e
add jwt middleware
riffca Sep 24, 2016
a9e5f63
add get-user route
riffca Sep 24, 2016
ba55d6a
write sign up page functionality
riffca Sep 24, 2016
a18308c
fix interceptors
riffca Sep 24, 2016
9ffc61b
fix interceptors
riffca Sep 24, 2016
4133870
check authorisation precess
riffca Sep 24, 2016
02121af
add write and show message functionality to home page
riffca Sep 24, 2016
91f2d31
adding auth logic for show elements
riffca Sep 24, 2016
7968247
adding pagination
riffca Sep 24, 2016
aece7da
orderBy desc messages and fix send message method
riffca Sep 24, 2016
15e9e4b
add navigation
riffca Sep 24, 2016
44365db
add pagination
riffca Sep 24, 2016
94f7d77
add orderBy desc to messages
riffca Sep 24, 2016
df38b47
add message component
riffca Sep 24, 2016
cc926e1
add link to profile page
riffca Sep 24, 2016
a7234a6
make profile component logic
riffca Sep 24, 2016
79ffda6
add profile api
riffca Sep 24, 2016
9406f88
add non message
riffca Sep 24, 2016
a03371a
add style to auth adn some alert errors
riffca Sep 24, 2016
b1c8391
fix auth style and redirect if not auth
riffca Sep 24, 2016
4ea1cf8
add exp to jwttoken
riffca Sep 24, 2016
52d12a2
replace tags
riffca Sep 24, 2016
6eb7a62
add paginate count
riffca Sep 24, 2016
e4ada2b
update send-box style
riffca Sep 24, 2016
6c2196f
readME
riffca Sep 24, 2016
ae983a0
adding cors
riffca Sep 25, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
APP_ENV=local
APP_KEY=base64:uvsRvE4BidzVDb/8D9nuAMeFl18iMwCZlA2KZ2cvFZs=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=guest-case
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
32 changes: 32 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/public/storage
/vendor
/.idea
Homestead.json
Homestead.yaml
48 changes: 18 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
Тестовое задание на позицию PHP developer
=============


Реализовать приложение **гостевая книга**.
1. Отображение списка сообщений на странице
2. Форма добавления нового сообщения
* Поля для заполнения
1. User Name (цифры и буквы латинского алфавита) – обязательное поле
2. E-mail (формат email) – не обязательное поле
3. Text (непосредственно сам текст сообщения, HTML тэги недопустимы) – обязательное поле
3. Клик на User Name сообщения выводит список сообщений данного пользователя.

##Требования
1. Фреймворк Laravel 5 или Laravel 4 (на самом деле любой современный фреймворк подойдет, но Laravel предпочтительнее)
2. Логика должна быть разбита на Backend и Frontend.
3. Backend используется в качестве Api
4. Frontend на любом современном JS фреймворке (Angular, React, Vue и тп.)
5. Валидация формы с выводом ошибок.
6. Использование миграций

##Не обязательно но будет плюсом
1. PHPUnit тесты для Backend
2. Авторизация и регистрация
3. Личный кабинет после авторизации в котором выводятся сообщения пользователя.
4. Сообщения должны разбиваться на страницы с выбором колличества сообщений на каждой (5 на странице или 10 на странице)

##Ответ
Коммиты стараться делать логически осмысленными, разбивая функционал на части. Сообщения коммита должны описывать что было сделано.
Ответ нужно прислать через pull request в данный репозиторий.
# Start

`configure virtualhost`
`configure database`
`composer install`

# Develop client

`npm install`
`npm start`

# About

`[email protected]`
`Станислав Дворецкий`



40 changes: 40 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}
65 changes: 65 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
];

/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}

/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}

return redirect()->guest('login');
}
}
32 changes: 32 additions & 0 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
39 changes: 39 additions & 0 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/

use AuthenticatesUsers;

/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
}
71 changes: 71 additions & 0 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace App\Http\Controllers\Auth;

use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/

use RegistersUsers;

/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}

/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
Loading