Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webprofile-jwg2024
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Siti Aisah
webprofile-jwg2024
Commits
acc65b55
Commit
acc65b55
authored
Jan 13, 2020
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
front download file
parent
ba184106
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
2 deletions
+148
-2
app/Http/Controllers/Webprofile/Front/DownloadController.php
+75
-0
app/Repositories/Webprofile/FileRepository.php
+19
-0
resources/views/webprofile/front/jollyany/download.blade.php
+52
-0
routes/webprofile/front.php
+2
-2
No files found.
app/Http/Controllers/Webprofile/Front/DownloadController.php
0 → 100644
View file @
acc65b55
<?php
namespace
App\Http\Controllers\Webprofile\Front
;
use
App\Http\Controllers\Controller
;
use
App\Models\Webprofile\Categories
;
use
App\Models\Webprofile\CategoriesFile
;
use
App\Models\Webprofile\Design
;
use
App\Models\Webprofile\File
;
use
App\Models\Webprofile\Menu
;
use
App\Models\Webprofile\Posts
;
use
App\Repositories\Webprofile\FileRepository
;
class
DownloadController
extends
Controller
{
public
function
index
()
{
$categoriesFile
=
CategoriesFile
::
where
(
'is_active'
,
1
)
->
orderBy
(
'created_at'
,
'DESC'
)
->
with
([
'rFile'
])
->
get
();
$setting
=
webprofilesetting
();
$menu
=
Menu
::
orderby
(
'urutan'
,
'asc'
)
->
get
();
$hot
=
Posts
::
where
(
'post_status'
,
'1'
)
->
orderby
(
'viewer'
,
'desc'
)
->
limit
(
'5'
)
->
get
();
$categories
=
Categories
::
where
(
'is_active'
,
'1'
)
->
get
();
$widget_right
=
Design
::
where
(
'name_design'
,
'widget_right'
)
->
orderBy
(
'urutan'
,
'ASC'
)
->
get
();
$widget_left
=
Design
::
where
(
'name_design'
,
'widget_left'
)
->
orderBy
(
'urutan'
,
'ASC'
)
->
get
();
$data
=
[
'categoriesFile'
=>
$categoriesFile
,
'setting'
=>
$setting
,
'menu'
=>
$menu
,
'hot'
=>
$hot
,
'categories'
=>
$categories
,
'widget_right'
=>
$widget_right
,
'widget_left'
=>
$widget_left
,
];
return
view
(
'webprofile.front.'
.
$setting
[
'theme'
]
.
'.download'
,
$data
);
}
public
function
downloadFile
(
$id
)
{
$setting
=
webprofilesetting
();
$fileModel
=
new
File
;
$fileRepo
=
new
FileRepository
(
$fileModel
);
$dbfile
=
$fileRepo
->
findId
(
$id
);
if
(
$setting
[
'external_storage'
]
==
1
)
{
$file
=
$setting
[
'url_static'
]
.
'/'
.
$setting
[
'directory'
]
.
'/file/'
.
$dbfile
->
file
;
}
else
{
$file
=
url
(
'/storage/file/'
.
$dbfile
->
file
);
}
// dd($file);
$fileRepo
->
countDownload
(
$dbfile
);
// if ($fileRepo->is_url_exist($file)) {
$filename
=
$dbfile
->
slug
;
$tempImage
=
tempnam
(
sys_get_temp_dir
(),
$filename
);
stream_context_set_default
([
'ssl'
=>
[
'verify_peer'
=>
false
,
'verify_peer_name'
=>
false
,
],
]);
copy
(
$file
,
$tempImage
);
return
response
()
->
download
(
$tempImage
,
$filename
);
// } else {
// Alert::error('File tidak ditemukan');
// return redirect()->back();
// }
}
}
app/Repositories/Webprofile/FileRepository.php
View file @
acc65b55
...
...
@@ -76,4 +76,23 @@ class FileRepository extends StorageRepository
->
rawColumns
([
'action'
,
'status'
,
'category'
,
'file'
,
'downloaded'
])
->
make
(
true
);
}
public
function
is_url_exist
(
$url
)
{
stream_context_set_default
([
'ssl'
=>
[
'verify_peer'
=>
false
,
'verify_peer_name'
=>
false
,
],
]);
$headers
=
get_headers
(
$url
);
return
stripos
(
$headers
[
0
],
"200 OK"
)
?
true
:
false
;
}
public
function
countDownload
(
File
$file
)
{
$file
->
downloaded
=
$file
->
downloaded
+
1
;
return
$file
->
save
();
}
}
resources/views/webprofile/front/jollyany/download.blade.php
0 → 100644
View file @
acc65b55
@
extends
(
'webprofile.front.jollyany.master'
)
@
section
(
'content'
)
<
section
class
="
post
-
wrapper
-
top
jt
-
shadow
clearfix
">
<div class="
container
">
<div class="
col
-
lg
-
12
">
<h2>Download</h2>
</div>
</div>
</section><!-- end post-wrapper-top -->
<section class="
blog
-
wrapper
">
<div class="
container
">
<div class="
row
">
<div id="
main
-
content
" class="
col
-
md
-
12
" role="
main
" align="
justify
">
<table class="
table
table
-
bordered
">
<thead>
<tr>
<th style="
width
:
5
%
;
">No</th>
<th>Nama Dokumen</th>
<th style="
width
:
15
%
;
">Tanggal Publikasi</th>
<th style="
width
:
10
%
;
">Option</th>
</tr>
</thead>
<tbody>
@foreach (
$categoriesFile
as
$value
)
<tr>
<td colspan="
4
" style="
font
-
weight
:
bold
;
">KATEGORI : {{
$value->name
}}</td>
</tr>
@php
$no
= 1;
@endphp
@foreach (
$value->rFile
as
$item
)
<tr>
<td style="
text
-
align
:
center
;
color
:
black
;
">{{
$no
++ }}</td>
<td style="
color
:
black
;
">{{
$item->title
}}</td>
<td style="
text
-
align
:
center
;
color
:
black
;
">{{ InseoHelper::tgl(
$item->created_at
) }}</td>
<td style="
text
-
align
:
center
;
">
<a href="
{{
url
(
'downloadlink/'
.
$item
->
id
)
}}
" class="
btn
btn
-
info
"><i class="
fa
fa
-
download
"> Download</i></a>
</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
</div>
</div>
</div><!-- end title -->
</div><!-- end container -->
</section><!--end white-wrapper -->
@endsection
routes/webprofile/front.php
View file @
acc65b55
...
...
@@ -8,6 +8,6 @@ Route::group(['namespace' => 'Webprofile\Front'], function () {
Route
::
get
(
'information/{id}'
,
'InformationController@index'
)
->
name
(
'infomation'
);
Route
::
get
(
'agenda'
,
'AgendaController@index'
)
->
name
(
'agenda'
);
Route
::
get
(
'error'
,
'ErrorController@index'
)
->
name
(
'error'
);
Route
::
get
(
'download'
,
'
FrontController@download
'
)
->
name
(
'download'
);
Route
::
get
(
'downloadlink/{data}'
,
'
Front
Controller@downloadFile'
)
->
name
(
'downloadFile'
);
Route
::
get
(
'download'
,
'
DownloadController@index
'
)
->
name
(
'download'
);
Route
::
get
(
'downloadlink/{data}'
,
'
Download
Controller@downloadFile'
)
->
name
(
'downloadFile'
);
});
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