Skip to content

Commit

Permalink
ajustes
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Tamagawa committed Apr 10, 2017
1 parent 8f07a43 commit 6c4efa2
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 394 deletions.
8 changes: 0 additions & 8 deletions .idea/Newsletters.iml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/blade.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

266 changes: 0 additions & 266 deletions .idea/workspace.xml

This file was deleted.

66 changes: 24 additions & 42 deletions src/Http/Controllers/NewslettersAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ public function index(Request $request)
($trash) ? $query->onlyTrashed() : '';

$search = [];
$search['name'] = $request->input('name', '');
if(config('mnewsletters.fields.name') !== false) {
$search['name'] = $request->input('name', '');
}
$search['email'] = $request->input('email', '');

($search['name']) ? $query->where('name', 'LIKE', '%' . $search['name'] . '%') : '';
if(config('mnewsletters.fields.name') !== false) {
($search['name']) ? $query->where('name', 'LIKE', '%' . $search['name'] . '%') : '';
}
($search['email']) ? $query->where('email', 'LIKE', '%' . $search['email'] . '%') : '';

$newsletters = $query->paginate(50);
Expand All @@ -37,40 +41,6 @@ public function index(Request $request)
return view('mixdinternet/newsletters::admin.index', $view);
}

public function create(Newsletter $newsletter)
{
$view['newsletter'] = $newsletter;
return view('mixdinternet/newsletters::admin.form', $view);
}

public function store(CreateEditNewslettersRequest $request)
{
if (Newsletter::create($request->all())) {
Flash::success('Item inserido com sucesso.');
} else {
Flash::error('Falha no cadastro.');
}

return ($url = session()->get('backUrl')) ? redirect($url) : redirect()->route('admin.newsletters.index');
}

public function edit(Newsletter $newsletter)
{
$view['newsletter'] = $newsletter;
return view('mixdinternet/newsletters::admin.form', $view);
}

public function update(Newsletter $newsletter, CreateEditNewslettersRequest $request)
{
if ($newsletter->update($request->all())) {
Flash::success('Item atualizado com sucesso.');
} else {
Flash::error('Falha na atualização.');
}

return ($url = session()->get('backUrl')) ? redirect($url) : redirect()->route('admin.newsletters.index');
}

