Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
60ce1613
Commit
60ce1613
authored
Dec 08, 2017
by
Vipul Basapati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Faqs Module
parent
86e360dd
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
102 additions
and
90 deletions
+102
-90
Kernel.php
app/Console/Kernel.php
+0
-1
FaqStatusController.php
app/Http/Controllers/Backend/Faqs/FaqStatusController.php
+38
-0
FaqsController.php
app/Http/Controllers/Backend/Faqs/FaqsController.php
+30
-52
Faq.php
app/Models/Faqs/Faq.php
+1
-1
FaqsRepository.php
app/Repositories/Backend/Faqs/FaqsRepository.php
+21
-27
module.php
config/module.php
+3
-0
edit.blade.php
resources/views/backend/faqs/edit.blade.php
+1
-1
form.blade.php
resources/views/backend/faqs/form.blade.php
+2
-2
index.blade.php
resources/views/backend/faqs/index.blade.php
+5
-5
Faqs.php
routes/Backend/Faqs.php
+1
-1
No files found.
app/Console/Kernel.php
View file @
60ce1613
...
...
@@ -13,7 +13,6 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected
$commands
=
[
'App\Console\Commands\ModuleGenerator'
,
];
/**
...
...
app/Http/Controllers/Backend/Faqs/FaqStatusController.php
0 → 100644
View file @
60ce1613
<?php
namespace
App\Http\Controllers\Backend\Faqs
;
use
App\Models\Faqs\Faq
;
use
App\Http\Controllers\Controller
;
use
App\Repositories\Backend\Faqs\FaqsRepository
;
use
App\Http\Requests\Backend\Faqs\EditFaqsRequest
;
use
App\Http\Requests\Backend\Faqs\ManageFaqsRequest
;
class
FaqStatusController
extends
Controller
{
protected
$faq
;
/**
* @param \App\Repositories\Backend\Faqs\FaqsRepository $faq
*/
public
function
__construct
(
FaqsRepository
$faq
)
{
$this
->
faq
=
$faq
;
}
/**
* @param \App\Models\Faqs\Faq $Faq
* @param $status
* @param \App\Http\Requests\Backend\Faqs\ManageFaqsRequest $request
*
* @return mixed
*/
public
function
store
(
Faq
$faq
,
$status
,
EditFaqsRequest
$request
)
{
$this
->
faq
->
mark
(
$faq
,
$status
);
return
redirect
()
->
route
(
'admin.faqs.index'
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.faqs.updated'
));
}
}
\ No newline at end of file
app/Http/Controllers/Backend/Faqs/FaqsController.php
View file @
60ce1613
...
...
@@ -14,35 +14,31 @@ use App\Repositories\Backend\Faqs\FaqsRepository;
class
FaqsController
extends
Controller
{
/**
* @var FaqsRepository
*/
protected
$faqs
;
protected
$faq
;
/**
* @param
FaqsRepository $faqs
* @param
\App\Repositories\Backend\Faqs\FaqsRepository $faq
*/
public
function
__construct
(
FaqsRepository
$faq
s
)
public
function
__construct
(
FaqsRepository
$faq
)
{
$this
->
faq
s
=
$faqs
;
$this
->
faq
=
$faq
;
}
/**
* Display a listing of the resource.
*
* @param \App\Http\Requests\Backend\Faqs\ManageFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
public
function
index
(
ManageFaqsRequest
$request
)
{
//Status array
$status
=
[
1
=>
'Active'
,
0
=>
'Inactive'
];
return
view
(
'backend.faqs.index'
)
->
withStatus
(
$status
);
return
view
(
'backend.faqs.index'
);
}
/**
* Show the form for creating a new resource.
*
* @param \App\Http\Requests\Backend\Faqs\CreateFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
public
function
create
(
CreateFaqsRequest
$request
)
...
...
@@ -52,8 +48,7 @@ class FaqsController extends Controller
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Http\Requests\Backend\Faqs\StoreFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
...
...
@@ -61,39 +56,32 @@ class FaqsController extends Controller
{
$input
=
$request
->
all
();
$this
->
faq
s
->
create
(
$input
);
$this
->
faq
->
create
(
$input
);
return
redirect
()
->
route
(
'admin.faqs.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.faqs.created'
));
}
/**
* Display the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public
function
show
(
$id
)
{
return
redirect
()
->
route
(
'admin.faqs.index'
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.faqs.created'
));
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\EditFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
public
function
edit
(
Faq
$faq
,
EditFaqsRequest
$request
)
{
return
view
(
'backend.faqs.edit'
)
->
withItem
(
$faq
);
return
view
(
'backend.faqs.edit'
)
->
with
(
'faq'
,
$faq
);
}
/**
* Update the specified resource in storage.
*
* @param \
Illuminate\Http\
Request $request
* @param
int
$id
* @param \
App\Http\Requests\Backend\Faqs\UpdateFaqs
Request $request
* @param
\App\Models\Faqs\Faq
$id
*
* @return \Illuminate\Http\Response
*/
...
...
@@ -101,37 +89,27 @@ class FaqsController extends Controller
{
$input
=
$request
->
all
();
$this
->
faq
s
->
update
(
$faq
,
$input
);
$this
->
faq
->
update
(
$faq
,
$input
);
return
redirect
()
->
route
(
'admin.faqs.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.faqs.updated'
));
return
redirect
()
->
route
(
'admin.faqs.index'
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.faqs.updated'
));
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param \App\Models\Faqs\Faq $faq
* @param \App\Http\Requests\Backend\Faqs\DeleteFaqsRequest $request
*
* @return \Illuminate\Http\Response
*/
public
function
destroy
(
Faq
$faq
,
DeleteFaqsRequest
$request
)
{
$this
->
faqs
->
delete
(
$faq
);
return
redirect
()
->
route
(
'admin.faqs.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.faqs.deleted'
));
}
/**
* @param Faq $Faq
* @param $status
* @param ManageFaqRequest $request
*
* @return mixed
*/
public
function
mark
(
$id
,
$status
,
EditFaqsRequest
$request
)
{
$faq
=
Faq
::
find
(
$id
);
$this
->
faqs
->
mark
(
$faq
,
$status
);
$this
->
faq
->
delete
(
$faq
);
return
redirect
()
->
route
(
'admin.faqs.index'
)
->
withFlashSuccess
(
trans
(
'alerts.backend.faqs.updated'
));
return
redirect
()
->
route
(
'admin.faqs.index'
)
->
with
(
'flash_success'
,
trans
(
'alerts.backend.faqs.deleted'
));
}
}
app/Models/Faqs/Faq.php
View file @
60ce1613
...
...
@@ -32,6 +32,6 @@ class Faq extends BaseModel
public
function
__construct
(
array
$attributes
=
[])
{
parent
::
__construct
(
$attributes
);
$this
->
table
=
config
(
'
access.faqs_
table'
);
$this
->
table
=
config
(
'
module.faqs.
table'
);
}
}
app/Repositories/Backend/Faqs/FaqsRepository.php
View file @
60ce1613
...
...
@@ -23,31 +23,27 @@ class FaqsRepository extends BaseRepository
{
return
$this
->
query
()
->
select
([
config
(
'
access.faqs_t
able'
)
.
'.id'
,
config
(
'
access.faqs_
table'
)
.
'.question'
,
config
(
'
access.faqs_
table'
)
.
'.answer'
,
config
(
'
access.faqs_
table'
)
.
'.status'
,
config
(
'
access.faqs_
table'
)
.
'.created_at'
,
config
(
'
mdule.faqs.
able'
)
.
'.id'
,
config
(
'
odule.faqs.
table'
)
.
'.question'
,
config
(
'
module.faqs.
table'
)
.
'.answer'
,
config
(
'
module.faqs.
table'
)
.
'.status'
,
config
(
'
module.faqs.
table'
)
.
'.created_at'
,
]);
}
/**
* @param array $input
*
* @throws GeneralException
* @throws
\App\Exceptions\
GeneralException
*
* @return bool
*/
public
function
create
(
array
$input
)
{
$faq
=
self
::
MODEL
;
$faq
=
new
$faq
();
$faq
->
question
=
$input
[
'question'
];
$faq
->
answer
=
$input
[
'answer'
];
$faq
->
status
=
isset
(
$input
[
'status'
])
?
$input
[
'status'
]
:
0
;
$input
[
'status'
]
=
isset
(
$input
[
'status'
])
?
1
:
0
;
//If faq saved successfully, then return true
if
(
$faq
->
save
(
))
{
if
(
Faq
::
create
(
$input
))
{
return
true
;
}
...
...
@@ -55,21 +51,19 @@ class FaqsRepository extends BaseRepository
}
/**
* @param
Model $permission
* @param $input
* @param
\App\Models\Faqs\Faq $faq
* @param
array
$input
*
* @throws GeneralException
* @throws
\App\Exceptions\
GeneralException
*
* return bool
*/
public
function
update
(
Model
$faq
,
array
$input
)
public
function
update
(
Faq
$faq
,
array
$input
)
{
$faq
->
question
=
$input
[
'question'
];
$faq
->
answer
=
$input
[
'answer'
];
$faq
->
status
=
isset
(
$input
[
'status'
])
?
$input
[
'status'
]
:
0
;
$input
[
'status'
]
=
isset
(
$input
[
'status'
])
?
1
:
0
;
//If faq updated successfully
if
(
$faq
->
save
(
))
{
if
(
$faq
->
update
(
$input
))
{
return
true
;
}
...
...
@@ -77,13 +71,13 @@ class FaqsRepository extends BaseRepository
}
/**
* @param
Model $blog
* @param
\App\Models\Faqs\Faq $faq
*
* @throws GeneralException
* @throws
\App\Exceptions\
GeneralException
*
* @return bool
*/
public
function
delete
(
Model
$faq
)
public
function
delete
(
Faq
$faq
)
{
if
(
$faq
->
delete
())
{
return
true
;
...
...
@@ -93,14 +87,14 @@ class FaqsRepository extends BaseRepository
}
/**
* @param
Model
$faq
* @param $status
* @param
\App\Models\Faqs\Faq
$faq
* @param
string
$status
*
* @throws GeneralException
* @throws
\App\Exceptions\
GeneralException
*
* @return bool
*/
public
function
mark
(
Model
$faq
,
$status
)
public
function
mark
(
Faq
$faq
,
$status
)
{
$faq
->
status
=
$status
;
...
...
config/module.php
View file @
60ce1613
...
...
@@ -17,5 +17,8 @@ return [
],
'blogs'
=>
[
'table'
=>
'blogs'
],
'faqs'
=>
[
'table'
=>
'faqs'
]
];
resources/views/backend/faqs/edit.blade.php
View file @
60ce1613
...
...
@@ -10,7 +10,7 @@
@
endsection
@
section
(
'content'
)
{{
Form
::
model
(
$
item
,
[
'route'
=>
[
'admin.faqs.update'
,
$item
],
'class'
=>
'form-horizontal'
,
'role'
=>
'form'
,
'method'
=>
'PATCH'
,
'id'
=>
'edit-faqs'
])
}}
{{
Form
::
model
(
$
faq
,
[
'route'
=>
[
'admin.faqs.update'
,
$faq
],
'class'
=>
'form-horizontal'
,
'role'
=>
'form'
,
'method'
=>
'PATCH'
,
'id'
=>
'edit-faqs'
])
}}
<
div
class
="
box
box
-
success
">
<div class="
box
-
header
with
-
border
">
...
...
resources/views/backend/faqs/form.blade.php
View file @
60ce1613
...
...
@@ -21,8 +21,8 @@
<div
class=
"col-lg-10"
>
<div
class=
"control-group"
>
<label
class=
"control control--checkbox"
>
@if(isset($
item
->status))
{{ Form::checkbox('status', 1, $
item
->status == 1 ? true :false) }}
@if(isset($
faq
->status))
{{ Form::checkbox('status', 1, $
faq
->status == 1 ? true :false) }}
@else
{{ Form::checkbox('status', 1, true) }}
@endif
...
...
resources/views/backend/faqs/index.blade.php
View file @
60ce1613
...
...
@@ -39,7 +39,7 @@
<a class="
reset
-
data
" href="
javascript
:
void
(
0
)
"><i class="
fa
fa
-
times
"></i></a>
</th>
<th>
{!! Form::select('status',
$status
, null, ["
class
"
=>
"
search
-
input
-
select
form
-
control
", "
data
-
column
" => 2, "
placeholder
" => trans('labels.backend.faqs.table.all')]) !!}
{!! Form::select('status',
[1 => 'Active', 0 => 'InActive']
, null, ["
class
"
=>
"
search
-
input
-
select
form
-
control
", "
data
-
column
" => 2, "
placeholder
" => trans('labels.backend.faqs.table.all')]) !!}
</th>
{{-- <th></th> --}}
<th></th>
...
...
@@ -78,10 +78,10 @@
type: 'post'
},
columns: [
{data: 'question', name: '
{
{config('
access.faqs_
table')}}.question'
}
,
{data: 'answer', name: '
{
{config('
access.faqs_
table')}}.answer'
}
,
{data: 'status', name: '
{
{config('
access.faqs_
table')}}.status'
}
,
{data: 'updated_at', name: '
{
{config('
access.faqs_
table')}}.updated_at'
}
,
{data: 'question', name: '
{
{config('
module.faqs.
table')}}.question'
}
,
{data: 'answer', name: '
{
{config('
module.faqs.
table')}}.answer'
}
,
{data: 'status', name: '
{
{config('
module.faqs.
table')}}.status'
}
,
{data: 'updated_at', name: '
{
{config('
module.faqs.
table')}}.updated_at'
}
,
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[1, "
asc
"]],
...
...
routes/Backend/Faqs.php
View file @
60ce1613
...
...
@@ -10,5 +10,5 @@ Route::group(['namespace' => 'Faqs'], function () {
Route
::
post
(
'faqs/get'
,
'FaqsTableController'
)
->
name
(
'faqs.get'
);
// Status
Route
::
get
(
'faqs/{
id}/mark/{status}'
,
'FaqsController@mark
'
)
->
name
(
'faqs.mark'
)
->
where
([
'status'
=>
'[0,1]'
]);
Route
::
get
(
'faqs/{
faq}/mark/{status}'
,
'FaqStatusController@store
'
)
->
name
(
'faqs.mark'
)
->
where
([
'status'
=>
'[0,1]'
]);
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment