Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
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
Platform
Commits
5abd4e02
Commit
5abd4e02
authored
Nov 06, 2018
by
Silvio Gratani
Browse files
Options
Browse Files
Download
Plain Diff
merge master
parents
639c2744
a475153c
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
208 additions
and
97 deletions
+208
-97
BaseRepository.php
Modules/Core/Repositories/BaseRepository.php
+16
-0
BaseCacheDecorator.php
Modules/Core/Repositories/Cache/BaseCacheDecorator.php
+19
-0
EloquentBaseRepository.php
...les/Core/Repositories/Eloquent/EloquentBaseRepository.php
+23
-0
MediaList.vue
Modules/Media/Assets/js/components/MediaList.vue
+72
-59
UploadZone.vue
Modules/Media/Assets/js/components/UploadZone.vue
+59
-34
media.php
Modules/Translation/Resources/lang/media/en/media.php
+1
-0
SentinelAuthentication.php
...les/User/Repositories/Sentinel/SentinelAuthentication.php
+4
-4
module-service-provider.stub
...rkshop/Scaffold/Module/stubs/module-service-provider.stub
+14
-0
No files found.
Modules/Core/Repositories/BaseRepository.php
View file @
5abd4e02
...
@@ -99,6 +99,22 @@ interface BaseRepository
...
@@ -99,6 +99,22 @@ interface BaseRepository
*/
*/
public
function
clearCache
();
public
function
clearCache
();
/**
* Add where statement to current builder
*
* @param string $field
* @param string|int $value
* @param string $operator
*/
public
function
where
(
string
$field
,
$value
,
string
$operator
=
null
);
/**
* Eager relationship(s) loading
*
* @param array|string $relationships
*/
public
function
with
(
$relationships
);
/**
/**
* @param string $field
* @param string $field
* @param array $values
* @param array $values
...
...
Modules/Core/Repositories/Cache/BaseCacheDecorator.php
View file @
5abd4e02
...
@@ -228,5 +228,24 @@ abstract class BaseCacheDecorator implements BaseRepository
...
@@ -228,5 +228,24 @@ abstract class BaseCacheDecorator implements BaseRepository
public
function
whereIn
(
string
$field
,
array
$values
)
public
function
whereIn
(
string
$field
,
array
$values
)
{
{
return
$this
->
repository
->
whereIn
(
$field
,
$values
);
return
$this
->
repository
->
whereIn
(
$field
,
$values
);
/**
* @inheritdoc
*/
public
function
where
(
string
$field
,
$value
,
string
$operator
=
null
)
{
return
$this
->
remember
(
function
()
use
(
$field
,
$value
,
$operator
)
{
return
$this
->
repository
->
where
(
$field
,
$value
,
$operator
);
});
}
/**
* @inheritdoc
*/
public
function
with
(
$relationships
)
{
return
$this
->
remember
(
function
()
use
(
$relationships
)
{
return
$this
->
repository
->
with
(
$relationships
);
});
}
}
}
}
Modules/Core/Repositories/Eloquent/EloquentBaseRepository.php
View file @
5abd4e02
...
@@ -192,6 +192,28 @@ abstract class EloquentBaseRepository implements BaseRepository
...
@@ -192,6 +192,28 @@ abstract class EloquentBaseRepository implements BaseRepository
return
true
;
return
true
;
}
}
/**
* @inheritdoc
*/
public
function
where
(
string
$field
,
$value
,
string
$operator
=
null
)
{
if
(
$operator
===
null
)
{
$operator
=
'='
;
}
else
{
list
(
$value
,
$operator
)
=
[
$operator
,
$value
];
}
return
$this
->
model
->
where
(
$field
,
$operator
,
$value
);
}
/**
* @inheritdoc
*/
public
function
with
(
$relationships
)
{
return
$this
->
model
->
with
(
$relationships
);
}
/**
/**
* @param string $field
* @param string $field
* @param array $values
* @param array $values
...
@@ -200,4 +222,5 @@ abstract class EloquentBaseRepository implements BaseRepository
...
@@ -200,4 +222,5 @@ abstract class EloquentBaseRepository implements BaseRepository
{
{
return
$this
->
model
->
whereIn
(
$field
,
$values
);
return
$this
->
model
->
whereIn
(
$field
,
$values
);
}
}
}
}
Modules/Media/Assets/js/components/MediaList.vue
View file @
5abd4e02
This diff is collapsed.
Click to expand it.
Modules/Media/Assets/js/components/UploadZone.vue
View file @
5abd4e02
<
template
>
<
template
>
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
<el-upload
<el-upload
class=
"media-upload"
class=
"media-upload"
drag
drag
:action=
"uploadUrl"
:action=
"uploadUrl"
:on-preview=
"handlePreview"
list-type=
"picture"
:on-remove=
"handleRemove"
:show-file-list=
"false"
:on-success=
"handleSuccess"
:http-request=
"uploadFile"
:file-list=
"fileList"
multiple
:headers=
"requestHeaders"
>
multiple
>
<i
class=
"el-icon-upload"
></i>
<i
class=
"el-icon-upload"
></i>
<div
class=
"el-upload__text"
>
Drop file here or
<em>
click to upload
</em></div>
<div
class=
"el-upload__text"
>
Drop file here or
<em>
click to upload
</em></div>
</el-upload>
</el-upload>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
axios
from
'
axios
'
;
export
default
{
export
default
{
props
:
{
parentId
:
{
type
:
Number
},
},
data
()
{
data
()
{
return
{
return
{
file
List
:
[]
,
file
IsUploading
:
false
,
};
};
},
},
computed
:
{
computed
:
{
uploadUrl
()
{
uploadUrl
()
{
return
route
(
'
api.media.store
'
).
domain
+
route
(
'
api.media.store
'
).
url
;
return
route
(
'
api.media.store
'
).
domain
+
route
(
'
api.media.store
'
).
url
;
},
},
requestHeaders
()
{
const
userApiToken
=
document
.
head
.
querySelector
(
'
meta[name="user-api-token"]
'
);
return
{
Authorization
:
`Bearer
${
userApiToken
.
content
}
`
,
};
},
},
},
methods
:
{
methods
:
{
handleSuccess
(
response
)
{
uploadFile
(
event
)
{
this
.
fileIsUploading
=
true
;
const
data
=
new
FormData
();
data
.
append
(
'
parent_id
'
,
this
.
parentId
);
data
.
append
(
'
file
'
,
event
.
file
);
axios
.
post
(
route
(
'
api.media.store
'
),
data
).
then
((
response
)
=>
{
this
.
$events
.
emit
(
'
fileWasUploaded
'
,
response
);
this
.
$events
.
emit
(
'
fileWasUploaded
'
,
response
);
this
.
fileList
=
[];
this
.
$message
({
type
:
'
success
'
,
message
:
this
.
trans
(
'
media.file uploaded
'
),
});
this
.
fileIsUploading
=
false
;
},
(
error
)
=>
{
console
.
log
(
error
.
response
.
data
);
this
.
fileIsUploading
=
false
;
this
.
$notify
.
error
({
title
:
'
Error
'
,
message
:
error
.
response
.
data
.
errors
.
file
[
0
],
});
});
},
},
handlePreview
()
{},
handleRemove
()
{},
},
},
mounted
()
{},
};
};
</
script
>
</
script
>
<
style
>
<
style
>
.media-upload
{
margin-bottom
:
10px
;
}
.el-upload__input
{
.el-upload__input
{
display
:
none
!important
;
display
:
none
!important
;
}
}
.el-upload--text
{
display
:
block
;
.el-upload--picture
,
.el-upload--picture-card
{
width
:
100%
;
height
:
175px
;
line-height
:
100px
;
border
:
none
;
}
}
.el-upload-dragger
{
.el-upload-dragger
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
}
}
.media-upload
{
margin-bottom
:
10px
;
.el-upload-dragger
.el-upload__text
{
position
:
absolute
;
bottom
:
0
;
width
:
100%
;
}
.el-upload--text
{
display
:
block
;
}
}
</
style
>
</
style
>
Modules/Translation/Resources/lang/media/en/media.php
View file @
5abd4e02
...
@@ -38,6 +38,7 @@ return [
...
@@ -38,6 +38,7 @@ return [
'create resource'
=>
'Create media'
,
'create resource'
=>
'Create media'
,
'edit resource'
=>
'Edit media'
,
'edit resource'
=>
'Edit media'
,
'destroy resource'
=>
'Delete media'
,
'destroy resource'
=>
'Delete media'
,
'file uploaded'
=>
'File uploaded successfully'
,
'file too large'
=>
'File is too large. Must be below :size MB.'
,
'file too large'
=>
'File is too large. Must be below :size MB.'
,
'some files not moved'
=>
'Some files were not moved'
,
'some files not moved'
=>
'Some files were not moved'
,
'files moved successfully'
=>
'Files moved successfully'
,
'files moved successfully'
=>
'Files moved successfully'
,
...
...
Modules/User/Repositories/Sentinel/SentinelAuthentication.php
View file @
5abd4e02
...
@@ -123,7 +123,7 @@ class SentinelAuthentication implements Authentication
...
@@ -123,7 +123,7 @@ class SentinelAuthentication implements Authentication
* @param $permission
* @param $permission
* @return bool
* @return bool
*/
*/
public
function
hasAccess
(
$permission
)
public
function
hasAccess
(
$permission
)
:
bool
{
{
if
(
!
Sentinel
::
check
())
{
if
(
!
Sentinel
::
check
())
{
return
false
;
return
false
;
...
@@ -136,7 +136,7 @@ class SentinelAuthentication implements Authentication
...
@@ -136,7 +136,7 @@ class SentinelAuthentication implements Authentication
* Check if the user is logged in
* Check if the user is logged in
* @return bool
* @return bool
*/
*/
public
function
check
()
public
function
check
()
:
bool
{
{
$user
=
Sentinel
::
check
();
$user
=
Sentinel
::
check
();
...
@@ -153,14 +153,14 @@ class SentinelAuthentication implements Authentication
...
@@ -153,14 +153,14 @@ class SentinelAuthentication implements Authentication
*/
*/
public
function
user
()
public
function
user
()
{
{
return
Sentinel
::
check
();
return
Sentinel
::
getUser
();
}
}
/**
/**
* Get the ID for the currently authenticated user
* Get the ID for the currently authenticated user
* @return int
* @return int
*/
*/
public
function
id
()
public
function
id
()
:
int
{
{
$user
=
$this
->
user
();
$user
=
$this
->
user
();
...
...
Modules/Workshop/Scaffold/Module/stubs/module-service-provider.stub
View file @
5abd4e02
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
Modules
\
$MODULE
$
\Providers
;
namespace
Modules
\
$MODULE
$
\Providers
;
use
Illuminate\Database\Eloquent\Factory
as
EloquentFactory
;
use
Illuminate\Support\ServiceProvider
;
use
Illuminate\Support\ServiceProvider
;
use
Modules\Core\Traits\CanPublishConfiguration
;
use
Modules\Core\Traits\CanPublishConfiguration
;
use
Modules\Core\Events\BuildingSidebar
;
use
Modules\Core\Events\BuildingSidebar
;
...
@@ -31,6 +32,8 @@ class $MODULE$ServiceProvider extends ServiceProvider
...
@@ -31,6 +32,8 @@ class $MODULE$ServiceProvider extends ServiceProvider
$this
->
app
[
'events'
]
->
listen
(
LoadingBackendTranslations
::
class
,
function
(
LoadingBackendTranslations
$event
)
{
$this
->
app
[
'events'
]
->
listen
(
LoadingBackendTranslations
::
class
,
function
(
LoadingBackendTranslations
$event
)
{
// append translations
// append translations
});
});
$this
->
registerEloquentFactoriesFrom
(
__DIR__
.
'/../Database/factories'
);
}
}
public
function
boot
()
public
function
boot
()
...
@@ -54,4 +57,15 @@ class $MODULE$ServiceProvider extends ServiceProvider
...
@@ -54,4 +57,15 @@ class $MODULE$ServiceProvider extends ServiceProvider
{
{
// add bindings
// add bindings
}
}
/**
* Register factories.
*
* @param string $path
* @return void
*/
protected
function
registerEloquentFactoriesFrom
(
$path
)
{
$this
->
app
->
make
(
EloquentFactory
::
class
)
->
load
(
$path
);
}
}
}
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