Implementation of the project 


Мы поможем в написании ваших работ!



ЗНАЕТЕ ЛИ ВЫ?

Implementation of the project



As a result, the system contains 9 controllers:

IndexController:

Responsible for displaying the home page. It caused virtually all database tables in one function, and all data are transmitted to the “dashboard” model.

<? php

 

namespace App\Http\Controllers;

 

use App\Blackboard;

use App\Chat;

use Illuminate\Http\Request;

use App\Http\Requests;

use App\User;

use App\Project;

use App\Task;

use App\Client;

use Illuminate\Support\Facades\Auth;

 

class IndexController extends Controller

{

public function index ()

{

$managers = User :: where ( 'position', 'Content manager' )-> lists ( 'name', 'id' );

$designers = User :: where ( 'position', 'Designer' )-> lists ( 'name', 'id' );

$programmers = User :: where ( 'position', 'Web developer' )-> lists ( 'name', 'id' );

$projects = Project :: lists ( 'title', 'id' );

$projects -> prepend ( 'No project', '0' );

$bbitems = Blackboard :: where ( 'onboard', '1' )-> get ();

$tasks = Task :: where ([ 'completed' => 0, 'user_id' => Auth :: user ()-> id ])-> get ();

$client_lists = Client :: lists ( 'title', 'id' );

$chats = Chat :: orderBy ( 'created_at', 'desc' )-> take ( 50 )-> get ();

 

return view ( 'dashboard' )

->with( 'projects', $projects )

->with( 'managers', $managers )

->with( 'designers', $designers )

->with( 'programmers', $programmers )

->with( 'bbitems', $bbitems )

->with( 'tasks', $tasks )

->with( 'client_lists', $client_lists )

->with( 'chats', $chats );

}

}

 

4.1 Code syntax. Index Conroller.

 

 

BlackboardController:

Implements “Dashboard Manager” module. All the functionality is written here. It has methods such as: index, store, update, edit.

ChatController:

Implements “Chat” module. Shows on page only last 50 records. It has only 2 methods: index, store.

ProjectsController:

Implements “Projects” module. It has all RESTfull API methods: index, create, store, edit, update, destroy and show.

ProjectsсommentController:

Auxiliary Controller for ProjectConrtoller. Can create comments for specific project.

ClientsController:

Implements “Clients” module. It has all RESTfull API methods: index, create, store, edit, update, destroy and show.

TasksController:

Implements “Tasks manager. It has all RESTfull API methods: index, create, store, edit, update, destroy. Also has addintional method for creating subtask.

UsersController:

Has functions like show, create, update.

AuthController:

This controller is activated when the user entered is not authorized in the system. She throws a user to the login page.

 

 


<? php

 

class AuthController extends Controller {

 

use AuthenticatesAndRegistersUsers, ThrottlesLogins;

 

protected $redirectTo = '/';

 

public function __construct ()

{

$this -> middleware ( $this -> guestMiddleware (), [ 'except' => 'logout' ]);

}

 

 

public function getLogin ()

{

return view ( 'templates.login' );

}

 

 

public function postLogin ( Request $request )

{

$v = \Validator :: make ( $request ->all(), [

'email' => 'required|exists:users',

'password' => 'required'

]);

 

if ( $v -> fails ())

{

return redirect ()-> back ()-> withErrors ( $v -> errors ());

}

 

$credentials = [

'email' => $request [ 'email' ],

'password' => $request [ 'password' ],

'confirmed' => 1,

];

 

if ( Auth :: attempt ( $credentials ))

{

return redirect ()-> intended ( '/' )-> withInfo ( 'Welcome back!' );

}

else{

return redirect ()-> to ( '/auth' )-> withInput ()-> withError ( 'We were unable to sign you in.' );

}

 

if ( Auth :: viaRemember ()) {

return redirect ()-> intended ( '/' )-> withInfo ( 'Welcome back!' );

}

 

}

 

public function logout ()

{

Auth :: logout ();

 

4.2 Code syntax. Auth Conroller.

 

A very important role has the routes.php. Virtually the entire system works through this file. It determines which pages the user can enter, binds the correct page specific controller or just some sort of response to the user. We can say that here is written all pages.

<? php

Route :: get ( '/auth', [

'as' => 'auth.login',

'uses' => 'Auth\AuthController@getLogin',

]);

Route :: post ( '/auth/postlogin', [

'as' => 'auth.postlogin',

'uses' => 'Auth\AuthController@postLogin'

]);

Route :: get ( '/auth/logout', [

'as' => 'auth.logout',

'uses' => 'Auth\AuthController@logout'

]);

 

Route :: get ( 'register/verify/{confirmationCode}', [

'as' => 'confirmation_path',

'uses' => 'UsersController@confirm'

]);

 

Route :: group ([ 'middleware' => [ 'auth' ]], function () {

Route :: get ( '/', [

'as' => 'index',

'uses' => 'IndexController@index',

]);

// Users

Route :: resource ( '/users', 'UsersController' );

// Clients

Route :: resource ( '/clients', 'ClientsController' );

// Projects

Route :: resource ( '/projects', 'ProjectsController' );

// Projects Comments

Route :: resource ( '/project-comments', 'ProjectCommentsController' );

// Tasks

Route :: resource ( '/tasks', 'TasksController' );

Route :: post ( '/tasks/subtask', [

'as' => 'task.subtas',

'uses' => 'TasksController@addSubtask',

]);

// Blackboards

Route :: resource ( '/blackboards', 'BlackboardsController' );

// Chat

Route :: resource ( '/chat', 'ChatController' );

});

 

Route :: group ([ 'middleware' => [ 'auth', 'admin' ]], function () {

 

Route :: get ( '/users/create'

 

4.3 Code syntax. routes.php file

 



Поделиться:


Последнее изменение этой страницы: 2016-08-10; просмотров: 190; Нарушение авторского права страницы; Мы поможем в написании вашей работы!

infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 3.147.66.178 (0.021 с.)