Permalink
Browse files

http://www.laragle.com/2017/04/twitter-from-scratch-using-laravel-cre…

  • Loading branch information...
darwinluague committed Apr 12, 2017
1 parent 958d376 commit f1370761201e401b263477557407c630dfe5f4a5
@@ -0,0 +1,29 @@
APP_ENV=local
APP_KEY=base64:DTwc9SRXxHeiDcWo+nEwIDr4bGhtV4wrod/cUc7Qk/M=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://twitter.dev

DB_CONNECTION=sqlite

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=log
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=no-reply@twitter.dev
MAIL_FROM_NAME=Twitter

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
@@ -25,7 +25,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/';
/**
* Create a new controller instance.
@@ -27,7 +27,7 @@ class RegisterController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/';
/**
* Create a new controller instance.
@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use App\User;
use Illuminate\Support\Facades\View;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
@@ -10,4 +12,19 @@
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
/**
* Create a new controller instance.
*/
public function __construct()
{
$this->middleware(function ($request, $next) {
$user = auth()->user();
View::share('loggedIn', $user ? true : false);
View::share('loggedUser', $user ?? new User);
return $next($request);
});
}
}
@@ -6,23 +6,18 @@
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function index()
public function index(Request $request)
{
if (is_null($request->user())) {
return view('welcome');
}
return view('home');
}
}
@@ -2,6 +2,7 @@
namespace App\Providers;
use Laravel\Dusk\DuskServiceProvider;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
@@ -23,6 +24,8 @@ public function boot()
*/
public function register()
{
//
if ($this->app->environment('local', 'testing')) {
$this->app->register(DuskServiceProvider::class);
}
}
}
@@ -7,6 +7,7 @@
"require": {
"php": ">=5.6.4",
"cviebrock/eloquent-sluggable": "^4.2",
"laravel/dusk": "^1.0",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0"
},

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -35,7 +35,7 @@
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'database' => database_path('database.sqlite'),
'prefix' => '',
],
@@ -5,10 +5,17 @@
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Dashboard</div>

<div class="panel-body">
You are logged in!
<form action="{{ route('tweet.store', ['username' => $loggedUser->username]) }}" method="POST">
{{ csrf_field() }}

<div class="form-group">
<textarea name="body" class="form-control" rows="3"></textarea>
</div>
<div class="text-right">
<button type="submit" class="btn btn-primary">Tweet</button>
</div>
</form>
</div>
</div>
</div>
@@ -11,14 +11,10 @@
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/', 'HomeController@index');
Auth::routes();
Route::get('/home', 'HomeController@index');
Route::group(['prefix' => 'account', 'namespace' => 'Account', 'as' => 'account.'], function () {
Route::group(['prefix' => 'verify', 'namespace' => 'Verification', 'as' => 'verify.'], function () {
Route::get('email/{token}', 'EmailController@verify')->name('email');
@@ -0,0 +1,23 @@
<?php
namespace Tests\Browser;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ExampleTest extends DuskTestCase
{
/**
* A basic browser test example.
*
* @return void
*/
public function testBasicExample()
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->assertSee('Laravel');
});
}
}
@@ -0,0 +1,40 @@
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class HomePage extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/';
}
/**
* Assert that the browser is on the page.
*
* @return void
*/
public function assert(Browser $browser)
{
//
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
Oops, something went wrong.

0 comments on commit f137076

Please sign in to comment.