@@ -26,7 +26,7 @@ |
||
26 | 26 | /** |
27 | 27 | * Show the application welcome screen to the user. |
28 | 28 | * |
29 | - * @return Response |
|
29 | + * @return \Illuminate\View\View |
|
30 | 30 | */ |
31 | 31 | public function index() |
32 | 32 | { |
@@ -6,20 +6,20 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Create admin model from User class with title and url alias |
9 | -Admin::model('\User')->title('Users')->as('users-alias-name')->denyCreating(function () |
|
9 | +Admin::model('\User')->title('Users')->as('users-alias-name')->denyCreating(function() |
|
10 | 10 | { |
11 | 11 | // Deny creating on thursday |
12 | 12 | return date('w') == 4; |
13 | -})->denyEditingAndDeleting(function ($instance) |
|
13 | +})->denyEditingAndDeleting(function($instance) |
|
14 | 14 | { |
15 | 15 | // deny editing and deleting rows when this is true |
16 | 16 | return ($instance->id <= 2) || ($instance->email == 'admin'); |
17 | -})->columns(function () |
|
17 | +})->columns(function() |
|
18 | 18 | { |
19 | 19 | // Describing columns for table view |
20 | 20 | Column::string('name', 'Name'); |
21 | 21 | Column::string('email', 'Email'); |
22 | -})->form(function () |
|
22 | +})->form(function() |
|
23 | 23 | { |
24 | 24 | // Describing elements in create and editing forms |
25 | 25 | FormItem::text('name', 'Name'); |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | |
6 | 6 | })->columns(function () |
7 | 7 | { |
8 | - //Column::image('training_resource_thumbnail'); |
|
9 | - Column::string('training_resource_id', 'ID'); |
|
8 | + //Column::image('training_resource_thumbnail'); |
|
9 | + Column::string('training_resource_id', 'ID'); |
|
10 | 10 | Column::string('training_resource_name', 'Nom'); |
11 | 11 | //Column::string('training_resource_short_name', 'Nom Curt'); |
12 | 12 | Column::string('training_resource_description', 'Descripció'); |
13 | 13 | //Column::string('training_resource_external_url', 'URL'); |
14 | - //Column::string('training_resource_name', 'Pare')->append(Column::where('training_resource_id', '=', 'training_resource_parentResourceId')); |
|
15 | - Column::string('parent.training_resource_name', 'Pare'); |
|
14 | + //Column::string('training_resource_name', 'Pare')->append(Column::where('training_resource_id', '=', 'training_resource_parentResourceId')); |
|
15 | + Column::string('parent.training_resource_name', 'Pare'); |
|
16 | 16 | |
17 | 17 | })->form(function () |
18 | 18 | { |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | FormItem::text('training_resource_short_name', 'Nom Curt'); |
21 | 21 | FormItem::image('training_resource_thumbnail', 'Imatge'); |
22 | 22 | FormItem::text('training_resource_external_url', 'URL Externa'); |
23 | - FormItem::select('training_resource_parentResourceId', 'Pare')->list('\App\Training_Resource')->nullable(); |
|
23 | + FormItem::select('training_resource_parentResourceId', 'Pare')->list('\App\Training_Resource')->nullable(); |
|
24 | 24 | //FormItem::timestamp('training_resource_entryDate', 'Data Creació');//->seconds(true); |
25 | 25 | //FormItem::timestamp('training_resource_last_update', 'Data de l\'última modificació');//->seconds(true); |
26 | - FormItem::checkbox('training_resource_softDeleted', 'SoftDeleted'); |
|
27 | - FormItem::ckeditor('training_resource_description', 'Descripció'); |
|
26 | + FormItem::checkbox('training_resource_softDeleted', 'SoftDeleted'); |
|
27 | + FormItem::ckeditor('training_resource_description', 'Descripció'); |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | 31 | //FormItem::text('training_resource_creationUserId', 'Training Resource Creation User Id'); |
32 | 32 | //FormItem::text('training_resource_lastupdateUserId', 'Training Resource Lastupdate User Id'); |
33 | 33 | |
34 | - //FormItem::timestamp('training_resource_softDeletedDate', 'Training Resource Soft Deleted Date');//->seconds(true); |
|
34 | + //FormItem::timestamp('training_resource_softDeletedDate', 'Training Resource Soft Deleted Date');//->seconds(true); |
|
35 | 35 | }); |
36 | 36 | \ No newline at end of file |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -Admin::model('\App\Training_Resource')->title('Recursos de formació')->with()->filters(function () |
|
3 | +Admin::model('\App\Training_Resource')->title('Recursos de formació')->with()->filters(function() |
|
4 | 4 | { |
5 | 5 | |
6 | -})->columns(function () |
|
6 | +})->columns(function() |
|
7 | 7 | { |
8 | 8 | //Column::image('training_resource_thumbnail'); |
9 | 9 | Column::string('training_resource_id', 'ID'); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | //Column::string('training_resource_name', 'Pare')->append(Column::where('training_resource_id', '=', 'training_resource_parentResourceId')); |
15 | 15 | Column::string('parent.training_resource_name', 'Pare'); |
16 | 16 | |
17 | -})->form(function () |
|
17 | +})->form(function() |
|
18 | 18 | { |
19 | 19 | FormItem::text('training_resource_name', 'Nom')->required(); |
20 | 20 | FormItem::text('training_resource_short_name', 'Nom Curt'); |
@@ -24,6 +24,6 @@ |
||
24 | 24 | Route::resource('api/training_resource', 'Training_Resource_Controller'); |
25 | 25 | |
26 | 26 | Route::controllers([ |
27 | - 'auth' => 'Auth\AuthController', |
|
28 | - 'password' => 'Auth\PasswordController', |
|
27 | + 'auth' => 'Auth\AuthController', |
|
28 | + 'password' => 'Auth\PasswordController', |
|
29 | 29 | ]); |
@@ -7,101 +7,101 @@ |
||
7 | 7 | class Training_Resource_Controller extends Controller |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Display a listing of the resource. |
|
12 | - * |
|
13 | - * @return Response |
|
14 | - */ |
|
15 | - public function index() |
|
16 | - { |
|
17 | - $training_resources = new Training_Resource; |
|
18 | - |
|
19 | - $id = Input::get('training_resource_parentResourceId'); |
|
20 | - |
|
21 | - if ($id || ($id == 0)) |
|
22 | - $training_resources = $training_resources::where('training_resource_parentResourceId', '=', $id); |
|
23 | - |
|
24 | - return $training_resources->get(); |
|
25 | - |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Show the form for creating a new resource. |
|
30 | - * |
|
31 | - * @return Response |
|
32 | - */ |
|
33 | - public function create() |
|
34 | - { |
|
35 | - // |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * Store a newly created resource in storage. |
|
40 | - * |
|
41 | - * @return Response |
|
42 | - */ |
|
43 | - public function store() |
|
44 | - { |
|
45 | - |
|
46 | - $training_resource = Training_Resource::create(Request::all()); |
|
47 | - return $training_resource; |
|
48 | - |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Display the specified resource. |
|
53 | - * |
|
54 | - * @param int $id |
|
55 | - * @return Response |
|
56 | - */ |
|
57 | - public function show($id) |
|
58 | - { |
|
59 | - |
|
60 | - $training_resource = Training_Resource::find($id); |
|
61 | - return $training_resource; |
|
62 | - |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Show the form for editing the specified resource. |
|
67 | - * |
|
68 | - * @param int $id |
|
69 | - * @return Response |
|
70 | - */ |
|
71 | - public function edit($id) |
|
72 | - { |
|
73 | - // |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Update the specified resource in storage. |
|
78 | - * |
|
79 | - * @param int $id |
|
80 | - * @return Response |
|
81 | - */ |
|
82 | - public function update($id) |
|
83 | - { |
|
84 | - $training_resource = Training_Resource::find($id); |
|
85 | - $training_resource->training_resource_name = Request::input('training_resource_name'); |
|
86 | - $training_resource->training_resource_short_name = Request::input('training_resource_short_name'); |
|
87 | - $training_resource->training_resource_description = Request::input('training_resource_description'); |
|
88 | - $training_resource->training_resource_thumbnail = Request::input('training_resource_thumbnail'); |
|
89 | - $training_resource->training_resource_external_url = Request::input('training_resource_external_url'); |
|
90 | - $training_resource->training_resource_softDeleted = Request::input('training_resource_softDeleted'); |
|
91 | - |
|
92 | - $training_resource->save(); |
|
93 | - |
|
94 | - return $training_resource; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Remove the specified resource from storage. |
|
99 | - * |
|
100 | - * @param int $id |
|
101 | - * @return Response |
|
102 | - */ |
|
103 | - public function destroy($id) |
|
104 | - { |
|
105 | - Training_Resource::destroy($id); |
|
106 | - } |
|
10 | + /** |
|
11 | + * Display a listing of the resource. |
|
12 | + * |
|
13 | + * @return Response |
|
14 | + */ |
|
15 | + public function index() |
|
16 | + { |
|
17 | + $training_resources = new Training_Resource; |
|
18 | + |
|
19 | + $id = Input::get('training_resource_parentResourceId'); |
|
20 | + |
|
21 | + if ($id || ($id == 0)) |
|
22 | + $training_resources = $training_resources::where('training_resource_parentResourceId', '=', $id); |
|
23 | + |
|
24 | + return $training_resources->get(); |
|
25 | + |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Show the form for creating a new resource. |
|
30 | + * |
|
31 | + * @return Response |
|
32 | + */ |
|
33 | + public function create() |
|
34 | + { |
|
35 | + // |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * Store a newly created resource in storage. |
|
40 | + * |
|
41 | + * @return Response |
|
42 | + */ |
|
43 | + public function store() |
|
44 | + { |
|
45 | + |
|
46 | + $training_resource = Training_Resource::create(Request::all()); |
|
47 | + return $training_resource; |
|
48 | + |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Display the specified resource. |
|
53 | + * |
|
54 | + * @param int $id |
|
55 | + * @return Response |
|
56 | + */ |
|
57 | + public function show($id) |
|
58 | + { |
|
59 | + |
|
60 | + $training_resource = Training_Resource::find($id); |
|
61 | + return $training_resource; |
|
62 | + |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Show the form for editing the specified resource. |
|
67 | + * |
|
68 | + * @param int $id |
|
69 | + * @return Response |
|
70 | + */ |
|
71 | + public function edit($id) |
|
72 | + { |
|
73 | + // |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Update the specified resource in storage. |
|
78 | + * |
|
79 | + * @param int $id |
|
80 | + * @return Response |
|
81 | + */ |
|
82 | + public function update($id) |
|
83 | + { |
|
84 | + $training_resource = Training_Resource::find($id); |
|
85 | + $training_resource->training_resource_name = Request::input('training_resource_name'); |
|
86 | + $training_resource->training_resource_short_name = Request::input('training_resource_short_name'); |
|
87 | + $training_resource->training_resource_description = Request::input('training_resource_description'); |
|
88 | + $training_resource->training_resource_thumbnail = Request::input('training_resource_thumbnail'); |
|
89 | + $training_resource->training_resource_external_url = Request::input('training_resource_external_url'); |
|
90 | + $training_resource->training_resource_softDeleted = Request::input('training_resource_softDeleted'); |
|
91 | + |
|
92 | + $training_resource->save(); |
|
93 | + |
|
94 | + return $training_resource; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Remove the specified resource from storage. |
|
99 | + * |
|
100 | + * @param int $id |
|
101 | + * @return Response |
|
102 | + */ |
|
103 | + public function destroy($id) |
|
104 | + { |
|
105 | + Training_Resource::destroy($id); |
|
106 | + } |
|
107 | 107 | } |
108 | 108 | \ No newline at end of file |
@@ -18,8 +18,9 @@ |
||
18 | 18 | |
19 | 19 | $id = Input::get('training_resource_parentResourceId'); |
20 | 20 | |
21 | - if ($id || ($id == 0)) |
|
22 | - $training_resources = $training_resources::where('training_resource_parentResourceId', '=', $id); |
|
21 | + if ($id || ($id == 0)) { |
|
22 | + $training_resources = $training_resources::where('training_resource_parentResourceId', '=', $id); |
|
23 | + } |
|
23 | 24 | |
24 | 25 | return $training_resources->get(); |
25 | 26 |
@@ -37,8 +37,7 @@ |
||
37 | 37 | if ($request->ajax()) |
38 | 38 | { |
39 | 39 | return response('Unauthorized.', 401); |
40 | - } |
|
41 | - else |
|
40 | + } else |
|
42 | 41 | { |
43 | 42 | return redirect()->guest('auth/login'); |
44 | 43 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', |
16 | 16 | 'Illuminate\Session\Middleware\StartSession', |
17 | 17 | 'Illuminate\View\Middleware\ShareErrorsFromSession', |
18 | - // EDITED |
|
18 | + // EDITED |
|
19 | 19 | //'App\Http\Middleware\VerifyCsrfToken', |
20 | 20 | ]; |
21 | 21 |
@@ -7,99 +7,99 @@ |
||
7 | 7 | |
8 | 8 | class Training_Resource extends SleepingOwlModel implements ModelWithImageFieldsInterface |
9 | 9 | { |
10 | - use ModelWithImageOrFileFieldsTrait; |
|
11 | - |
|
12 | - public $timestamps = true; |
|
13 | - |
|
14 | - |
|
15 | - /** |
|
16 | - * The database table used by the model. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $table = 'training_resource'; |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * Primary key of the table |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $primaryKey = 'training_resource_id'; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * The name of the "created at" column. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - const CREATED_AT = 'training_resource_entryDate'; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * The name of the "updated at" column. |
|
40 | - * |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - const UPDATED_AT = 'training_resource_last_update'; |
|
44 | - |
|
45 | - |
|
46 | - protected $fillable = [ |
|
47 | - 'training_resource_name', |
|
48 | - 'training_resource_short_name', |
|
49 | - 'training_resource_description', |
|
50 | - 'training_resource_thumbnail', |
|
51 | - 'training_resource_external_url', |
|
52 | - 'training_resource_softDeleted', |
|
53 | - 'training_resource_parentResourceId' |
|
54 | - ]; |
|
55 | - |
|
56 | - |
|
57 | - protected $hidden = [ |
|
58 | - 'training_resource_entryDate', |
|
59 | - 'training_resource_last_update' |
|
60 | - ]; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Get array of image field names and its directories within images folder |
|
65 | - * |
|
66 | - * Keys of array is image field names |
|
67 | - * Values is their directories |
|
68 | - * |
|
69 | - * @return string[] |
|
70 | - */ |
|
71 | - |
|
72 | - public function getImageFields() |
|
73 | - { |
|
74 | - return [ |
|
75 | - 'training_resource_thumbnail' => '/' |
|
76 | - ]; |
|
77 | - } |
|
78 | - |
|
79 | - public function parent() |
|
80 | - { |
|
81 | - return $this->belongsTo('\App\Training_Resource', 'training_resource_parentResourceId'); |
|
82 | - } |
|
83 | - |
|
84 | - public function children() |
|
85 | - { |
|
86 | - return $this->hasMany('\App\Training_Resource', 'training_resource_id'); |
|
87 | - } |
|
88 | - public static function getList() |
|
89 | - { |
|
90 | - return static::lists('training_resource_name', 'training_resource_id'); |
|
91 | - } |
|
92 | - |
|
93 | - public function getDates() |
|
94 | - { |
|
95 | - return array_merge(parent::getDates(), ['training_resource_entryDate','training_resource_last_update']); |
|
96 | - } |
|
97 | - public function pare($pare) |
|
98 | - { |
|
99 | - $this->training_resource()->detach(); |
|
100 | - if ( ! $pare) return; |
|
101 | - if ( ! $this->exists) $this->save(); |
|
102 | - $this->training_resource()->attach($pare); |
|
103 | - } |
|
10 | + use ModelWithImageOrFileFieldsTrait; |
|
11 | + |
|
12 | + public $timestamps = true; |
|
13 | + |
|
14 | + |
|
15 | + /** |
|
16 | + * The database table used by the model. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $table = 'training_resource'; |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * Primary key of the table |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $primaryKey = 'training_resource_id'; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * The name of the "created at" column. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + const CREATED_AT = 'training_resource_entryDate'; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * The name of the "updated at" column. |
|
40 | + * |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + const UPDATED_AT = 'training_resource_last_update'; |
|
44 | + |
|
45 | + |
|
46 | + protected $fillable = [ |
|
47 | + 'training_resource_name', |
|
48 | + 'training_resource_short_name', |
|
49 | + 'training_resource_description', |
|
50 | + 'training_resource_thumbnail', |
|
51 | + 'training_resource_external_url', |
|
52 | + 'training_resource_softDeleted', |
|
53 | + 'training_resource_parentResourceId' |
|
54 | + ]; |
|
55 | + |
|
56 | + |
|
57 | + protected $hidden = [ |
|
58 | + 'training_resource_entryDate', |
|
59 | + 'training_resource_last_update' |
|
60 | + ]; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Get array of image field names and its directories within images folder |
|
65 | + * |
|
66 | + * Keys of array is image field names |
|
67 | + * Values is their directories |
|
68 | + * |
|
69 | + * @return string[] |
|
70 | + */ |
|
71 | + |
|
72 | + public function getImageFields() |
|
73 | + { |
|
74 | + return [ |
|
75 | + 'training_resource_thumbnail' => '/' |
|
76 | + ]; |
|
77 | + } |
|
78 | + |
|
79 | + public function parent() |
|
80 | + { |
|
81 | + return $this->belongsTo('\App\Training_Resource', 'training_resource_parentResourceId'); |
|
82 | + } |
|
83 | + |
|
84 | + public function children() |
|
85 | + { |
|
86 | + return $this->hasMany('\App\Training_Resource', 'training_resource_id'); |
|
87 | + } |
|
88 | + public static function getList() |
|
89 | + { |
|
90 | + return static::lists('training_resource_name', 'training_resource_id'); |
|
91 | + } |
|
92 | + |
|
93 | + public function getDates() |
|
94 | + { |
|
95 | + return array_merge(parent::getDates(), ['training_resource_entryDate','training_resource_last_update']); |
|
96 | + } |
|
97 | + public function pare($pare) |
|
98 | + { |
|
99 | + $this->training_resource()->detach(); |
|
100 | + if ( ! $pare) return; |
|
101 | + if ( ! $this->exists) $this->save(); |
|
102 | + $this->training_resource()->attach($pare); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | \ No newline at end of file |
@@ -92,13 +92,13 @@ |
||
92 | 92 | |
93 | 93 | public function getDates() |
94 | 94 | { |
95 | - return array_merge(parent::getDates(), ['training_resource_entryDate','training_resource_last_update']); |
|
95 | + return array_merge(parent::getDates(), ['training_resource_entryDate', 'training_resource_last_update']); |
|
96 | 96 | } |
97 | 97 | public function pare($pare) |
98 | 98 | { |
99 | 99 | $this->training_resource()->detach(); |
100 | - if ( ! $pare) return; |
|
101 | - if ( ! $this->exists) $this->save(); |
|
100 | + if (!$pare) return; |
|
101 | + if (!$this->exists) $this->save(); |
|
102 | 102 | $this->training_resource()->attach($pare); |
103 | 103 | } |
104 | 104 |
@@ -97,8 +97,12 @@ |
||
97 | 97 | public function pare($pare) |
98 | 98 | { |
99 | 99 | $this->training_resource()->detach(); |
100 | - if ( ! $pare) return; |
|
101 | - if ( ! $this->exists) $this->save(); |
|
100 | + if ( ! $pare) { |
|
101 | + return; |
|
102 | + } |
|
103 | + if ( ! $this->exists) { |
|
104 | + $this->save(); |
|
105 | + } |
|
102 | 106 | $this->training_resource()->attach($pare); |
103 | 107 | } |
104 | 108 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | /** |
27 | 27 | * Show the application welcome screen to the user. |
28 | 28 | * |
29 | - * @return Response |
|
29 | + * @return \Illuminate\View\View |
|
30 | 30 | */ |
31 | 31 | public function index() |
32 | 32 | { |