public function destroy(Request $request)
{
if (Newsletter::destroy($request->input('id'))) {
Expand Down Expand Up @@ -104,10 +74,13 @@ public function download(Request $request)
$query = Newsletter::sort();

$search = [];
$search['name'] = $request->input('name', '');
if(config('mnewsletters.fields.name') !== false) {
$search['name'] = $request->input('name', '');
}
$search['email'] = $request->input('email', '');

($search['name']) ? $query->where('name', 'LIKE', '%' . $search['name'] . '%') : '';
if(config('mnewsletters.fields.name') !== false) {
($search['name']) ? $query->where('name', 'LIKE', '%' . $search['name'] . '%') : '';
}
($search['email']) ? $query->where('email', 'LIKE', '%' . $search['email'] . '%') : '';

$newsletters = $query->paginate(50);
Expand All @@ -119,12 +92,21 @@ public function download(Request $request)
$nameFile = "leads".$user_id.$date.".csv";

$csv = '';
$csv .= "\"nome\";\"email\";\"data de cadastro\"\n";
if(config('mnewsletters.fields.name') !== false) {
$csv .= "\"nome\";\"email\";\"data de cadastro\"\n";

foreach($newsletters as $row) {
$csv .= "\"".$row['name']."\";\"".$row['email']."\";\"".Carbon::parse($row['created_at'])->format('d/m/Y H:i')."\"\n";
foreach ($newsletters as $row) {
$csv .= "\"" . $row['name'] . "\";\"" . $row['email'] . "\";\"" . Carbon::parse($row['created_at'])->format('d/m/Y H:i') . "\"\n";
}
}

if(config('mnewsletters.fields.name') == false){
$csv .= "\"email\";\"data de cadastro\"\n";

foreach ($newsletters as $row) {
$csv .= "\"" . $row['email'] . "\";\"" . Carbon::parse($row['created_at'])->format('d/m/Y H:i') . "\"\n";
}
}
$arquivo = $nameFile;
// Configurações header para forçar o download
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Expand Down
11 changes: 0 additions & 11 deletions src/Http/helpers.php

This file was deleted.

32 changes: 0 additions & 32 deletions src/resources/views/admin/form.blade.php

This file was deleted.

25 changes: 12 additions & 13 deletions src/resources/views/admin/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
@endsection

@section('btn-insert')
{{-- @if((!checkRule('admin.newsletters.create')) && (!$trash))
@include('mixdinternet/admix::partials.actions.btn.insert', ['route' => route('admin.newsletters.create')])
@endif
--}}
@if((!checkRule('admin.newsletters.trash')) && (!$trash))
@include('mixdinternet/admix::partials.actions.btn.trash', ['route' => route('admin.newsletters.trash')])
@endif
Expand All @@ -27,9 +23,11 @@
{!! Form::model($search, ['route' => ($trash) ? 'admin.newsletters.trash' : 'admin.newsletters.index', 'method' => 'get', 'id' => 'form-search'
, 'class' => '']) !!}
<div class="row">
<div class="col-md-4">
{!! BootForm::text('name', 'Nome') !!}
</div>
@if(config('mnewsletters.fields.name') !== false)
<div class="col-md-4">
{!! BootForm::text('name', 'Nome') !!}
</div>
@endif
<div class="col-md-4">
{!! BootForm::text('email', 'Email') !!}
</div>
Expand All @@ -38,7 +36,7 @@
<div class="row">
<div class="col-md-12">
<div class="pull-right">
<a href="/admix/newsletters/download{{ getQueryString(Request::fullUrl()) }}" class="btn btn-default btn-flat" >
<a href="/admix/newsletters/download?{{ http_build_query($search) }}" class="btn btn-default btn-flat" >
<i class="fa fa-download"></i>
<i class="fs-normal hidden-xs texto-download">Download</i>
</a>
Expand Down Expand Up @@ -72,7 +70,9 @@ class="btn btn-default btn-flat">
</th>
@endif
<th>{!! columnSort('#', ['field' => 'id', 'sort' => 'asc']) !!}</th>
<th>{!! columnSort('Nome', ['field' => 'name', 'sort' => 'asc']) !!}</th>
@if(config('mnewsletters.fields.name') !== false)
<th>{!! columnSort('Nome', ['field' => 'name', 'sort' => 'asc']) !!}</th>
@endif
<th>{!! columnSort('Email', ['field' => 'email', 'sort' => 'asc']) !!}</th>
<th>{!! columnSort('Data de cadastro', ['field' => 'created_at', 'sort' => 'asc']) !!}</th>
<th></th>
Expand All @@ -87,13 +87,12 @@ class="btn btn-default btn-flat">
</td>
@endif
<td>{{ $newsletter->id }}</td>
<td>{{ $newsletter->name }}</td>
@if (config('mnewsletters.fields.name') !== false)
<td>{{ $newsletter->name }}</td>
@endif
<td>{{ $newsletter->email }}</td>
<td>{{ $newsletter->created_at->format('d/m/Y') }}</td>
<td>
{{-- !!} @if((!checkRule('admin.newsletters.edit')) && (!$trash))
@include('mixdinternet/admix::partials.actions.btn.edit', ['route' => route('admin.newsletters.edit', $newsletter->id)])
@endif --}}
@if((!checkRule('admin.newsletters.destroy')) && (!$trash))
@include('mixdinternet/admix::partials.actions.btn.delete', ['route' => route('admin.newsletters.destroy'), 'id' => $newsletter->id])
@endif
Expand Down
3 changes: 2 additions & 1 deletion src/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Route::group(['middleware' => ['auth.admin', 'auth.rules']], function () {
Route::get('newsletters/trash', ['uses' => 'NewslettersAdminController@index', 'as' => '.trash']);
Route::post('newsletters/restore/{id}', ['uses' => 'NewslettersAdminController@restore', 'as' => '.restore']);
Route::get('newsletters/download', ['uses' => 'NewslettersAdminController@download', 'as' => '.download']);
Route::resource('newsletters', 'NewslettersAdminController', [
'names' => [
'index' => '.index',
Expand All @@ -14,7 +15,7 @@
], 'except' => ['destroy']
]);
Route::delete('newsletters/destroy', ['uses' => 'NewslettersAdminController@destroy', 'as' => '.destroy']);
Route::get('newsletters/download', ['uses' => 'NewslettersAdminController@download', 'as' => '.download']);

});

});

0 comments on commit 6c4efa2

Please sign in to comment.