mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-05 01:24:38 +08:00
Laravel 8 shift squash & merge (#3029)
* Temporarily moved back config path * Apply Laravel coding style * Shift exception handler * Shift HTTP kernel and middleware * Shift service providers * Convert options array to fluent methods * Shift to class based routes * Shift console routes * Ignore temporary framework files * Shift to class based factories * Namespace seeders * Shift PSR-4 autoloading * Shift config files * Default config files * Shift Laravel dependencies * Shift return type of base TestCase methods * Shift cleanup * Applied stylci style changes * Reverted config files location * Applied manual changes to Laravel 8 shift Co-authored-by: Shift <shift@laravelshift.com>
This commit is contained in:
32
database/factories/Actions/CommentFactory.php
Normal file
32
database/factories/Actions/CommentFactory.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Actions;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class CommentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Actions\Comment::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$text = $this->faker->paragraph(1);
|
||||
$html = '<p>' . $text . '</p>';
|
||||
|
||||
return [
|
||||
'html' => $html,
|
||||
'text' => $text,
|
||||
'parent_id' => null,
|
||||
];
|
||||
}
|
||||
}
|
28
database/factories/Actions/TagFactory.php
Normal file
28
database/factories/Actions/TagFactory.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Actions;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class TagFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Actions\Tag::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->city,
|
||||
'value' => $this->faker->sentence(3),
|
||||
];
|
||||
}
|
||||
}
|
28
database/factories/Auth/RoleFactory.php
Normal file
28
database/factories/Auth/RoleFactory.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class RoleFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Auth\Role::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'display_name' => $this->faker->sentence(3),
|
||||
'description' => $this->faker->sentence(10),
|
||||
];
|
||||
}
|
||||
}
|
35
database/factories/Auth/UserFactory.php
Normal file
35
database/factories/Auth/UserFactory.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Auth\User::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$name = $this->faker->name;
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'email' => $this->faker->email,
|
||||
'slug' => \Illuminate\Support\Str::slug($name . '-' . \Illuminate\Support\Str::random(5)),
|
||||
'password' => Str::random(10),
|
||||
'remember_token' => Str::random(10),
|
||||
'email_confirmed' => 1,
|
||||
];
|
||||
}
|
||||
}
|
30
database/factories/Entities/Models/BookFactory.php
Normal file
30
database/factories/Entities/Models/BookFactory.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BookFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Entities\Models\Book::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $this->faker->paragraph,
|
||||
];
|
||||
}
|
||||
}
|
30
database/factories/Entities/Models/BookshelfFactory.php
Normal file
30
database/factories/Entities/Models/BookshelfFactory.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BookshelfFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Entities\Models\Bookshelf::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $this->faker->paragraph,
|
||||
];
|
||||
}
|
||||
}
|
30
database/factories/Entities/Models/ChapterFactory.php
Normal file
30
database/factories/Entities/Models/ChapterFactory.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ChapterFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Entities\Models\Chapter::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $this->faker->paragraph,
|
||||
];
|
||||
}
|
||||
}
|
34
database/factories/Entities/Models/PageFactory.php
Normal file
34
database/factories/Entities/Models/PageFactory.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Entities\Models\Page::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$html = '<p>' . implode('</p>', $this->faker->paragraphs(5)) . '</p>';
|
||||
|
||||
return [
|
||||
'name' => $this->faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'html' => $html,
|
||||
'text' => strip_tags($html),
|
||||
'revision_count' => 1,
|
||||
];
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of your model factories. Model factories give
|
||||
| you a convenient way to create models for testing and seeding your
|
||||
| database. Just tell the factory how a default model should look.
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(\BookStack\Auth\User::class, function ($faker) {
|
||||
$name = $faker->name;
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'email' => $faker->email,
|
||||
'slug' => \Illuminate\Support\Str::slug($name . '-' . \Illuminate\Support\Str::random(5)),
|
||||
'password' => Str::random(10),
|
||||
'remember_token' => Str::random(10),
|
||||
'email_confirmed' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Models\Bookshelf::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Models\Book::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Models\Chapter::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Models\Page::class, function ($faker) {
|
||||
$html = '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>';
|
||||
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'html' => $html,
|
||||
'text' => strip_tags($html),
|
||||
'revision_count' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Auth\Role::class, function ($faker) {
|
||||
return [
|
||||
'display_name' => $faker->sentence(3),
|
||||
'description' => $faker->sentence(10),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Actions\Tag::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->city,
|
||||
'value' => $faker->sentence(3),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Uploads\Image::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->slug . '.jpg',
|
||||
'url' => $faker->url,
|
||||
'path' => $faker->url,
|
||||
'type' => 'gallery',
|
||||
'uploaded_to' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Actions\Comment::class, function ($faker) {
|
||||
$text = $faker->paragraph(1);
|
||||
$html = '<p>' . $text . '</p>';
|
||||
|
||||
return [
|
||||
'html' => $html,
|
||||
'text' => $text,
|
||||
'parent_id' => null,
|
||||
];
|
||||
});
|
31
database/factories/Uploads/ImageFactory.php
Normal file
31
database/factories/Uploads/ImageFactory.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Uploads;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ImageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Uploads\Image::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->slug . '.jpg',
|
||||
'url' => $this->faker->url,
|
||||
'path' => $this->faker->url,
|
||||
'type' => 'gallery',
|
||||
'uploaded_to' => 0,
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user