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
c9fa7794
Commit
c9fa7794
authored
Jan 13, 2020
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix upload file on post master
parent
9d3db05f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
11 deletions
+60
-11
app/Http/Controllers/Webprofile/Backend/PostController.php
+24
-2
app/Repositories/Repository.php
+26
-7
app/Repositories/Webprofile/PostRepository.php
+2
-2
resources/views/webprofile/backend/posts/edit.blade.php
+8
-0
No files found.
app/Http/Controllers/Webprofile/Backend/PostController.php
View file @
c9fa7794
...
@@ -8,6 +8,7 @@ use App\Models\Webprofile\Categories;
...
@@ -8,6 +8,7 @@ use App\Models\Webprofile\Categories;
use
App\Repositories\Webprofile\En\PostRepository
as
EnPostRepository
;
use
App\Repositories\Webprofile\En\PostRepository
as
EnPostRepository
;
use
App\Repositories\Webprofile\PostRepository
;
use
App\Repositories\Webprofile\PostRepository
;
use
Statickidz\GoogleTranslate
;
use
Statickidz\GoogleTranslate
;
use
Illuminate\Support\Str
;
class
PostController
extends
Controller
class
PostController
extends
Controller
{
{
...
@@ -67,8 +68,17 @@ class PostController extends Controller
...
@@ -67,8 +68,17 @@ class PostController extends Controller
array_key_exists
(
'post_status'
,
$data
)
?
$data
[
'post_status'
]
=
1
:
$data
[
'post_status'
]
=
0
;
array_key_exists
(
'post_status'
,
$data
)
?
$data
[
'post_status'
]
=
1
:
$data
[
'post_status'
]
=
0
;
array_key_exists
(
'cover_status'
,
$data
)
?
$data
[
'cover_status'
]
=
1
:
$data
[
'cover_status'
]
=
0
;
array_key_exists
(
'cover_status'
,
$data
)
?
$data
[
'cover_status'
]
=
1
:
$data
[
'cover_status'
]
=
0
;
$data
[
'slug'
]
=
str_slug
(
$request
->
input
(
'title'
));
$save
=
$this
->
repo
->
store
(
$request
,
'thumbnail'
,
'off'
);
$save
=
$this
->
repo
->
store
(
$data
);
$tipe
=
'thumbnail'
;
if
(
$request
->
hasFile
(
$tipe
))
{
$img
[
$tipe
]
=
$save
->
id
.
'.'
.
$request
->
file
(
$tipe
)
->
guessClientExtension
();
$this
->
repo
->
upload
(
$img
[
$tipe
],
$request
,
$tipe
);
$this
->
repo
->
update
(
$img
,
$save
);
}
if
(
webprofilesetting
()[
'auto_translate'
]
==
1
)
{
if
(
webprofilesetting
()[
'auto_translate'
]
==
1
)
{
// save translate
// save translate
...
@@ -110,12 +120,14 @@ class PostController extends Controller
...
@@ -110,12 +120,14 @@ class PostController extends Controller
*/
*/
public
function
edit
(
$id
)
public
function
edit
(
$id
)
{
{
$setting
=
webprofilesetting
();
$data
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]);
$data
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]);
$categories
=
Categories
::
pluck
(
'name'
,
'id'
);
$categories
=
Categories
::
pluck
(
'name'
,
'id'
);
$data
=
[
$data
=
[
'data'
=>
$data
,
'data'
=>
$data
,
'categories'
=>
$categories
,
'categories'
=>
$categories
,
'setting'
=>
$setting
,
];
];
return
view
(
'webprofile.backend.posts.edit'
,
$data
)
->
withTitle
(
trans
(
'feature.edit_post'
));
return
view
(
'webprofile.backend.posts.edit'
,
$data
)
->
withTitle
(
trans
(
'feature.edit_post'
));
...
@@ -135,9 +147,18 @@ class PostController extends Controller
...
@@ -135,9 +147,18 @@ class PostController extends Controller
array_key_exists
(
'post_status'
,
$data
)
?
$data
[
'post_status'
]
=
1
:
$data
[
'post_status'
]
=
0
;
array_key_exists
(
'post_status'
,
$data
)
?
$data
[
'post_status'
]
=
1
:
$data
[
'post_status'
]
=
0
;
array_key_exists
(
'cover_status'
,
$data
)
?
$data
[
'cover_status'
]
=
1
:
$data
[
'cover_status'
]
=
0
;
array_key_exists
(
'cover_status'
,
$data
)
?
$data
[
'cover_status'
]
=
1
:
$data
[
'cover_status'
]
=
0
;
$data
[
'slug'
]
=
str_slug
(
$request
->
input
(
'title'
));
$post
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]);
$post
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]);
$edit
=
$this
->
repo
->
update
(
$request
,
$post
,
'thumbnail'
,
'off'
);
$edit
=
$this
->
repo
->
update
(
$data
,
$post
);
$tipe
=
'thumbnail'
;
if
(
$request
->
hasFile
(
$tipe
))
{
$img
[
$tipe
]
=
$post
->
id
.
'.'
.
$request
->
file
(
$tipe
)
->
guessClientExtension
();
$this
->
repo
->
upload
(
$img
[
$tipe
],
$request
,
$tipe
);
$this
->
repo
->
update
(
$img
,
$post
);
}
$this
->
updateEn
(
$dataEn
,
$post
);
$this
->
updateEn
(
$dataEn
,
$post
);
...
@@ -162,6 +183,7 @@ class PostController extends Controller
...
@@ -162,6 +183,7 @@ class PostController extends Controller
{
{
$data
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]);
$data
=
$this
->
repo
->
findId
(
$id
,
[
'rEn'
]);
$this
->
repo
->
destroy
(
$data
,
'thumbnail'
);
$this
->
repo
->
destroy
(
$data
,
'thumbnail'
);
$this
->
repo
->
deletefile
(
$data
,
'thumbnail'
);
if
(
$data
->
rEn
)
{
if
(
$data
->
rEn
)
{
$this
->
repoEn
->
destroy
(
$data
->
rEn
);
$this
->
repoEn
->
destroy
(
$data
->
rEn
);
...
...
app/Repositories/Repository.php
View file @
c9fa7794
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
namespace
App\Repositories
;
namespace
App\Repositories
;
use
Storage
;
abstract
class
Repository
abstract
class
Repository
{
{
protected
$model
;
protected
$model
;
...
@@ -74,18 +76,35 @@ abstract class Repository
...
@@ -74,18 +76,35 @@ abstract class Repository
return
$model
->
delete
();
return
$model
->
delete
();
}
}
public
function
upload
(
$name
,
$request
,
$tipe
,
$setting
)
public
function
upload
(
$name
,
$request
,
$tipe
)
{
{
if
(
$request
->
hasFile
(
$tipe
))
{
$setting
=
webprofilesetting
();
$cover
=
$request
->
file
(
$tipe
);
$cover
=
$request
->
file
(
$tipe
);
$extension
=
$cover
->
guessClientExtension
();
$filename
=
$name
.
'.'
.
$extension
;
if
(
$setting
[
'external_storage'
]
==
1
)
{
if
(
$setting
[
'external_storage'
]
==
1
)
{
Storage
::
disk
(
'storage'
)
->
put
(
$setting
[
'directory'
]
.
'/'
.
$tipe
.
'/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
Storage
::
disk
(
'storage'
)
->
put
(
$setting
[
'directory'
]
.
'/'
.
$tipe
.
'/'
.
$name
,
file_get_contents
(
$cover
->
getRealPath
()));
}
else
{
Storage
::
disk
(
'local'
)
->
put
(
'public/'
.
$tipe
.
'/'
.
$name
,
file_get_contents
(
$cover
->
getRealPath
()));
}
return
$name
;
}
/**
* Remove the specified resource from storage.
*
* @param Model $model
* @return \Illuminate\Http\Response
*/
public
function
deletefile
(
$model
,
$tipe
)
{
$setting
=
webprofilesetting
();
if
(
$model
->
$tipe
)
{
if
(
$setting
[
'external_storage'
]
==
1
)
{
Storage
::
disk
(
'storage'
)
->
delete
(
$setting
[
'directory'
]
.
'/'
.
$tipe
.
'/'
.
$model
->
$tipe
);
}
else
{
}
else
{
Storage
::
disk
(
'local'
)
->
put
(
'public/'
.
$tipe
.
'/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
())
);
Storage
::
disk
(
'local'
)
->
delete
(
'public/'
.
$tipe
.
'/'
.
$model
->
$tipe
);
}
}
return
$filename
;
}
}
}
}
}
}
app/Repositories/Webprofile/PostRepository.php
View file @
c9fa7794
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
namespace
App\Repositories\Webprofile
;
namespace
App\Repositories\Webprofile
;
use
App\Models\Webprofile\Posts
;
use
App\Models\Webprofile\Posts
;
use
App\Repositories\
Storage
Repository
;
use
App\Repositories\Repository
;
use
DataTables
;
use
DataTables
;
class
PostRepository
extends
Storage
Repository
class
PostRepository
extends
Repository
{
{
protected
$model
;
protected
$model
;
...
...
resources/views/webprofile/backend/posts/edit.blade.php
View file @
c9fa7794
...
@@ -135,7 +135,15 @@
...
@@ -135,7 +135,15 @@
<div class="
col
-
md
-
12
">
<div class="
col
-
md
-
12
">
<center>
<center>
<div class="
form
-
group
">
<div class="
form
-
group
">
@if (
$data->thumbnail
)
@if (
$setting['external_storage']
== 1)
<img id="
uploadPreview
" style="
width
:
200
px
;
height
:
100
%
;
" src="
{{
$setting
[
'url_static'
]
.
'/'
.
$setting
[
'directory'
]
.
'/thumbnail/'
.
$data
->
thumbnail
}}
"><br>
@else
<img id="
uploadPreview
" style="
width
:
200
px
;
height
:
100
%
;
" src="
{{
url
(
'/storage/thumbnail/'
.
$data
->
thumbnail
)
}}
"><br>
@endif
@else
<img id="
uploadPreview
" style="
width
:
200
px
;
height
:
100
%
;
" src="
https
://
statik
.
unesa
.
ac
.
id
/
profileunesa_konten_statik
/
images
/
preview
.
png
"/><br>
<img id="
uploadPreview
" style="
width
:
200
px
;
height
:
100
%
;
" src="
https
://
statik
.
unesa
.
ac
.
id
/
profileunesa_konten_statik
/
images
/
preview
.
png
"/><br>
@endif
</div>
</div>
<div class="
form
-
group
">
<div class="
form
-
group
">
{{ Form::file('thumbnail', array('class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>app('translator')->getFromJson('label.cover_image'), 'onchange'=>'PreviewImage();')) }}
{{ Form::file('thumbnail', array('class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>app('translator')->getFromJson('label.cover_image'), 'onchange'=>'PreviewImage();')) }}
...
...
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