Skip to content

Commit 18c84be

Browse files
committed
Updated package to work with Laravel 5.3
* Changed Auth engine to new one. * Changes to Routing due to removal of `Route::controller()` and changes in route naming. * Changes to Requests as it now uses `FormRequest` instead of `Request` * Changed `lists` method to `pluck`
1 parent f9a03e9 commit 18c84be

23 files changed

+1174
-77
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
"email": "[email protected]"
1313
}
1414
],
15-
"version": "1.1.6",
15+
"version": "1.2.0",
1616
"require": {
17-
"laravelcollective/html": "5.2.*",
17+
"laravelcollective/html": "^5.3",
1818
"intervention/image": "^2.3",
19-
"yajra/laravel-datatables-oracle": "~6.0"
19+
"yajra/laravel-datatables-oracle": "^6.18"
2020
},
2121
"classmap": [
2222
"src/Controllers",

src/Builders/ControllerBuilder.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function build()
3737
$this->files = $cached['files'];
3838
$this->enum = $cached['enum'];
3939
$this->names();
40-
$template = (string) $this->loadTemplate();
40+
$template = (string)$this->loadTemplate();
4141
$template = $this->buildParts($template);
4242
$this->publish($template);
4343
}
@@ -47,7 +47,7 @@ public function buildCustom($name)
4747
$this->template = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'customController';
4848
$this->name = $name;
4949
$this->names();
50-
$template = (string) $this->loadTemplate();
50+
$template = (string)$this->loadTemplate();
5151
$template = $this->buildParts($template);
5252
$this->publish($template);
5353
}
@@ -165,18 +165,18 @@ public function relationshipsBuilder()
165165
foreach ($this->fields as $field) {
166166
if ($field->type == 'relationship') {
167167
// Formatting fix if the relationship is not first
168-
if (!$first) {
168+
if (! $first) {
169169
$relationships .= ' ';
170170
}
171171
$menu = $menus[$field->relationship_id];
172172
$relationships .= '$'
173-
. $field->relationship_name
174-
. ' = '
175-
. ucfirst(Str::camel($menu->name))
176-
. '::lists("'
177-
. $field->relationship_field
178-
. '", "id")->prepend(\'Please select\', \'\');'
179-
. "\r\n";
173+
. $field->relationship_name
174+
. ' = '
175+
. ucfirst(Str::camel($menu->name))
176+
. '::pluck("'
177+
. $field->relationship_field
178+
. '", "id")->prepend(\'Please select\', null);'
179+
. "\r\n";
180180
}
181181
}
182182

@@ -210,7 +210,7 @@ public function compactBuilder()
210210
}
211211
}
212212
if ($this->enum > 0) {
213-
if (!isset($first)) {
213+
if (! isset($first)) {
214214
$first = true;
215215
}
216216
foreach ($this->fields as $field) {
@@ -281,7 +281,7 @@ private function names()
281281
*/
282282
private function publish($template)
283283
{
284-
if (!file_exists(app_path('Http' . DIRECTORY_SEPARATOR . 'Controllers' . DIRECTORY_SEPARATOR . 'Admin'))) {
284+
if (! file_exists(app_path('Http' . DIRECTORY_SEPARATOR . 'Controllers' . DIRECTORY_SEPARATOR . 'Admin'))) {
285285
mkdir(app_path('Http' . DIRECTORY_SEPARATOR . 'Controllers' . DIRECTORY_SEPARATOR . 'Admin'));
286286
chmod(app_path('Http' . DIRECTORY_SEPARATOR . 'Controllers' . DIRECTORY_SEPARATOR . 'Admin'), 0777);
287287
}

src/Builders/RequestBuilder.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private function buildRules($type)
8888
$rules = '';
8989
foreach ($this->fields as $field) {
9090
// Check if there is no duplication for radio and checkbox
91-
if (!in_array($field->title, $used)) {
91+
if (! in_array($field->title, $used)) {
9292
if ($field->type != 'file' && $field->type != 'relationship' && $field->type != 'money') {
9393
if ($type == 0 || $field->type != 'password') {
9494
switch ($field->validation) {
@@ -192,6 +192,9 @@ private function names()
192192
*/
193193
private function publish($template)
194194
{
195+
if (! file_exists(app_path('Http' . DIRECTORY_SEPARATOR . 'Requests'))) {
196+
mkdir(app_path('Http' . DIRECTORY_SEPARATOR . 'Requests'), 0777, true);
197+
}
195198
file_put_contents(app_path('Http' . DIRECTORY_SEPARATOR . 'Requests' . DIRECTORY_SEPARATOR . 'Create' . $this->fileName),
196199
$template[0]);
197200
file_put_contents(app_path('Http' . DIRECTORY_SEPARATOR . 'Requests' . DIRECTORY_SEPARATOR . 'Update' . $this->fileName),

src/Controllers/QuickadminMenuController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public function createCrud()
7373
$fieldTypes = FieldsDescriber::types();
7474
$fieldValidation = FieldsDescriber::validation();
7575
$defaultValuesCbox = FieldsDescriber::default_cbox();
76-
$menusSelect = Menu::whereNotIn('menu_type', [2, 3])->lists('title', 'id');
76+
$menusSelect = Menu::whereNotIn('menu_type', [2, 3])->pluck('title', 'id');
7777
$roles = Role::all();
78-
$parentsSelect = Menu::where('menu_type', 2)->lists('title', 'id')->prepend('-- no parent --', '');
78+
$parentsSelect = Menu::where('menu_type', 2)->pluck('title', 'id')->prepend('-- no parent --', '');
7979
// Get columns for relationship
8080
$models = [];
8181
foreach (Menu::whereNotIn('menu_type', [2, 3])->get() as $menu) {
@@ -245,7 +245,7 @@ public function insertParent(Request $request)
245245
*/
246246
public function createCustom()
247247
{
248-
$parentsSelect = Menu::where('menu_type', 2)->lists('title', 'id')->prepend('-- no parent --', '');
248+
$parentsSelect = Menu::where('menu_type', 2)->pluck('title', 'id')->prepend('-- no parent --', '');
249249
$roles = Role::all();
250250

251251
return view('qa::menus.createCustom', compact('parentsSelect', 'roles'));
@@ -291,7 +291,7 @@ public function insertCustom(Request $request)
291291
public function edit($id)
292292
{
293293
$menu = Menu::findOrFail($id);
294-
$parentsSelect = Menu::where('menu_type', 2)->lists('title', 'id')->prepend('-- no parent --', '');
294+
$parentsSelect = Menu::where('menu_type', 2)->pluck('title', 'id')->prepend('-- no parent --', '');
295295
$roles = Role::all();
296296

297297
return view('qa::menus.edit', compact('menu', 'parentsSelect', 'roles'));
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
7+
8+
class ForgotPasswordController extends Controller
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Password Reset Controller
13+
|--------------------------------------------------------------------------
14+
|
15+
| This controller is responsible for handling password reset emails and
16+
| includes a trait which assists in sending these notifications from
17+
| your application to your users. Feel free to explore this trait.
18+
|
19+
*/
20+
21+
use SendsPasswordResetEmails;
22+
23+
/**
24+
* Create a new controller instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
$this->middleware('guest');
31+
}
32+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\AuthenticatesUsers;
7+
8+
class LoginController extends Controller
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Login Controller
13+
|--------------------------------------------------------------------------
14+
|
15+
| This controller handles authenticating users for the application and
16+
| redirecting them to your home screen. The controller uses a trait
17+
| to conveniently provide its functionality to your applications.
18+
|
19+
*/
20+
21+
use AuthenticatesUsers;
22+
23+
/**
24+
* Where to redirect users after login / registration.
25+
*
26+
* @var string
27+
*/
28+
protected $redirectTo = '/home';
29+
30+
/**
31+
* Create a new controller instance.
32+
*
33+
* @return void
34+
*/
35+
public function __construct()
36+
{
37+
$this->middleware('guest', ['except' => 'logout']);
38+
}
39+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\User;
6+
use Validator;
7+
use App\Http\Controllers\Controller;
8+
use Illuminate\Foundation\Auth\RegistersUsers;
9+
10+
class RegisterController extends Controller
11+
{
12+
/*
13+
|--------------------------------------------------------------------------
14+
| Register Controller
15+
|--------------------------------------------------------------------------
16+
|
17+
| This controller handles the registration of new users as well as their
18+
| validation and creation. By default this controller uses a trait to
19+
| provide this functionality without requiring any additional code.
20+
|
21+
*/
22+
23+
use RegistersUsers;
24+
25+
/**
26+
* Where to redirect users after login / registration.
27+
*
28+
* @var string
29+
*/
30+
protected $redirectTo = '/home';
31+
32+
/**
33+
* Create a new controller instance.
34+
*
35+
* @return void
36+
*/
37+
public function __construct()
38+
{
39+
$this->middleware('guest');
40+
}
41+
42+
/**
43+
* Get a validator for an incoming registration request.
44+
*
45+
* @param array $data
46+
* @return \Illuminate\Contracts\Validation\Validator
47+
*/
48+
protected function validator(array $data)
49+
{
50+
return Validator::make($data, [
51+
'name' => 'required|max:255',
52+
'email' => 'required|email|max:255|unique:users',
53+
'password' => 'required|min:6|confirmed',
54+
]);
55+
}
56+
57+
/**
58+
* Create a new user instance after a valid registration.
59+
*
60+
* @param array $data
61+
* @return User
62+
*/
63+
protected function create(array $data)
64+
{
65+
return User::create([
66+
'name' => $data['name'],
67+
'email' => $data['email'],
68+
'password' => bcrypt($data['password']),
69+
]);
70+
}
71+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\ResetsPasswords;
7+
8+
class ResetPasswordController extends Controller
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Password Reset Controller
13+
|--------------------------------------------------------------------------
14+
|
15+
| This controller is responsible for handling password reset requests
16+
| and uses a simple trait to include this behavior. You're free to
17+
| explore this trait and override any methods you wish to tweak.
18+
|
19+
*/
20+
21+
use ResetsPasswords;
22+
23+
/**
24+
* Create a new controller instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
$this->middleware('guest');
31+
}
32+
}

src/Controllers/publish/UsersController

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class UsersController extends Controller
2626
*/
2727
public function create()
2828
{
29-
$roles = Role::lists('title', 'id');
29+
$roles = Role::pluck('title', 'id');
3030

3131
return view('admin.users.create', compact('roles'));
3232
}
@@ -57,7 +57,7 @@ class UsersController extends Controller
5757
public function edit($id)
5858
{
5959
$user = User::findOrFail($id);
60-
$roles = Role::lists('title', 'id');
60+
$roles = Role::pluck('title', 'id');
6161

6262
return view('admin.users.edit', compact('user', 'roles'));
6363
}

src/Controllers/publish/UsersController.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class UsersController extends Controller
2626
*/
2727
public function create()
2828
{
29-
$roles = Role::lists('title', 'id');
29+
$roles = Role::pluck('title', 'id');
3030

3131
return view('admin.users.create', compact('roles'));
3232
}
@@ -57,7 +57,7 @@ class UsersController extends Controller
5757
public function edit($id)
5858
{
5959
$user = User::findOrFail($id);
60-
$roles = Role::lists('title', 'id');
60+
$roles = Role::pluck('title', 'id');
6161

6262
return view('admin.users.edit', compact('user', 'roles'));
6363
}

0 commit comments

Comments
 (0)