-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,55 @@ | |
|
||
namespace Database\Seeds\Components\Wiki; | ||
|
||
use Carbon\Carbon; | ||
use App\Models\Wiki; | ||
use Illuminate\Database\Seeder; | ||
|
||
/** | ||
* @author Zeeshan Ahmed <[email protected]> | ||
*/ | ||
class WikisTableSeeder extends Seeder | ||
{ | ||
/** | ||
* Path to wikis.json file. | ||
* | ||
* @var string | ||
*/ | ||
private $wikisFilePath = 'database\seeds\Components\Wiki\wikis.json'; | ||
|
||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
// | ||
$wikis = $this->getWikis(); | ||
|
||
foreach ($wikis as $wiki) { | ||
Wiki::insert([ | ||
'name' => $wiki['name'], | ||
'slug' => str_slug($wiki['name'], '_'), | ||
'outline' => $wiki['outline'], | ||
'description' => $wiki['description'], | ||
'user_id' => $wiki['user_id'], | ||
'space_id' => $wiki['space_id'], | ||
'team_id' => $wiki['team_id'], | ||
'created_at' => Carbon::now(), | ||
'updated_at' => Carbon::now() | ||
]); | ||
} | ||
} | ||
|
||
/** | ||
* Get the wikis from json file. | ||
* | ||
* @return array $wikis | ||
*/ | ||
private function getWikis() | ||
{ | ||
$wikis = file_get_contents(base_path($this->wikisFilePath)); | ||
|
||
return json_decode($wikis, true); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters