94 lines
6.2 KiB
PHP
94 lines
6.2 KiB
PHP
<?php
|
||
|
||
namespace Modules\Blog\database\seeders;
|
||
|
||
use Carbon\Carbon;
|
||
use Illuminate\Support\Str;
|
||
use Illuminate\Database\Seeder;
|
||
use Modules\Blog\app\Models\Blog;
|
||
use Illuminate\Support\Facades\Storage;
|
||
|
||
class BlogDatabaseSeeder extends Seeder
|
||
{
|
||
/**
|
||
* Run the database seeds.
|
||
*/
|
||
public function run(): void
|
||
{
|
||
$blogs = [
|
||
[
|
||
'title' => 'How to Reach Benagil Cave in 2023, Algarve, Portugal (Tours + Kayaking + tips)',
|
||
'content' => "Algarve’s Benagil Cave beach is one of those extra special ones. The only way in is by kayaking or paddle boating, which obviously adds a more elusive touch to this already amazing place.
|
||
didn’t know already, the Algarve region is in the South of Portugal and is a lovely coastal area. The thing that makes the Algarve coastline unique is the stunning rock formations. They are everywhere and are mindblowing. I spent a week in Lagos and then a week in Carvoeiro – both these places are in the Algarve and are stunning.
|
||
In Portuguese, the Benagil Cave is called Algar de Benagil. The holes in the rock formations are called algares (or holes) and there are many of them. I did mention in my Seven Hanging Valleys post that there’s a hike that goes on top of the cliff inside which this cave is situated. You can see the holes in these cliffs from the top.
|
||
This post is about the best way of getting inside the cave from the water. Actually, there are many caves in this short stretch and they are collectively called the Benagil Caves, but in this post, we will mostly talk about the most famous Benagil Cave one with a hidden sandy beach. THIS one (below).",
|
||
'author' => 'Jhigu CMS Travel & Tour',
|
||
'summary' => 'Algarve’s Benagil Cave beach is one of those extra special ones. The only way in is by kayaking or paddle boating, which obviously adds a more elusive touch to this already amazing place',
|
||
'published_date' => Carbon::now(),
|
||
'image' => 'b1.jpg',
|
||
'slug' => "Slug for blog",
|
||
],
|
||
[
|
||
'title' => 'The Ultimate Italy Road Trip: 2 Weeks Itinerary (with Amalfi Coast)',
|
||
'content' => "The first time I visited Italy, it was just North Italy. We landed in Venice and drove to Trentino in our rental car. The second time was in South Italy where we spent one entire month in Puglia. We actually drove from Germany to Puglia but realized it would have been easier to just fly to Bari or Brindisi and drive a rental car from there.
|
||
For the purpose of travel, it is important to understand what are the regions of Italy. You can pick and choose some of them or get a taste of them all. Here are the regions in Italy that you can visit –
|
||
Northeast Italy, (the Dolomites, Trentino, Venice and Bologna)
|
||
Northwest Italy, (Cinque Terre, Milan and the Alps)
|
||
Central Italy, (Tuscany region and Rome)
|
||
Southern Italy, (Naples, Puglia, Amalfi and Capri)
|
||
The islands – Sicily and Sardinia.
|
||
If you ever see the list of the most visited countries in the world, Italy usually is in top 5 year after year. It is because there is so much to see & experience in every single region of
|
||
Keep in mind that to properly explore each region of Italy, you would probably need at least two weeks each. However, this itinerary focuses on the entire Italy, so I will help you move from one region to another and tell you the best of each. That’s the difference between a region-specific itinerary and a country-specific itinerary.
|
||
Matera in Puglia, Italy road trip two weeks itinerary – via Pixabay
|
||
If you think you will get to visit Italy multiple times, then by all means pick just one region or maximum two for each trip. If you’re going to visit Italy just once or twice in your life then I suggest you visit more than just 2 regions because they all have something to offer.
|
||
on’t try to cover it all, it isn’t possible to do so. Instead, pick a few destinations and spend some quality time in each place that you visit so that you don’t feel rushed or drained out.",
|
||
'author' => 'Jhigu CMS Travel & Tour',
|
||
'summary' => 'Algarve’s Benagil Cave beach is one of those extra special ones. The only way in is by kayaking or paddle boating, which obviously adds a more elusive touch to this already amazing place',
|
||
'published_date' => Carbon::now(),
|
||
'image' => 'b2.jpg',
|
||
'slug' => "Slug for blog",
|
||
]
|
||
];
|
||
foreach ($blogs as $blog) {
|
||
$cmsblog = Blog::create([
|
||
'uuid' => Str::uuid(),
|
||
'title' => $blog['title'],
|
||
'content' => $blog['content'],
|
||
'author' => $blog['author'],
|
||
'summary' => $blog['summary'],
|
||
'published_date' => $blog['published_date'],
|
||
'slug' => $blog['slug'],
|
||
]);
|
||
|
||
// Add image to the created banner
|
||
$this->uploadImageForBlog($blog['image'], $cmsblog);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
private function uploadImageForBlog(string $imageFileName, $cmsbanner)
|
||
{
|
||
$seederDirPath = 'Blogs/';
|
||
|
||
// Generate a unique filename for the new image
|
||
$newFileName = Str::uuid() . '.jpg';
|
||
|
||
// Storage path for the new image
|
||
$storagePath = '/blogs/' . $newFileName;
|
||
|
||
// Check if the image exists in the seeder_disk
|
||
if (Storage::disk('seeder_disk')->exists($seederDirPath . $imageFileName)) {
|
||
// Copy the image from seeder to public
|
||
$fileContents = Storage::disk('seeder_disk')->get($seederDirPath . $imageFileName);
|
||
|
||
Storage::disk('public_uploads')->put($storagePath, $fileContents);
|
||
|
||
$cmsbanner->image = $newFileName;
|
||
$cmsbanner->image_path = $storagePath;
|
||
$cmsbanner->save();
|
||
}
|
||
}
|
||
|
||
}
|