|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Scool\Timetables\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Created by PhpStorm. |
|
9
|
|
|
* User: alumne |
|
10
|
|
|
* Date: 22/11/16 |
|
11
|
|
|
* Time: 17:34 |
|
12
|
|
|
*/ |
|
13
|
|
|
class TimetablesServiceProvider extends ServiceProvider |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
public function register() |
|
17
|
|
|
{ |
|
18
|
|
|
if(!defined('SCOOL_TIMETABLES_PATH')){ |
|
19
|
|
|
define('SCOOL_TIMETABLES_PATH',realpath(__DIR__.'/../../')); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
$this->app->bind(\Scool\Timetables\Repositories\AttendanceRepository::class, \Scool\Timetables\Repositories\AttendanceRepositoryEloquent::class); |
|
23
|
|
|
|
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function boot() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->defineRoutes(); |
|
29
|
|
|
// $this->loadMigrations(); |
|
|
|
|
|
|
30
|
|
|
// $this->publishFactories(); |
|
31
|
|
|
// $this->publishConfig(); |
|
32
|
|
|
$this->publishTests(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
private function publishTests() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->publishes( |
|
38
|
|
|
[SCOOL_TIMETABLES_PATH.'/tests/TimetablesTest.php' =>'tests/TimetablesTest.php'], |
|
39
|
|
|
'scool_timetables' |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Load migrations. |
|
45
|
|
|
*/ |
|
46
|
|
|
private function loadMigrations() |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$this->loadMigrationsFrom(SCOOL_TIMETABLES_PATH . '/database/migrations'); |
|
49
|
|
|
} |
|
50
|
|
|
/** |
|
51
|
|
|
* Publish factories. |
|
52
|
|
|
*/ |
|
53
|
|
|
private function publishFactories() |
|
|
|
|
|
|
54
|
|
|
{ |
|
55
|
|
|
$this->publishes( |
|
56
|
|
|
ScoolTimetables::factories(),"scool_timetables" |
|
57
|
|
|
//TODO -> paths in a class |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Publish config. |
|
64
|
|
|
*/ |
|
65
|
|
|
private function publishConfig() { |
|
|
|
|
|
|
66
|
|
|
$this->publishes( |
|
67
|
|
|
ScoolTimetables::configs(),"scool_timetables" |
|
68
|
|
|
); |
|
69
|
|
|
$this->mergeConfigFrom( |
|
70
|
|
|
SCOOL_TIMETABLES_PATH . '/config/timetables.php', 'scool_timetables' |
|
71
|
|
|
); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Define the Timetables routes. |
|
76
|
|
|
*/ |
|
77
|
|
|
protected function defineRoutes() |
|
78
|
|
|
{ |
|
79
|
|
|
if (!$this->app->routesAreCached()) { |
|
80
|
|
|
$router = app('router'); |
|
81
|
|
|
$router->group(['namespace' => 'Scool\Timetables\Http\Controllers'], function () { |
|
82
|
|
|
require __DIR__.'/../Http/routes.php'; |
|
83
|
|
|
}); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.