Skip to content

Commit

Permalink
flash message step1
Browse files Browse the repository at this point in the history
  • Loading branch information
Halim authored and Halim committed Nov 8, 2016
1 parent 9d39cdb commit c884fd3
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 89 deletions.
16 changes: 16 additions & 0 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,23 @@ public function update() {
} else {
$user->update(Request::all());
//return Redirect::to('users');

//Session::flash('flash_message', 'Your profile has been updated!');
//Session::flash('flash_message_important', true);

//return redirect('profile');

/*
return redirect('profile')->with([
'flash_message' => 'Your profile has been updated!',
'flash_message_important' => true
]);
*/

flash('Your profile has been updated!')->important();

return redirect('profile');

}
}

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"laravelcollective/html": "5.3.*"
"laravelcollective/html": "5.3.*",
"laracasts/flash": "^2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
47 changes: 45 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,

Laracasts\Flash\FlashServiceProvider::class,

],

Expand Down
104 changes: 18 additions & 86 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,105 +14,37 @@
<link href="/css/app.css" rel="stylesheet">

<!-- Scripts -->
<script>
window.Laravel = <?php
echo json_encode([
'csrfToken' => csrf_token(),
]);
?>
<script>window.Laravel = <?php echo json_encode(['csrfToken' => csrf_token(),]); ?>
</script>
</head>
<body>
<div id="app">
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">

<!-- Collapsed Hamburger -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<!-- Branding Image -->
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
</a>

</div>


<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav">
&nbsp;
<li><a href="{{ url('/home') }}">Dashboard</a></li>

@if (!Auth::guest())
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Articles <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{{ url('articles/create') }}">New Article</a></li>
<li><a href="{{ url('articles') }}">Articles List</a></li>
<li class="divider"></li>
<li><a href="{{ url('articles2') }}">Articles List (Datatables)</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Settings <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{{ url('users') }}">Manage Users</a></li>
<li class="divider"></li>
<li><a href="{{ url('settings') }}">Other Settings</a></li>
</ul>
</li>
@endif
@include('layouts.navbar')

<li><a href="{{ url('/about') }}">About</a></li>
</ul>

<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
@if (Auth::guest())
<li><a href="{{ url('/login') }}">Login</a></li>
<li><a href="{{ url('/register') }}">Register</a></li>
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{{ Auth::user()->username }} <span class="caret"></span>
</a>

<ul class="dropdown-menu" role="menu">
<li><a href="{{ url('/profile') }}">Edit Profile</a></li>
<li><a href="{{ url('/password') }}">Change password</a></li>
<li class="divider"></li>
<li>
<a href="{{ url('/logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>

<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
</li>
@endif
</ul>
<div class="container">
<div class="col-md-10 col-md-offset-1">
@if(Session::has('flash_message'))
<div class="alert alert-success {{ Session::has('flash_message_important') ? 'alert-important': '' }}">
@if(Session::has('flash_message_important'))
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
@endif
{{ Session::get('flash_message') }}
</div>
@endif
</div>
</nav>
</div>

@yield('content')

</div>

<!-- Scripts -->
<script src="/js/app.js"></script>

<script>
$('div.alert').not('.alert-important').delay(1500).slideUp(300);
</script>

</body>
</html>
83 changes: 83 additions & 0 deletions resources/views/layouts/navbar.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">

<!-- Collapsed Hamburger -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<!-- Branding Image -->
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
</a>

</div>


<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav">
&nbsp;
<li><a href="{{ url('/home') }}">Dashboard</a></li>

@if (!Auth::guest())
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Articles <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{{ url('articles/create') }}">New Article</a></li>
<li><a href="{{ url('articles') }}">Articles List</a></li>
<li class="divider"></li>
<li><a href="{{ url('articles2') }}">Articles List (Datatables)</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Settings <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{{ url('users') }}">Manage Users</a></li>
<li class="divider"></li>
<li><a href="{{ url('settings') }}">Other Settings</a></li>
</ul>
</li>
@endif

<li><a href="{{ url('/about') }}">About</a></li>
</ul>

<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
@if (Auth::guest())
<li><a href="{{ url('/login') }}">Login</a></li>
<li><a href="{{ url('/register') }}">Register</a></li>
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{{ Auth::user()->username }} <span class="caret"></span>
</a>

<ul class="dropdown-menu" role="menu">
<li><a href="{{ url('/profile') }}">Edit Profile</a></li>
<li><a href="{{ url('/password') }}">Change password</a></li>
<li class="divider"></li>
<li>
<a href="{{ url('/logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>

