Skip to content

Commit 4befe49

Browse files
committed
Added Laravel Sample
1 parent 0b6f67e commit 4befe49

File tree

5,499 files changed

+628023
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,499 files changed

+628023
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Myboard
2+
3+
[![Build Status](https://travis-ci.org/vitorfs/bootcamp.svg?branch=master)](https://travis-ci.org/vitorfs/bootcamp)
4+
5+
Myboard is an open source **to do board** built with [PHP][0] using the [Laravel Web Framework][1].
6+
7+
The project has two basic apps:
8+
9+
* Create todo action items
10+
* Mark Status
11+
12+
## Technology Stack
13+
14+
- PHP 7
15+
- Ubuntu 16.04
16+
- Laravel 5.1
17+
- Twitter Bootstrap 3
18+
- Microsoft PHP SQL Server Driver
19+
- Microsoft ODBC SQL Server Driver
20+
21+
22+
## Installation Guide
23+
24+
### 1 Install Pre-Requisites
25+
26+
* **Composer**
27+
https://getcomposer.org/download/
28+
29+
* **PHP**
30+
http://php.net/releases/7_0_0.php
31+
32+
* **PHP Connector for SQL Server**
33+
https://blogs.msdn.microsoft.com/sqlphp/2016/10/10/getting-started-with-php-7-sql-server-and-azure-sql-database-on-linux-ubuntu-with-apache/
34+
35+
* **Apache**
36+
https://help.ubuntu.com/lts/serverguide/httpd.html
37+
38+
* **Mcrypt and mbstring**
39+
http://php.net/manual/en/mcrypt.setup.php
40+
41+
42+
### 2 Install dependencies
43+
On the project root there is a requirements.pip file. Make sure you install all the required dependencies before running myboard
44+
45+
cd todo
46+
composer install
47+
48+
49+
### 3 Syncdb
50+
51+
Edit your database.php with your database information
52+
53+
'sqlsrv' => [
54+
'driver' => 'sqlsrv',
55+
'host' => 'your_server',
56+
'database' => env('DB_DATABASE', 'your_database'),
57+
'username' => env('DB_USERNAME', 'sa'),
58+
'password' => env('DB_PASSWORD', 'your_password'),
59+
'prefix' => '',
60+
],
61+
62+
Then run the database migration
63+
64+
php artisan migrate
65+
chmod 777 -R storage
66+
67+
### 4 Run
68+
69+
php artisan serve
70+
71+
72+
73+
74+
75+
[0]: http://php.net/
76+
[1]: https://laravel.com/docs/5.1
77+
[2]: https://github.com/meet-bhagdev/todo/wiki
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php namespace App\Console\Commands;
2+
3+
use Illuminate\Console\Command;
4+
use Illuminate\Foundation\Inspiring;
5+
6+
class Inspire extends Command
7+
{
8+
/**
9+
* The name and signature of the console command.
10+
*
11+
* @var string
12+
*/
13+
protected $signature = 'inspire';
14+
15+
/**
16+
* The console command description.
17+
*
18+
* @var string
19+
*/
20+
protected $description = 'Display an inspiring quote';
21+
22+
/**
23+
* Execute the console command.
24+
*
25+
* @return mixed
26+
*/
27+
public function handle()
28+
{
29+
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
30+
}
31+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php namespace App\Console;
2+
3+
use Illuminate\Console\Scheduling\Schedule;
4+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
5+
6+
class Kernel extends ConsoleKernel
7+
{
8+
/**
9+
* The Artisan commands provided by your application.
10+
*
11+
* @var array
12+
*/
13+
protected $commands = [
14+
'App\Console\Commands\Inspire',
15+
];
16+
17+
/**
18+
* Define the application's command schedule.
19+
*
20+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
21+
* @return void
22+
*/
23+
protected function schedule(Schedule $schedule)
24+
{
25+
$schedule->command('inspire')
26+
->hourly();
27+
}
28+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php namespace App\Events;
2+
3+
abstract class Event
4+
{
5+
//
6+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php namespace App\Exceptions;
2+
3+
use Exception;
4+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
5+
6+
class Handler extends ExceptionHandler
7+
{
8+
/**
9+
* A list of the exception types that should not be reported.
10+
*
11+
* @var array
12+
*/
13+
protected $dontReport = [
14+
'Symfony\Component\HttpKernel\Exception\HttpException'
15+
];
16+
17+
/**
18+
* Report or log an exception.
19+
*
20+
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
21+
*
22+
* @param \Exception $e
23+
* @return void
24+
*/
25+
public function report(Exception $e)
26+
{
27+
return parent::report($e);
28+
}
29+
30+
/**
31+
* Render an exception into an HTTP response.
32+
*
33+
* @param \Illuminate\Http\Request $request
34+
* @param \Exception $e
35+
* @return \Illuminate\Http\Response
36+
*/
37+
public function render($request, Exception $e)
38+
{
39+
return parent::render($request, $e);
40+
}
41+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Http\Requests\LoginRequest;
6+
use Illuminate\Support\Facades\Auth;
7+
8+
class AuthController extends Controller
9+
{
10+
/**
11+
* View Home Page.
12+
*
13+
* @return \Illuminate\View\View
14+
*/
15+
public function home()
16+
{
17+
return view('home');
18+
}
19+
20+
/**
21+
* Show Login Form.
22+
*
23+
* @return \Illuminate\View\View
24+
*/
25+
public function getLogin()
26+
{
27+
return view('auth.login');
28+
}
29+
30+
/**
31+
* Do Login.
32+
*
33+
* @param LoginRequest $request
34+
*
35+
* @return \Illuminate\Http\RedirectResponse
36+
*/
37+
public function postLogin(LoginRequest $request)
38+
{
39+
if (Auth::attempt([
40+
'email' => $request->get('email'),
41+
'password' => $request->get('password'),
42+
], $request->get('remember'))) {
43+
return redirect()
44+
->intended('/todo')
45+
->with('flash_notification.message', 'Logged in successfully')
46+
->with('flash_notification.level', 'success');
47+
}
48+
49+
return redirect()
50+
->back()
51+
->withInput()
52+
->with('flash_notification.message', 'Wrong email or password')
53+
->with('flash_notification.level', 'danger');
54+
}
55+
56+
/**
57+
* Logout.
58+
*
59+
* @return \Illuminate\Http\RedirectResponse
60+
*/
61+
public function logout()
62+
{
63+
Auth::logout();
64+
65+
return redirect('/')
66+
->with('flash_notification.message', 'Logged out successfully')
67+
->with('flash_notification.level', 'success');
68+
}
69+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Foundation\Bus\DispatchesJobs;
6+
use Illuminate\Routing\Controller as BaseController;
7+
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
9+
abstract class Controller extends BaseController
10+
{
11+
use DispatchesJobs, ValidatesRequests;
12+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Todo;
6+
use Illuminate\Http\Request;
7+
use Illuminate\Support\Facades\Auth;
8+
9+
class TodoController extends Controller
10+
{
11+
/**
12+
* View ToDos listing.
13+
*
14+
* @return \Illuminate\View\View
15+
*/
16+
public function index()
17+
{
18+
$todoList = Todo::where('user_id', Auth::id())->paginate(7);
19+
20+
return view('todo.list', compact('todoList'));
21+
}
22+
23+
/**
24+
* View Create Form.
25+
*
26+
* @return \Illuminate\View\View
27+
*/
28+
public function create()
29+
{
30+
return view('todo.create');
31+
}
32+
33+
/**
34+
* Create new Todo.
35+
*
36+
* @param Request $request
37+
*
38+
* @return \Illuminate\Http\RedirectResponse
39+
*/
40+
public function store(Request $request)
41+
{
42+
$this->validate($request, ['name' => 'required']);
43+
44+
Todo::create([
45+
'name' => $request->get('name'),
46+
'user_id' => Auth::user()->id,
47+
]);
48+
49+
return redirect('/todo')
50+
->with('flash_notification.message', 'New todo created successfully')
51+
->with('flash_notification.level', 'success');
52+
}
53+
54+
/**
55+
* Toggle Status.
56+
*
57+
* @param $id
58+
*
59+
* @return \Illuminate\Http\RedirectResponse
60+
*/
61+
public function update($id)
62+
{
63+
$todo = Todo::findOrFail($id);
64+
$todo->complete = !$todo->complete;
65+
$todo->save();
66+
67+
return redirect()
68+
->route('todo.index')
69+
->with('flash_notification.message', 'Todo updated successfully')
70+
->with('flash_notification.level', 'success');
71+
}
72+
73+
/**
74+
* Delete Todo.
75+
*
76+
* @param $id
77+
*
78+
* @return \Illuminate\Http\RedirectResponse
79+
*/
80+
public function destroy($id)
81+
{
82+
$todo = Todo::findOrFail($id);
83+
$todo->delete();
84+
85+
return redirect()
86+
->route('todo.index')
87+
->with('flash_notification.message', 'Todo deleted successfully')
88+
->with('flash_notification.level', 'success');
89+
}
90+
}

0 commit comments

Comments
 (0)