Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header video #95

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/Controllers/HeaderImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public function store(Request $request)
$header_image = new HeaderImage($request->all());
$header_image->author()->associate($request->user());

if($request->hasFile($this->form_field_name)){
$header_image->type = explode('/',request()->{$this->form_field_name}->getMimeType())[0];
}

$this->uploadImage($header_image);

if ($header_image->save()) {
Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/Trait/UploadsImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function uploadImage($model): bool {
File::ensureDirectoryExists($model->getImageDirectory());
$img = request()->{$this->form_field_name}->store($this->getStrippedDirectoryPath($model));
$model->attachImage($img);
if (extension_loaded('gd')) {
if (extension_loaded('gd') && starts_with(request()->{$this->form_field_name}->getMimeType(), 'image/')) {
File::ensureDirectoryExists($model->getImageDirectory() . '/thumbs');
\Intervention\Image\ImageManagerStatic::make(storage_path($img))->fit(300, 200)->save($model->getThumbnailDirectory(). DIRECTORY_SEPARATOR . $model->image);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Model/HeaderImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HeaderImage extends Model {
* @var array
*/
protected $fillable = [
'title', 'link' ,'description', 'image', 'active',
'title', 'type' ,'link' ,'description', 'image', 'active',
];

}
4 changes: 0 additions & 4 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],

'Illuminate\Auth\Events\Login' => [
'\App\Listeners\UserEventListener@countLogin',
],
Expand Down
38 changes: 31 additions & 7 deletions app/View/media/header_images.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@
<span class='fa fa-pencil' aria-hidden='true'
style=' font-size: 1.4em;z-index:15;top:3px;right:3px;margin-bottom:-15px;'></span>
</a>

@if($each->type === 'video')
<video controls width='100%' height='75%;' style="object-fit:cover;">
<source src="storage/images/header_images/{{ $each->image }}" >
Your browser does not support the video tag.
</video>
@else
<img src='storage/images/header_images/{{ $each->image }}' alt=''
class='card-img-top' width='100%' height='75%;' style="object-fit:cover;">
@endif

<div class="card-body text-black">
<h5 class="card-title">{{ $each->title }}</h5>
<h5 class="card-title">{{ $each->title }}<small> | {{$each->type}}</small></h5>
</div>
<ul class="list-group list-group-flush mb-3">
<a class='btn btn-danger btn-xs btn-block'
Expand Down Expand Up @@ -175,10 +184,17 @@ class='btn btn-primary'>{{ trans('actions.save') }}</button>
</div>
</div>
</div>
@if($each->type === 'video')
<video controls width='100%' height='75%;' style="object-fit:cover;">
<source src="storage/images/header_images/{{ $each->image }}" >
Your browser does not support the video tag.
</video>
@else
<img src='storage/images/header_images/{{ $each->image }}' alt=''
class='card-img-top' width='100%' height='75%;' style="object-fit:cover;">
@endif
<div class="card-body text-black">
<h5 class="card-title">{{ $each->title }}</h5>
<h5 class="card-title">{{ $each->title }}<small> | {{$each->type}}</small></h5>
</div>
</div>

Expand All @@ -205,13 +221,21 @@ class='card-img-top' width='100%' height='75%;' style="object-fit:cover;">
</div>
<div class="mb-3">
<div class="row">
<div class="col-11">
<div class="col-9">
<label for="header-image-image"
class="form-label">Image</label>
class="form-label">Media</label>
<input type="text" class="form-control disabled"
id="header-image-title" value="{{ $each->getImage() }}"
disabled>

</div>
<div class="col-2">
<label for="header-image-image"
class="form-label">Media</label>
<input type="text" class="form-control disabled"
id="header-image-type" value="{{ $each->type }}"
disabled>

</div>
<div class="col-1">
<label for="header-image-image"
Expand Down Expand Up @@ -277,7 +301,7 @@ class='btn btn-primary'>{{ trans('actions.save') }}</button>

<div class='modal upload_images' id='create_file' tabindex='-1' role='dialog'
aria-labelledby='myModalLabel' aria-hidden='true'>
<div class='modal-dialog modal-xl'>
<div class='modal-dialog modal-xl p-5'>
<div class='modal-content'>
<div class='modal-header modal-header-primary bg-primary'>
<h4 class='modal-title text-white'>Upload images</h4>
Expand All @@ -288,8 +312,8 @@ class='btn btn-primary'>{{ trans('actions.save') }}</button>
<div class='modal-body'>
@csrf
<div class='form-group'>
<label for='file'>Upload file:</label>
<input name='up_file' id='input-2' type='file' class='file' accept="image/*"
<label for='file'>Upload file</label>
<input name='up_file' id='input-2' type='file' class='file' accept="image/*, video/*"
multiple='true' data-show-upload='false' data-show-caption='true' required>
</div>
<div class="mb-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function up()
Schema::create($this->table_name, function (Blueprint $table) {
$table->increments('id');
$table->string('title')->nullable();
$table->string('type')->nullable();
$table->string('link')->nullable();
$table->text('description')->nullable();
$table->string('image');
Expand Down
1 change: 1 addition & 0 deletions database/seeders/ContentSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function run()
DB::table('header_images')->insert([
'id' => 1,
'title' => 'default',
'type' => 'image',
'image' => 'abovethecity.jpg',
'author_id' => 1,
'active' => 1
Expand Down
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"webpack-cli": "^5.0.2"
},
"dependencies": {
"@eonasdan/tempus-dominus": "^6.9.11",
"@popperjs/core": "^2.11.6",
"@vue/compiler-sfc": "^3.2.37",
"@vue/composition-api": "^1.7.0",
Expand Down
4 changes: 4 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
return response()->json(['error'=>'Username or password incorrect'], 401);
});

Route::get('/blogposts/slug/{slug}', function($slug){
$blogpost = \App\Model\Blogpost::findBySlug($slug);
return response()->json($blogpost);
});

Route::apiResource('blogposts', \App\Controllers\BlogpostController::class)
->only(['index', 'show']);
Expand Down
Loading