<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
</li>
@endif
</ul>
</div>
</div>
</nav>
11 changes: 11 additions & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\AboutController' => $baseDir . '/app/Http/Controllers/AboutController.php',
'App\\Http\\Controllers\\Articles2Controller' => $baseDir . '/app/Http/Controllers/Articles2Controller.php',
'App\\Http\\Controllers\\ArticlesController' => $baseDir . '/app/Http/Controllers/ArticlesController.php',
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php',
'App\\Http\\Controllers\\Auth\\RegisterController' => $baseDir . '/app/Http/Controllers/Auth/RegisterController.php',
'App\\Http\\Controllers\\Auth\\ResetPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ResetPasswordController.php',
'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\HomeController' => $baseDir . '/app/Http/Controllers/HomeController.php',
'App\\Http\\Controllers\\ProfileController' => $baseDir . '/app/Http/Controllers/ProfileController.php',
'App\\Http\\Controllers\\SettingsController' => $baseDir . '/app/Http/Controllers/SettingsController.php',
'App\\Http\\Controllers\\UsersController' => $baseDir . '/app/Http/Controllers/UsersController.php',
'App\\Http\\Kernel' => $baseDir . '/app/Http/Kernel.php',
'App\\Http\\Middleware\\EncryptCookies' => $baseDir . '/app/Http/Middleware/EncryptCookies.php',
'App\\Http\\Middleware\\RedirectIfAuthenticated' => $baseDir . '/app/Http/Middleware/RedirectIfAuthenticated.php',
'App\\Http\\Middleware\\VerifyCsrfToken' => $baseDir . '/app/Http/Middleware/VerifyCsrfToken.php',
'App\\Http\\Requests\\ArticleRequest' => $baseDir . '/app/Http/Requests/ArticleRequest.php',
'App\\Http\\Requests\\UsersRequest' => $baseDir . '/app/Http/Requests/UsersRequest.php',
'App\\Providers\\AppServiceProvider' => $baseDir . '/app/Providers/AppServiceProvider.php',
'App\\Providers\\AuthServiceProvider' => $baseDir . '/app/Providers/AuthServiceProvider.php',
'App\\Providers\\BroadcastServiceProvider' => $baseDir . '/app/Providers/BroadcastServiceProvider.php',
Expand Down Expand Up @@ -1183,6 +1189,11 @@
'JakubOnderka\\PhpConsoleColor\\ConsoleColor' => $vendorDir . '/jakub-onderka/php-console-color/src/JakubOnderka/PhpConsoleColor/ConsoleColor.php',
'JakubOnderka\\PhpConsoleColor\\InvalidStyleException' => $vendorDir . '/jakub-onderka/php-console-color/src/JakubOnderka/PhpConsoleColor/InvalidStyleException.php',
'JakubOnderka\\PhpConsoleHighlighter\\Highlighter' => $vendorDir . '/jakub-onderka/php-console-highlighter/src/JakubOnderka/PhpConsoleHighlighter/Highlighter.php',
'Laracasts\\Flash\\Flash' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/Flash.php',
'Laracasts\\Flash\\FlashNotifier' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/FlashNotifier.php',
'Laracasts\\Flash\\FlashServiceProvider' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/FlashServiceProvider.php',
'Laracasts\\Flash\\LaravelSessionStore' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/LaravelSessionStore.php',
'Laracasts\\Flash\\SessionStore' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/SessionStore.php',
'League\\Flysystem\\AdapterInterface' => $vendorDir . '/league/flysystem/src/AdapterInterface.php',
'League\\Flysystem\\Adapter\\AbstractAdapter' => $vendorDir . '/league/flysystem/src/Adapter/AbstractAdapter.php',
'League\\Flysystem\\Adapter\\AbstractFtpAdapter' => $vendorDir . '/league/flysystem/src/Adapter/AbstractFtpAdapter.php',
Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
'f18cc91337d49233e5754e93f3ed9ec3' => $vendorDir . '/laravelcollective/html/src/helpers.php',
'e23faeee409e941dc9b4c80386209c39' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/functions.php',
);
1 change: 1 addition & 0 deletions vendor/composer/autoload_namespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
return array(
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
'Mockery' => array($vendorDir . '/mockery/mockery/library'),
'Laracasts\\Flash' => array($vendorDir . '/laracasts/flash/src'),
'JakubOnderka\\PhpConsoleHighlighter' => array($vendorDir . '/jakub-onderka/php-console-highlighter/src'),
'JakubOnderka\\PhpConsoleColor' => array($vendorDir . '/jakub-onderka/php-console-color/src'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
Expand Down
Loading

0 comments on commit c884fd3

Please sign in to comment.