File: /mnt/data/ghayatcom/ghayatcom-api/database/seeders/BlogSeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Category;
use App\SubCategory;
use App\Blog;
class BlogSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$datas = [
1 => [
'name' => 'Nutrition',
'created_by' => 1
],
2 => [
'name' => 'Mind & Mood',
'created_by' => 1
],
];
foreach ($datas as $id => $data) {
$row = Category::firstOrNew([
'id' => $id,
]);
$row->fill($data);
$row->save();
}
$datas = [
1 => [
'category_id' => 1,
'name' => 'Nutritional Recommendation',
'created_by' => 1
],
2 => [
'category_id' => 2,
'name' => 'Protecting Memory',
'created_by' => 1
],
3 => [
'category_id' => 1,
'name' => 'Heart Health',
'created_by' => 1
],
];
foreach ($datas as $id => $data) {
$row = SubCategory::firstOrNew([
'id' => $id,
]);
$row->fill($data);
$row->save();
}
$datas = [
1 => [
'user_id' => 1,
'category_id' => 1,
'sub_category_id' => 1,
'title' => 'Are certain fruits healthier than others?',
'description' => 'Most people have heard the nutritional recommendation to eat five servings of fruit per day. But are some fruits better for you than others? Is it okay to eat dried or frozen fruit, or to drink fruit juice? Does it have to be organic?',
'blog_image' => 'blog_1.jpg',
'content' => 'Just like other foods, different fruits have different nutrient values. Generally, whole fruits are good sources of fiber while fruit juices are not. And one cup of fruit juice, even 100% fruit juice, has a lot more sugar than one piece or one serving of whole fruit. In addition, whole fruits are more satiating than juices. When meeting the recommended fruit and vegetable intake, it is better to eat them (whole) than drink them (juice). However, one should not completely avoid drinking juice — if it is 100% juice — but you should limit consumption to no more than 4 to 8 ounces a day.
The freezer section of the grocery store is often stocked with quite a variety of frozen fruits. These are often peeled and cut already (like mango), which is convenient and often less expensive than fresh fruits. Frozen fruits are usually picked and quick-frozen near the point of harvest, therefore the nutrients are well preserved. Moreover, some seasonal fruits such as blueberries are readily available in frozen form. The key to selection is to choose plain frozen fruits without added sugar.',
'created_by' => 1
],
2 => [
'user_id' => 1,
'category_id' => 2,
'sub_category_id' => 2,
'title' => 'Can flavonoids help fend off forgetfulness?',
'description' => 'Eating a broad variety of fruits and vegetables is a good way to get a sufficient intake of flavonoids, chemicals that contribute to many aspects of health. Now, a study suggests that flavonoid-rich foods may also play a role in protecting memory and thinking as people get older.',
'blog_image' => 'blog_2.jpg',
'content' => 'Just like other foods, different fruits have different nutrient values. Generally, whole fruits are good sources of fiber while fruit juices are not. And one cup of fruit juice, even 100% fruit juice, has a lot more sugar than one piece or one serving of whole fruit. In addition, whole fruits are more satiating than juices. When meeting the recommended fruit and vegetable intake, it is better to eat them (whole) than drink them (juice). However, one should not completely avoid drinking juice — if it is 100% juice — but you should limit consumption to no more than 4 to 8 ounces a day.
The freezer section of the grocery store is often stocked with quite a variety of frozen fruits. These are often peeled and cut already (like mango), which is convenient and often less expensive than fresh fruits. Frozen fruits are usually picked and quick-frozen near the point of harvest, therefore the nutrients are well preserved. Moreover, some seasonal fruits such as blueberries are readily available in frozen form. The key to selection is to choose plain frozen fruits without added sugar.',
'created_by' => 1
],
3 => [
'user_id' => 1,
'category_id' => 1,
'sub_category_id' => 3,
'title' => 'When the doctor becomes the patient: A transformative experience',
'description' => 'A doctor’s serious health threat prompts reflection on the power of spirituality, the value of mindfulness practice, and acknowledgment of mortality as a motivator to reassess one’s priorities.',
'blog_image' => 'blog_3.jpg',
'content' => 'Just like other foods, different fruits have different nutrient values. Generally, whole fruits are good sources of fiber while fruit juices are not. And one cup of fruit juice, even 100% fruit juice, has a lot more sugar than one piece or one serving of whole fruit. In addition, whole fruits are more satiating than juices. When meeting the recommended fruit and vegetable intake, it is better to eat them (whole) than drink them (juice). However, one should not completely avoid drinking juice — if it is 100% juice — but you should limit consumption to no more than 4 to 8 ounces a day.
The freezer section of the grocery store is often stocked with quite a variety of frozen fruits. These are often peeled and cut already (like mango), which is convenient and often less expensive than fresh fruits. Frozen fruits are usually picked and quick-frozen near the point of harvest, therefore the nutrients are well preserved. Moreover, some seasonal fruits such as blueberries are readily available in frozen form. The key to selection is to choose plain frozen fruits without added sugar.',
'created_by' => 1
],
];
foreach ($datas as $id => $data) {
$row = Blog::firstOrNew([
'id' => $id,
]);
$row->fill($data);
$row->save();
}
}
}