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
9692f6b0
Commit
9692f6b0
authored
Dec 26, 2019
by
Aan Choesni Herlingga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Storage Repository update
parent
081a8ca9
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
134 additions
and
95 deletions
+134
-95
app/Http/Controllers/Webprofile/Backend/SliderController.php
+3
-3
app/Repositories/StorageRepository.php
+124
-0
app/Repositories/Webprofile/SliderRepository.php
+4
-89
database/migrations/2019_11_12_114437_create_sliders_table.php
+1
-1
resources/views/webprofile/backend/sliders/create.blade.php
+1
-1
resources/views/webprofile/backend/sliders/edit.blade.php
+1
-1
No files found.
app/Http/Controllers/Webprofile/Backend/SliderController.php
View file @
9692f6b0
...
@@ -48,7 +48,7 @@ class SliderController extends Controller
...
@@ -48,7 +48,7 @@ class SliderController extends Controller
*/
*/
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
)
{
{
$this
->
repo
->
store
(
$request
);
$this
->
repo
->
store
(
$request
,
'slider'
);
return
redirect
()
->
route
(
'sliders.index'
);
return
redirect
()
->
route
(
'sliders.index'
);
}
}
...
@@ -91,7 +91,7 @@ class SliderController extends Controller
...
@@ -91,7 +91,7 @@ class SliderController extends Controller
public
function
update
(
Request
$request
,
$id
)
public
function
update
(
Request
$request
,
$id
)
{
{
$slider
=
$this
->
repo
->
findId
(
$id
);
$slider
=
$this
->
repo
->
findId
(
$id
);
$edit
=
$this
->
repo
->
update
(
$request
,
$slider
);
$edit
=
$this
->
repo
->
update
(
$request
,
$slider
,
'slider'
);
return
redirect
()
->
route
(
'sliders.index'
);
return
redirect
()
->
route
(
'sliders.index'
);
}
}
...
@@ -105,7 +105,7 @@ class SliderController extends Controller
...
@@ -105,7 +105,7 @@ class SliderController extends Controller
public
function
destroy
(
$id
)
public
function
destroy
(
$id
)
{
{
$data
=
$this
->
repo
->
findId
(
$id
);
$data
=
$this
->
repo
->
findId
(
$id
);
$this
->
repo
->
destroy
(
$data
);
$this
->
repo
->
destroy
(
$data
,
'slider'
);
return
response
()
->
json
([
'done'
]);
return
response
()
->
json
([
'done'
]);
}
}
...
...
app/Repositories/StorageRepository.php
0 → 100644
View file @
9692f6b0
<?php
namespace
App\Repositories
;
use
Illuminate\Support\Str
;
use
Storage
;
abstract
class
StorageRepository
{
protected
$model
;
abstract
public
function
get
();
/**
* Display specified resource.
*
* @param varchar $with
* @param uuid $id
* @return \Illuminate\Http\Response
*/
public
function
findId
(
$id
=
null
,
$with
=
null
)
{
return
$this
->
model
->
when
(
$with
,
function
(
$query
)
use
(
$with
)
{
return
$query
->
with
(
$with
);
})
->
when
(
$id
,
function
(
$query
)
use
(
$id
)
{
return
$query
->
where
(
'id'
,
$id
);
})
->
first
();
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public
function
store
(
$request
,
$tipe
)
{
$setting
=
webprofilesetting
();
$data
=
$request
->
except
(
'_token'
);
$data
[
'id'
]
=
Str
::
uuid
()
->
toString
();
if
(
$request
->
hasFile
(
$tipe
))
{
$cover
=
$request
->
file
(
$tipe
);
$extension
=
$cover
->
guessClientExtension
();
$filename
=
$data
[
'id'
]
.
'.'
.
$extension
;
if
(
$setting
[
'external_storage'
]
==
1
)
{
Storage
::
disk
(
'storage'
)
->
put
(
$setting
[
'directory'
]
.
'/'
.
$tipe
.
'/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
}
else
{
Storage
::
disk
(
'local'
)
->
put
(
'public/'
.
$tipe
.
'/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
}
$data
[
$tipe
]
=
$filename
;
}
$request
[
'userid_created'
]
=
auth
()
->
user
()
->
id
;
return
$this
->
model
->
create
(
$data
);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param Model $model
* @return \Illuminate\Http\Response
*/
public
function
update
(
$request
,
$model
,
$tipe
)
{
$setting
=
webprofilesetting
();
$data
=
$request
->
except
(
'_token'
);
if
(
$request
->
hasFile
(
$tipe
))
{
$cover
=
$request
->
file
(
$tipe
);
$extension
=
$cover
->
guessClientExtension
();
$filename
=
$model
->
id
.
'.'
.
$extension
;
if
(
$setting
[
'external_storage'
]
==
1
)
{
Storage
::
disk
(
'storage'
)
->
put
(
$setting
[
'directory'
]
.
'/'
.
$tipe
.
'/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
}
else
{
Storage
::
disk
(
'local'
)
->
put
(
'public/'
.
$tipe
.
'/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
}
$data
[
$tipe
]
=
$filename
;
}
$data
[
'userid_updated'
]
=
auth
()
->
user
()
->
id
;
return
$model
->
update
(
$data
);
}
/**
* Show the specified resource in storage.
*
* @param uuid $id
* @return \Illuminate\Http\Response
*/
public
function
show
(
$id
)
{
return
$this
->
model
->
where
(
'user_id'
,
$id
)
->
first
();
}
/**
* Remove the specified resource from storage.
*
* @param Model $model
* @return \Illuminate\Http\Response
*/
public
function
destroy
(
$model
,
$tipe
)
{
$setting
=
webprofilesetting
();
if
(
$model
->
images
)
{
if
(
$setting
[
'external_storage'
]
==
1
)
{
Storage
::
disk
(
'storage'
)
->
delete
(
$setting
[
'directory'
]
.
'/'
.
$tipe
.
'/'
.
$model
->
images
);
}
else
{
Storage
::
disk
(
'local'
)
->
delete
(
'public/'
.
$tipe
.
'/'
.
$model
->
images
);
}
}
$model
->
delete
(
$model
->
id
);
}
}
app/Repositories/Webprofile/SliderRepository.php
View file @
9692f6b0
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
namespace
App\Repositories\Webprofile
;
namespace
App\Repositories\Webprofile
;
use
App\Models\Webprofile\Slider
;
use
App\Models\Webprofile\Slider
;
use
App\Repositories\Repository
;
use
App\Repositories\
Storage
Repository
;
use
Illuminate\Support\Str
;
use
Illuminate\Support\Str
;
use
DataTables
;
use
DataTables
;
use
Storage
;
use
Storage
;
class
SliderRepository
extends
Repository
class
SliderRepository
extends
Storage
Repository
{
{
protected
$model
;
protected
$model
;
...
@@ -32,91 +32,6 @@ class SliderRepository extends Repository
...
@@ -32,91 +32,6 @@ class SliderRepository extends Repository
->
get
();
->
get
();
}
}
/**
* Custom Store a newly created resource in Slider.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public
function
store
(
$request
)
{
$setting
=
webprofilesetting
();
$data
=
$request
->
except
(
'_token'
);
$data
[
'id'
]
=
Str
::
uuid
()
->
toString
();
if
(
$request
->
hasFile
(
'images'
))
{
$cover
=
$request
->
file
(
'images'
);
$extension
=
$cover
->
guessClientExtension
();
$filename
=
$data
[
'id'
]
.
'.'
.
$extension
;
if
(
$setting
[
'external_storage'
]
==
1
)
{
Storage
::
disk
(
'storage'
)
->
put
(
$setting
[
'directory'
]
.
'/slider/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
}
else
{
Storage
::
disk
(
'local'
)
->
put
(
'public/slider/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
}
$data
[
'images'
]
=
$filename
;
}
$request
[
'userid_created'
]
=
auth
()
->
user
()
->
id
;
return
$this
->
model
->
create
(
$data
);
}
/**
* Custom Update a resource in Slider.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public
function
update
(
$request
,
$sModel
)
{
$setting
=
webprofilesetting
();
$data
=
$request
->
except
(
'_token'
);
if
(
$request
->
hasFile
(
'images'
))
{
$cover
=
$request
->
file
(
'images'
);
$extension
=
$cover
->
guessClientExtension
();
$filename
=
$sModel
->
id
.
'.'
.
$extension
;
if
(
$setting
[
'external_storage'
]
==
1
)
{
Storage
::
disk
(
'storage'
)
->
put
(
$setting
[
'directory'
]
.
'/slider/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
}
else
{
Storage
::
disk
(
'local'
)
->
put
(
'public/slider/'
.
$filename
,
file_get_contents
(
$cover
->
getRealPath
()));
}
$data
[
'images'
]
=
$filename
;
}
$data
[
'userid_updated'
]
=
auth
()
->
user
()
->
id
;
return
$sModel
->
update
(
$data
);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Slider $slider
* @return \Illuminate\Http\Response
*/
public
function
destroy
(
$sModel
)
{
$setting
=
webprofilesetting
();
try
{
if
(
$sModel
->
images
)
{
if
(
$setting
[
'external_storage'
]
==
1
)
{
Storage
::
disk
(
'storage'
)
->
delete
(
$setting
[
'directory'
]
.
'/slider/'
.
$sModel
->
images
);
}
else
{
Storage
::
disk
(
'local'
)
->
delete
(
'public/slider/'
.
$sModel
->
images
);
}
}
$sModel
->
delete
(
$sModel
->
id
);
return
redirect
()
->
route
(
'sliders.index'
);
}
catch
(
\Exception
$id
)
{
return
redirect
()
->
route
(
'sliders.index'
);
}
}
public
function
datatable
(
$data
)
public
function
datatable
(
$data
)
{
{
$setting
=
webprofilesetting
();
$setting
=
webprofilesetting
();
...
@@ -134,9 +49,9 @@ class SliderRepository extends Repository
...
@@ -134,9 +49,9 @@ class SliderRepository extends Repository
})
})
->
addColumn
(
'slider'
,
function
(
$row
)
use
(
$setting
)
{
->
addColumn
(
'slider'
,
function
(
$row
)
use
(
$setting
)
{
if
(
$setting
[
'external_storage'
]
==
1
)
{
if
(
$setting
[
'external_storage'
]
==
1
)
{
$str
=
'<img src="'
.
$setting
[
'url_static'
]
.
'/'
.
$setting
[
'directory'
]
.
'/slider/'
.
$row
->
images
.
'" height="100" width="auto">'
;
$str
=
'<img src="'
.
$setting
[
'url_static'
]
.
'/'
.
$setting
[
'directory'
]
.
'/slider/'
.
$row
->
slider
.
'" height="100" width="auto">'
;
}
else
{
}
else
{
$str
=
'<img src="'
.
url
(
'/storage/slider/'
.
$row
->
images
)
.
'" height="100" width="auto">'
;
$str
=
'<img src="'
.
url
(
'/storage/slider/'
.
$row
->
slider
)
.
'" height="100" width="auto">'
;
}
}
return
$str
;
return
$str
;
...
...
database/migrations/2019_11_12_114437_create_sliders_table.php
View file @
9692f6b0
...
@@ -16,7 +16,7 @@ class CreateSlidersTable extends Migration
...
@@ -16,7 +16,7 @@ class CreateSlidersTable extends Migration
Schema
::
create
(
'swp_sliders'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'swp_sliders'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'id'
,
36
)
->
primary
();
$table
->
string
(
'id'
,
36
)
->
primary
();
$table
->
string
(
'title'
);
$table
->
string
(
'title'
);
$table
->
string
(
'
images
'
)
->
nullable
();
$table
->
string
(
'
slider
'
)
->
nullable
();
$table
->
text
(
'content'
)
->
nullable
();
$table
->
text
(
'content'
)
->
nullable
();
$table
->
boolean
(
'is_active'
)
->
nullable
();
$table
->
boolean
(
'is_active'
)
->
nullable
();
$table
->
string
(
'userid_created'
,
36
)
->
nullable
();
$table
->
string
(
'userid_created'
,
36
)
->
nullable
();
...
...
resources/views/webprofile/backend/sliders/create.blade.php
View file @
9692f6b0
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
<img id="
uploadPreview
" style="
width
:
500
px
;
height
:
100
%
;
" src="
{{
URL
::
to
(
'https://statik.unesa.ac.id/perpus_konten_statik/uploads/slider/slider.png'
)}}
"/><br>
<img id="
uploadPreview
" style="
width
:
500
px
;
height
:
100
%
;
" src="
{{
URL
::
to
(
'https://statik.unesa.ac.id/perpus_konten_statik/uploads/slider/slider.png'
)}}
"/><br>
</div>
</div>
<div class="
form
-
group
">
<div class="
form
-
group
">
{{ Form::file('
images
', ['class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>trans('label.upload'), 'onchange'=>'PreviewImage();', 'accept'=>'image/jpeg,image/png']) }}
{{ Form::file('
slider
', ['class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>trans('label.upload'), 'onchange'=>'PreviewImage();', 'accept'=>'image/jpeg,image/png']) }}
</div>
</div>
</center>
</center>
</div>
</div>
...
...
resources/views/webprofile/backend/sliders/edit.blade.php
View file @
9692f6b0
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
@endif
@endif
</div>
</div>
<div class="
form
-
group
">
<div class="
form
-
group
">
{{ Form::file('
images
', array('class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>'Upload', 'onchange'=>'PreviewImage();', 'accept'=>'image/jpeg,image/png')) }}
{{ Form::file('
slider
', array('class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>'Upload', 'onchange'=>'PreviewImage();', 'accept'=>'image/jpeg,image/png')) }}
</div>
</div>
</center>
</center>
</div>
</div>
...
...
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