Upgrade to Laravel 8
This commit is contained in:
parent
1ad58f10c5
commit
57186c3e2e
27 changed files with 952 additions and 1010 deletions
|
|
@ -37,16 +37,6 @@ class ShortURLsController extends Controller
|
||||||
return redirect('https://twitter.com/jonnybarnes');
|
return redirect('https://twitter.com/jonnybarnes');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Redirect from '/+' to a Google+ profile.
|
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
|
||||||
*/
|
|
||||||
public function googlePlus(): RedirectResponse
|
|
||||||
{
|
|
||||||
return redirect('https://plus.google.com/u/0/117317270900655269082/about');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect a short url of this site out to a long one based on post type.
|
* Redirect a short url of this site out to a long one based on post type.
|
||||||
* Further redirects may happen.
|
* Further redirects may happen.
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ namespace App\Models;
|
||||||
use App\Traits\FilterHtml;
|
use App\Traits\FilterHtml;
|
||||||
use Eloquent;
|
use Eloquent;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
@ -37,6 +38,7 @@ use Mf2;
|
||||||
class Like extends Model
|
class Like extends Model
|
||||||
{
|
{
|
||||||
use FilterHtml;
|
use FilterHtml;
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = ['url'];
|
protected $fillable = ['url'];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ namespace App\Models;
|
||||||
use Eloquent;
|
use Eloquent;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
@ -33,6 +34,8 @@ use Illuminate\Support\Carbon;
|
||||||
*/
|
*/
|
||||||
class MicropubClient extends Model
|
class MicropubClient extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The table associated with the model.
|
* The table associated with the model.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use Eloquent;
|
||||||
use Exception;
|
use Exception;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Database\Eloquent\Relations\{BelongsTo, BelongsToMany, HasMany, MorphMany};
|
use Illuminate\Database\Eloquent\Relations\{BelongsTo, BelongsToMany, HasMany, MorphMany};
|
||||||
use Illuminate\Database\Eloquent\{Builder, Collection, Model, SoftDeletes};
|
use Illuminate\Database\Eloquent\{Builder, Collection, Factories\HasFactory, Model, SoftDeletes};
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Jonnybarnes\IndieWeb\Numbers;
|
use Jonnybarnes\IndieWeb\Numbers;
|
||||||
|
|
@ -88,6 +88,7 @@ use Spatie\CommonMarkHighlighter\{FencedCodeRenderer, IndentedCodeRenderer};
|
||||||
*/
|
*/
|
||||||
class Note extends Model
|
class Note extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
use Searchable;
|
use Searchable;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace App\Models;
|
||||||
use Cviebrock\EloquentSluggable\Sluggable;
|
use Cviebrock\EloquentSluggable\Sluggable;
|
||||||
use Eloquent;
|
use Eloquent;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\{Builder, Collection, Model};
|
use Illuminate\Database\Eloquent\{Builder, Collection, Factories\HasFactory, Model};
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
|
@ -51,6 +51,7 @@ use Illuminate\Support\Str;
|
||||||
*/
|
*/
|
||||||
class Place extends Model
|
class Place extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
use Sluggable;
|
use Sluggable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Cache\RateLimiting\Limit;
|
||||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
class RouteServiceProvider extends ServiceProvider
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
|
@ -12,9 +15,9 @@ class RouteServiceProvider extends ServiceProvider
|
||||||
*
|
*
|
||||||
* In addition, it is set as the URL generator's root namespace.
|
* In addition, it is set as the URL generator's root namespace.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
protected $namespace = 'App\Http\Controllers';
|
// protected $namespace = 'App\Http\Controllers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define your route model bindings, pattern filters, etc.
|
* Define your route model bindings, pattern filters, etc.
|
||||||
|
|
@ -23,51 +26,29 @@ class RouteServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
//
|
$this->configureRateLimiting();
|
||||||
|
|
||||||
parent::boot();
|
$this->routes(function () {
|
||||||
|
Route::prefix('api')
|
||||||
|
->middleware('api')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/api.php'));
|
||||||
|
|
||||||
|
Route::middleware('web')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/web.php'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the routes for the application.
|
* Configure the rate limiters for the application.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function map()
|
protected function configureRateLimiting()
|
||||||
{
|
{
|
||||||
$this->mapApiRoutes();
|
RateLimiter::for('api', function (Request $request) {
|
||||||
|
return Limit::perMinute(60);
|
||||||
$this->mapWebRoutes();
|
});
|
||||||
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the "web" routes for the application.
|
|
||||||
*
|
|
||||||
* These routes all receive session state, CSRF protection, etc.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function mapWebRoutes()
|
|
||||||
{
|
|
||||||
Route::middleware('web')
|
|
||||||
->namespace($this->namespace)
|
|
||||||
->group(base_path('routes/web.php'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the "api" routes for the application.
|
|
||||||
*
|
|
||||||
* These routes are typically stateless.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function mapApiRoutes()
|
|
||||||
{
|
|
||||||
Route::prefix('api')
|
|
||||||
->middleware('api')
|
|
||||||
->namespace($this->namespace)
|
|
||||||
->group(base_path('routes/api.php'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "jonnybarnes/jonnybarnes.uk",
|
"name": "jonnybarnes/jonnybarnes.uk",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"description": "The code for jonnybarnes.uk, based on Laravel 5.8",
|
"description": "The code for jonnybarnes.uk, based on Laravel 8",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"framework",
|
"framework",
|
||||||
"laravel",
|
"laravel",
|
||||||
|
|
@ -13,18 +13,18 @@
|
||||||
"ext-intl": "*",
|
"ext-intl": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"cviebrock/eloquent-sluggable": "~7.0",
|
"cviebrock/eloquent-sluggable": "^8.0",
|
||||||
"fideloper/proxy": "~4.0",
|
"fideloper/proxy": "~4.0",
|
||||||
"guzzlehttp/guzzle": "~6.0",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
"indieauth/client": "~0.1",
|
"indieauth/client": "~0.1",
|
||||||
"intervention/image": "^2.4",
|
"intervention/image": "^2.4",
|
||||||
"jonnybarnes/indieweb": "~0.2",
|
"jonnybarnes/indieweb": "~0.2",
|
||||||
"jonnybarnes/webmentions-parser": "~0.5",
|
"jonnybarnes/webmentions-parser": "~0.5",
|
||||||
"jublonet/codebird-php": "4.0.0-beta.1",
|
"jublonet/codebird-php": "4.0.0-beta.1",
|
||||||
"laravel/framework": "^7.0",
|
"laravel/framework": "^8.0",
|
||||||
"laravel/horizon": "^4.0",
|
"laravel/horizon": "^5.0",
|
||||||
"laravel/scout": "^8.0",
|
"laravel/scout": "^8.0",
|
||||||
"laravel/telescope": "^3.0",
|
"laravel/telescope": "^4.0",
|
||||||
"laravel/tinker": "^2.0",
|
"laravel/tinker": "^2.0",
|
||||||
"lcobucci/jwt": "^3.1",
|
"lcobucci/jwt": "^3.1",
|
||||||
"league/commonmark": "^1.0",
|
"league/commonmark": "^1.0",
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
"mf2/mf2": "~0.3",
|
"mf2/mf2": "~0.3",
|
||||||
"pmatseykanets/laravel-scout-postgres": "^7.0",
|
"pmatseykanets/laravel-scout-postgres": "^7.0",
|
||||||
"predis/predis": "~1.0",
|
"predis/predis": "~1.0",
|
||||||
"ramsey/uuid": "^3.5",
|
|
||||||
"sensiolabs/security-checker": "^6.0",
|
"sensiolabs/security-checker": "^6.0",
|
||||||
"spatie/browsershot": "~3.0",
|
"spatie/browsershot": "~3.0",
|
||||||
"spatie/commonmark-highlighter": "^2.0",
|
"spatie/commonmark-highlighter": "^2.0",
|
||||||
|
|
@ -42,11 +41,11 @@
|
||||||
"barryvdh/laravel-debugbar": "^3.0",
|
"barryvdh/laravel-debugbar": "^3.0",
|
||||||
"barryvdh/laravel-ide-helper": "^2.6",
|
"barryvdh/laravel-ide-helper": "^2.6",
|
||||||
"beyondcode/laravel-dump-server": "^1.0",
|
"beyondcode/laravel-dump-server": "^1.0",
|
||||||
"facade/ignition": "^2.0",
|
"facade/ignition": "^2.3.6",
|
||||||
"fzaninotto/faker": "^1.9.1",
|
"fzaninotto/faker": "^1.9.1",
|
||||||
"laravel/dusk": "^6.0",
|
"laravel/dusk": "^6.0",
|
||||||
"mockery/mockery": "^1.0",
|
"mockery/mockery": "^1.0",
|
||||||
"nunomaduro/collision": "^4.1",
|
"nunomaduro/collision": "^5.0",
|
||||||
"phpunit/phpunit": "^9.0",
|
"phpunit/phpunit": "^9.0",
|
||||||
"vimeo/psalm": "^3.9"
|
"vimeo/psalm": "^3.9"
|
||||||
},
|
},
|
||||||
|
|
@ -62,12 +61,10 @@
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\": "app/"
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
},
|
},
|
||||||
"classmap": [
|
|
||||||
"database/seeds",
|
|
||||||
"database/factories"
|
|
||||||
],
|
|
||||||
"files": [
|
"files": [
|
||||||
"helpers.php"
|
"helpers.php"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
1286
composer.lock
generated
1286
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,12 +1,35 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Bookmark;
|
namespace Database\Factories;
|
||||||
use Faker\Generator as Faker;
|
|
||||||
|
|
||||||
$factory->define(Bookmark::class, function (Faker $faker) {
|
use App\Models\Bookmark;
|
||||||
return [
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
'url' => $faker->url,
|
use Illuminate\Support\Carbon;
|
||||||
'name' => $faker->sentence,
|
|
||||||
'content' => $faker->text,
|
class BookmarkFactory extends Factory
|
||||||
];
|
{
|
||||||
});
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = Bookmark::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
$now = Carbon::now()->subDays(rand(5, 15));
|
||||||
|
|
||||||
|
return [
|
||||||
|
'url' => $this->faker->url,
|
||||||
|
'name' => $this->faker->sentence,
|
||||||
|
'content' => $this->faker->text,
|
||||||
|
'created_at' => $now->toDateTimeString(),
|
||||||
|
'updated_at' => $now->toDateTimeString(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Like;
|
namespace Database\Factories;
|
||||||
use Faker\Generator as Faker;
|
|
||||||
|
|
||||||
$factory->define(Like::class, function (Faker $faker) {
|
use App\Models\Like;
|
||||||
return [
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
'url' => $faker->url,
|
use Illuminate\Support\Carbon;
|
||||||
'author_name' => $faker->name,
|
|
||||||
'author_url' => $faker->url,
|
class LikeFactory extends Factory
|
||||||
'content' => '<html><body><div class="h-entry"><div class="e-content">' . $faker->realtext() . '</div></div></body></html>',
|
{
|
||||||
];
|
/**
|
||||||
});
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = Like::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
$now = Carbon::now()->subDays(rand(5, 15));
|
||||||
|
|
||||||
|
return [
|
||||||
|
'url' => $this->faker->url,
|
||||||
|
'author_name' => $this->faker->name,
|
||||||
|
'author_url' => $this->faker->url,
|
||||||
|
'content' => '<html><body><div class="h-entry"><div class="e-content">' . $this->faker->realtext() . '</div></div></body></html>',
|
||||||
|
'created_at' => $now->toDateTimeString(),
|
||||||
|
'updated_at' => $now->toDateTimeString(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
29
database/factories/MicropubClientFactory.php
Normal file
29
database/factories/MicropubClientFactory.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\MicropubClient;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class MicropubClientFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = MicropubClient::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'client_url' => $this->faker->url,
|
||||||
|
'client_name' => $this->faker->company,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,14 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use Faker\Generator as Faker;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
$factory->define(Note::class, function (Faker $faker) {
|
class NoteFactory extends Factory
|
||||||
$now = Carbon::now()->subDays(rand(5, 15));
|
{
|
||||||
return [
|
/**
|
||||||
'note' => $faker->paragraph,
|
* The name of the factory's corresponding model.
|
||||||
'created_at' => $now,
|
*
|
||||||
'updated_at' => $now,
|
* @var string
|
||||||
];
|
*/
|
||||||
});
|
protected $model = Note::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
$now = Carbon::now()->subDays(rand(5, 15));
|
||||||
|
|
||||||
|
return [
|
||||||
|
'note' => $this->faker->paragraph,
|
||||||
|
'created_at' => $now,
|
||||||
|
'updated_at' => $now,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
32
database/factories/PlaceFactory.php
Normal file
32
database/factories/PlaceFactory.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\Place;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class PlaceFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = Place::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => $this->faker->company,
|
||||||
|
'description' => $this->faker->sentence,
|
||||||
|
'latitude' => $this->faker->latitude,
|
||||||
|
'longitude' => $this->faker->longitude,
|
||||||
|
'external_urls' => $this->faker->url,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,28 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Tag;
|
namespace Database\Factories;
|
||||||
use Faker\Generator as Faker;
|
|
||||||
|
|
||||||
$factory->define(Tag::class, function (Faker $faker) {
|
use App\Models\Tag;
|
||||||
return [
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
'tag' => $faker->word,
|
|
||||||
];
|
class TagFactory extends Factory
|
||||||
});
|
{
|
||||||
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = Tag::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'tag' => $this->faker->word,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Faker\Generator as Faker;
|
|
||||||
|
|
||||||
/*
|
class UserFactory extends Factory
|
||||||
|--------------------------------------------------------------------------
|
{
|
||||||
| Model Factories
|
/**
|
||||||
|--------------------------------------------------------------------------
|
* The name of the factory's corresponding model.
|
||||||
|
|
*
|
||||||
| This directory should contain each of the model factory definitions for
|
* @var string
|
||||||
| your application. Factories provide a convenient way to generate new
|
*/
|
||||||
| model instances for testing / seeding your application's database.
|
protected $model = User::class;
|
||||||
|
|
|
||||||
*/
|
|
||||||
$factory->define(App\Models\User::class, function (Faker $faker) {
|
|
||||||
static $password;
|
|
||||||
|
|
||||||
return [
|
/**
|
||||||
'name' => mb_strtolower($faker->firstName),
|
* Define the model's default state.
|
||||||
'password' => $password ?: $password = bcrypt('secret'),
|
*
|
||||||
'remember_token' => Str::random(10),
|
* @return array
|
||||||
];
|
*/
|
||||||
});
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => $this->faker->name,
|
||||||
|
'password' => bcrypt('password'),
|
||||||
|
'remember_token' => Str::random(10),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
60
database/seeders/ArticlesTableSeeder.php
Normal file
60
database/seeders/ArticlesTableSeeder.php
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Article;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class ArticlesTableSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$now = Carbon::now()->subMonth();
|
||||||
|
$articleFirst = Article::create([
|
||||||
|
'title' => 'My New Blog',
|
||||||
|
'main' => 'This is *my* new blog. It uses `Markdown`.',
|
||||||
|
'published' => 1,
|
||||||
|
'created_at' => $now,
|
||||||
|
]);
|
||||||
|
DB::table('articles')
|
||||||
|
->where('id', $articleFirst->id)
|
||||||
|
->update(['updated_at' => $now->toDateTimeString()]);
|
||||||
|
|
||||||
|
$now = Carbon::now()->subHours(2)->subMinutes(25);
|
||||||
|
$articleWithCode = <<<EOF
|
||||||
|
I wrote some code.
|
||||||
|
|
||||||
|
I liked writing this:
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
echo 'Foo class constructed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
EOF;
|
||||||
|
$articleSecond = Article::create([
|
||||||
|
'title' => 'Some code I did',
|
||||||
|
'main' => $articleWithCode,
|
||||||
|
'published' => 1,
|
||||||
|
'created_at' => $now,
|
||||||
|
]);
|
||||||
|
DB::table('articles')
|
||||||
|
->where('id', $articleSecond->id)
|
||||||
|
->update(['updated_at' => $now->toDateTimeString()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
database/seeders/BookmarksTableSeeder.php
Normal file
32
database/seeders/BookmarksTableSeeder.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use App\Models\{Bookmark, Tag};
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class BookmarksTableSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
Bookmark::factory(10)->create();
|
||||||
|
factory(Bookmark::class, 10)->create()->each(function ($bookmark) {
|
||||||
|
$bookmark->tags()->save(factory(Tag::class)->make());
|
||||||
|
|
||||||
|
$now = Carbon::now()->subDays(rand(2, 12));
|
||||||
|
DB::table('bookmarks')
|
||||||
|
->where('id', $bookmark->id)
|
||||||
|
->update([
|
||||||
|
'created_at' => $now->toDateTimeString(),
|
||||||
|
'updated_at' => $now->toDateTimeString(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
35
database/seeders/ClientsTableSeeder.php
Normal file
35
database/seeders/ClientsTableSeeder.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\MicropubClient;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class ClientsTableSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
DB::table('clients')->insert([
|
||||||
|
'client_url' => 'https://jbl5.dev/notes/new',
|
||||||
|
'client_name' => 'JBL5',
|
||||||
|
'created_at' => '2016-01-12 16:03:00',
|
||||||
|
'updated_at' => '2016-01-12 16:03:00',
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::table('clients')->insert([
|
||||||
|
'client_url' => 'https://beta.indigenous.abode.pub/ios/',
|
||||||
|
'client_name' => 'https://beta.indigenous.abode.pub/ios/',
|
||||||
|
'created_at' => Carbon::now()->toDateTimeString(),
|
||||||
|
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
MicropubClient::factory(5)->create();
|
||||||
|
}
|
||||||
|
}
|
||||||
39
database/seeders/ContactsTableSeeder.php
Normal file
39
database/seeders/ContactsTableSeeder.php
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Contact;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\FileSystem\FileSystem;
|
||||||
|
|
||||||
|
class ContactsTableSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
Contact::create([
|
||||||
|
'nick' => 'tantek',
|
||||||
|
'name' => 'Tantek Çelik',
|
||||||
|
'homepage' => 'http://tantek.com',
|
||||||
|
'twitter' => 't',
|
||||||
|
]);
|
||||||
|
Contact::create([
|
||||||
|
'nick' => 'aaron',
|
||||||
|
'name' => 'Aaron Parecki',
|
||||||
|
'homepage' => 'https://aaronparecki.com',
|
||||||
|
'facebook' => '123456',
|
||||||
|
]);
|
||||||
|
$fs = new FileSystem();
|
||||||
|
if (!$fs->exists(public_path('assets/profile-images/aaronparecki.com'))) {
|
||||||
|
$fs->makeDirectory(public_path('assets/profile-images/aaronparecki.com'));
|
||||||
|
}
|
||||||
|
$fs->copy(
|
||||||
|
base_path('tests/aaron.png'),
|
||||||
|
public_path('assets/profile-images/aaronparecki.com/image')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
database/seeders/DatabaseSeeder.php
Normal file
26
database/seeders/DatabaseSeeder.php
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$this->call(ArticlesTableSeeder::class);
|
||||||
|
$this->call(ClientsTableSeeder::class);
|
||||||
|
$this->call(ContactsTableSeeder::class);
|
||||||
|
$this->call(PlacesTableSeeder::class);
|
||||||
|
$this->call(NotesTableSeeder::class);
|
||||||
|
$this->call(WebMentionsTableSeeder::class);
|
||||||
|
$this->call(LikesTableSeeder::class);
|
||||||
|
$this->call(BookmarksTableSeeder::class);
|
||||||
|
$this->call(UsersTableSeeder::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue