├── .browserlistrc ├── .editorconfig ├── .env.example ├── .eslintignore ├── .eslintrc ├── .gitattributes ├── .gitignore ├── .php_cs ├── .prettierignore ├── .prettierrc ├── Envoy.blade.php ├── README.md ├── app ├── Console │ ├── Commands │ │ └── TweetScheduledTweetsCommand.php │ └── Kernel.php ├── Events │ └── TweetTweeted.php ├── Exceptions │ ├── CouldNotTweet.php │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── Api │ │ │ └── TweetsController.php │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── RegisterController.php │ │ │ └── ResetPasswordController.php │ │ ├── Controller.php │ │ └── ScheduledTweetsController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php │ └── Resources │ │ └── TweetResource.php ├── Models │ ├── Tweet.php │ └── User.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ ├── RouteServiceProvider.php │ └── ViewServiceProvider.php ├── Services │ └── Twitter │ │ ├── Facades │ │ └── Twitter.php │ │ ├── FakeTwitter.php │ │ ├── RealTwitter.php │ │ ├── Twitter.php │ │ └── TwitterServiceProvider.php └── helpers.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── backup.php ├── broadcasting.php ├── cache.php ├── database.php ├── filesystems.php ├── hashing.php ├── logging.php ├── mail.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ ├── TweetFactory.php │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ └── 2018_07_06_212431_create__tweets_table.php └── seeds │ ├── DatabaseSeeder.php │ ├── TweetSeeder.php │ └── UserSeeder.php ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── favicon.ico ├── index.php └── robots.txt ├── resources ├── assets │ ├── css │ │ ├── app.css │ │ ├── bootstrap.css │ │ ├── components │ │ │ └── .gitkeep │ │ └── utilities │ │ │ ├── alert.css │ │ │ ├── button.css │ │ │ ├── form.css │ │ │ ├── grid.css │ │ │ ├── modal.css │ │ │ ├── page.css │ │ │ └── table.css │ └── js │ │ ├── api.js │ │ ├── app.js │ │ ├── bootstrap.js │ │ ├── components │ │ ├── AddTweetForm.vue │ │ ├── ConfirmDeleteModal.vue │ │ ├── DeleteTweetButton.vue │ │ ├── Flash.vue │ │ └── TweetList.vue │ │ ├── echo.js │ │ ├── mixins │ │ └── Ui.js │ │ └── store.js ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ ├── auth │ ├── login.blade.php │ └── passwords │ │ ├── email.blade.php │ │ └── reset.blade.php │ ├── layouts │ ├── app.blade.php │ └── partials │ │ └── navbar.blade.php │ └── scheduled-tweets │ └── index.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── debugbar │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tailwind.js ├── tests ├── CreatesApplication.php ├── Feature │ └── Api │ │ └── ScheduledTweetsTest.php ├── TestCase.php └── Unit │ ├── Commands │ └── SendScheduledTweetsCommandTest.php │ └── Models │ └── ScheduledTweetTest.php ├── webpack.mix.js └── yarn.lock /.browserlistrc: -------------------------------------------------------------------------------- 1 | # Browsers we support via Babel, Autoprefixer etc. 2 | # https://github.com/ai/browserslist 3 | 4 | last 2 versions 5 | > 5% in BE 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [{package.json,tailwind.js}] 15 | indent_size = 2 16 | 17 | [*.md] 18 | trim_trailing_whitespace = false 19 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME="Scheduled Tweets" 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_LOG_LEVEL=debug 6 | APP_URL=http://scheduled-tweets.test 7 | 8 | DB_CONNECTION=mysql 9 | DB_HOST=127.0.0.1 10 | DB_PORT=3306 11 | DB_DATABASE=scheduled_tweets 12 | DB_USERNAME=root 13 | DB_PASSWORD= 14 | 15 | BROADCAST_DRIVER=pusher 16 | CACHE_DRIVER=file 17 | SESSION_DRIVER=file 18 | QUEUE_DRIVER=sync 19 | 20 | REDIS_HOST=127.0.0.1 21 | REDIS_PASSWORD=null 22 | REDIS_PORT=6379 23 | 24 | MAIL_DRIVER=preview 25 | MAIL_HOST=smtp.sendgrid.net 26 | MAIL_PORT=587 27 | MAIL_USERNAME=apikey 28 | MAIL_PASSWORD= 29 | MAIL_ENCRYPTION=tls 30 | 31 | PUSHER_APP_ID= 32 | PUSHER_APP_KEY= 33 | PUSHER_APP_SECRET= 34 | PUSHER_APP_CLUSTER=eu 35 | 36 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 37 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 38 | 39 | BUGSNAG_API_KEY= 40 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /resources/assets/js/back/redactor 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:vue/essential", 5 | "prettier" 6 | ], 7 | "parserOptions": { 8 | "ecmaVersion": 2017 9 | }, 10 | "env": { 11 | "browser": true, 12 | "node": true 13 | }, 14 | "rules": { 15 | "vue/html-indent": ["error", 4] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .idea 3 | .php_cs.cache 4 | .vagrant 5 | Homestead.json 6 | Homestead.yaml 7 | node_modules 8 | npm-debug.log 9 | public/css 10 | public/hot 11 | public/js 12 | public/mix-manifest.json 13 | public/storage 14 | storage/*.key 15 | vendor 16 | yarn-error.log 17 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | notPath('bootstrap/cache') 5 | ->notPath('storage/*') 6 | ->notPath('vendor') 7 | ->in(__DIR__) 8 | ->name('*.php') 9 | ->name('_ide_helper') 10 | ->notName('*.blade.php') 11 | ->ignoreDotFiles(true) 12 | ->ignoreVCS(true); 13 | 14 | 15 | return PhpCsFixer\Config::create() 16 | ->setRules([ 17 | '@PSR2' => true, 18 | 'array_syntax' => ['syntax' => 'short'], 19 | 'ordered_imports' => ['sortAlgorithm' => 'alpha'], 20 | 'no_unused_imports' => true, 21 | ]) 22 | ->setFinder($finder); 23 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | public/ 2 | vendor/ 3 | resources/assets/js/back/redactor/ 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "singleQuote": true, 4 | "tabWidth": 4, 5 | "trailingComma": "es5" 6 | } 7 | -------------------------------------------------------------------------------- /Envoy.blade.php: -------------------------------------------------------------------------------- 1 | @setup 2 | require __DIR__.'/vendor/autoload.php'; 3 | (new \Dotenv\Dotenv(__DIR__, '.env'))->load(); 4 | 5 | $server = ""; 6 | $userAndServer = 'forge@'. $server; 7 | $repository = "spatie/{$server}"; 8 | $baseDir = "/home/forge/{$server}"; 9 | $releasesDir = "{$baseDir}/releases"; 10 | $currentDir = "{$baseDir}/current"; 11 | $newReleaseName = date('Ymd-His'); 12 | $newReleaseDir = "{$releasesDir}/{$newReleaseName}"; 13 | $user = get_current_user(); 14 | 15 | function logMessage($message) { 16 | return "echo '\033[32m" .$message. "\033[0m';\n"; 17 | } 18 | @endsetup 19 | 20 | @servers(['local' => '127.0.0.1', 'remote' => $userAndServer]) 21 | 22 | @macro('deploy') 23 | startDeployment 24 | cloneRepository 25 | runComposer 26 | runYarn 27 | generateAssets 28 | updateSymlinks 29 | optimizeInstallation 30 | backupDatabase 31 | migrateDatabase 32 | blessNewRelease 33 | cleanOldReleases 34 | finishDeploy 35 | @endmacro 36 | 37 | @macro('deploy-code') 38 | deployOnlyCode 39 | @endmacro 40 | 41 | @task('startDeployment', ['on' => 'local']) 42 | {{ logMessage("🏃 Starting deployment...") }} 43 | git checkout master 44 | git pull origin master 45 | @endtask 46 | 47 | @task('cloneRepository', ['on' => 'remote']) 48 | {{ logMessage("🌀 Cloning repository...") }} 49 | [ -d {{ $releasesDir }} ] || mkdir {{ $releasesDir }}; 50 | cd {{ $releasesDir }}; 51 | 52 | # Create the release dir 53 | mkdir {{ $newReleaseDir }}; 54 | 55 | # Clone the repo 56 | git clone --depth 1 git@github.com:{{ $repository }} {{ $newReleaseName }} 57 | 58 | # Configure sparse checkout 59 | cd {{ $newReleaseDir }} 60 | git config core.sparsecheckout true 61 | echo "*" > .git/info/sparse-checkout 62 | echo "!storage" >> .git/info/sparse-checkout 63 | echo "!public/build" >> .git/info/sparse-checkout 64 | git read-tree -mu HEAD 65 | 66 | # Mark release 67 | cd {{ $newReleaseDir }} 68 | echo "{{ $newReleaseName }}" > public/release-name.txt 69 | @endtask 70 | 71 | @task('runComposer', ['on' => 'remote']) 72 | {{ logMessage("🚚 Running Composer...") }} 73 | cd {{ $newReleaseDir }}; 74 | composer install --prefer-dist --no-scripts --no-dev -q -o; 75 | @endtask 76 | 77 | @task('runYarn', ['on' => 'remote']) 78 | {{ logMessage("📦 Running Yarn...") }} 79 | cd {{ $newReleaseDir }}; 80 | yarn config set ignore-engines true 81 | yarn --frozen-lockfile 82 | @endtask 83 | 84 | @task('generateAssets', ['on' => 'remote']) 85 | {{ logMessage("🌅 Generating assets...") }} 86 | cd {{ $newReleaseDir }}; 87 | yarn run production --progress false 88 | @endtask 89 | 90 | @task('updateSymlinks', ['on' => 'remote']) 91 | {{ logMessage("🔗 Updating symlinks to persistent data...") }} 92 | # Remove the storage directory and replace with persistent data 93 | rm -rf {{ $newReleaseDir }}/storage; 94 | cd {{ $newReleaseDir }}; 95 | ln -nfs {{ $baseDir }}/persistent/storage storage; 96 | 97 | # Import the environment config 98 | cd {{ $newReleaseDir }}; 99 | ln -nfs {{ $baseDir }}/.env .env; 100 | @endtask 101 | 102 | @task('optimizeInstallation', ['on' => 'remote']) 103 | {{ logMessage("✨ Optimizing installation...") }} 104 | cd {{ $newReleaseDir }}; 105 | php artisan clear-compiled; 106 | @endtask 107 | 108 | @task('backupDatabase', ['on' => 'remote']) 109 | {{ logMessage("📀 Backing up database...") }} 110 | cd {{ $newReleaseDir }} 111 | php artisan backup:run 112 | @endtask 113 | 114 | @task('migrateDatabase', ['on' => 'remote']) 115 | {{ logMessage("🙈 Migrating database...") }} 116 | cd {{ $newReleaseDir }}; 117 | php artisan migrate --force; 118 | @endtask 119 | 120 | @task('blessNewRelease', ['on' => 'remote']) 121 | {{ logMessage("🙏 Blessing new release...") }} 122 | ln -nfs {{ $newReleaseDir }} {{ $currentDir }}; 123 | cd {{ $newReleaseDir }} 124 | php artisan config:clear 125 | php artisan cache:clear 126 | php artisan config:cache 127 | 128 | sudo service php7.2-fpm restart 129 | sudo supervisorctl restart all 130 | @endtask 131 | 132 | @task('cleanOldReleases', ['on' => 'remote']) 133 | {{ logMessage("🚾 Cleaning up old releases...") }} 134 | # Delete all but the 5 most recent. 135 | cd {{ $releasesDir }} 136 | ls -dt {{ $releasesDir }}/* | tail -n +6 | xargs -d "\n" sudo chown -R forge .; 137 | ls -dt {{ $releasesDir }}/* | tail -n +6 | xargs -d "\n" rm -rf; 138 | @endtask 139 | 140 | @task('finishDeploy', ['on' => 'local']) 141 | {{ logMessage("🚀 Application deployed!") }} 142 | @endtask 143 | 144 | @task('deployOnlyCode',['on' => 'remote']) 145 | {{ logMessage("💻 Deploying code changes...") }} 146 | cd {{ $currentDir }} 147 | git pull origin master 148 | php artisan config:clear 149 | php artisan cache:clear 150 | php artisan config:cache 151 | sudo supervisorctl restart all 152 | sudo service php7.2-fpm restart 153 | @endtask 154 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [](https://supportukrainenow.org) 3 | 4 | # Scheduled Tweets app 5 | 6 | This repo contains a Laravel app that allows to schedule tweets. 7 | 8 | ## Support us 9 | 10 | [](https://spatie.be/github-ad-click/scheduled-tweets-app) 11 | 12 | We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). 13 | 14 | We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). 15 | 16 | ## Colofon 17 | 18 | ### Contributing 19 | 20 | Generally we won't accept any PR requests to this repo. If you have discovered a bug or have an idea to improve the code, contact us first before you start coding. 21 | 22 | ### License 23 | 24 | Spoon and The Laravel framework are open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) 25 | -------------------------------------------------------------------------------- /app/Console/Commands/TweetScheduledTweetsCommand.php: -------------------------------------------------------------------------------- 1 | info('Sending scheduled tweets...'); 17 | 18 | $tweets = Tweet::notTweetedYet()->get() 19 | ->filter->shouldBeTweeted() 20 | ->each->tweet(); 21 | 22 | $tweets = Tweet::get()->each->tweet(); 23 | 24 | $this->info('Tweeted ' . $tweets->count() . ' scheduled tweet(s)!'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('tweet-scheduled-tweets')->everyMinute(); 17 | } 18 | 19 | protected function commands() 20 | { 21 | $this->load(__DIR__.'/Commands'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Events/TweetTweeted.php: -------------------------------------------------------------------------------- 1 | tweetId = $tweet->id; 25 | } 26 | 27 | public function broadcastOn() 28 | { 29 | return new PrivateChannel('tweets'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Exceptions/CouldNotTweet.php: -------------------------------------------------------------------------------- 1 | text}` to `{$tweet->account}` because the tweet was already sent at {$tweet->tweeted_at->format('Y-m-d H:i:s')}"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | allowedFilters([ 19 | Filter::scope('not_tweeted_yet'), 20 | ]) 21 | ->orderBy('scheduled_for') 22 | ->get(); 23 | 24 | return TweetResource::collection($tweets); 25 | } 26 | 27 | public function store(Request $request) 28 | { 29 | $validated = $request->validate([ 30 | 'account' => 'required', 31 | 'text' => 'required|max:250', 32 | 'scheduledFor' => 'required|date_format:Y-m-d H:i:s', 33 | ]); 34 | 35 | $tweet = Tweet::create([ 36 | 'account' => $validated['account'], 37 | 'text' => $validated['text'], 38 | 'scheduled_for' => $validated['scheduledFor'], 39 | ]); 40 | 41 | return new TweetResource($tweet); 42 | } 43 | 44 | public function delete(Tweet $tweet) 45 | { 46 | $tweet->delete(); 47 | 48 | return response('', Response::HTTP_NO_CONTENT); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | [ 31 | \App\Http\Middleware\EncryptCookies::class, 32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 33 | \Illuminate\Session\Middleware\StartSession::class, 34 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 36 | \App\Http\Middleware\VerifyCsrfToken::class, 37 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 38 | \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class, 39 | ], 40 | 41 | 'api' => [ 42 | 'throttle:60,1', 43 | 'bindings', 44 | ], 45 | ]; 46 | 47 | /** 48 | * The application's route middleware. 49 | * 50 | * These middleware may be assigned to groups or used individually. 51 | * 52 | * @var array 53 | */ 54 | protected $routeMiddleware = [ 55 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 56 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 57 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 58 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 59 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 60 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 61 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 62 | ]; 63 | } 64 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | $this->id, 13 | 'account' => $this->account, 14 | 'text' => $this->text, 15 | 'scheduledFor' => $this->scheduled_for, 16 | 'tweetedAt' => $this->tweeted_at, 17 | ]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Models/Tweet.php: -------------------------------------------------------------------------------- 1 | 'datetime', 17 | 'scheduled_for' => 'datetime', 18 | ]; 19 | 20 | public function shouldBeTweeted(): bool 21 | { 22 | if ($this->wasAlreadyTweeted()) { 23 | return false; 24 | } 25 | 26 | return $this->scheduled_for->isPast(); 27 | } 28 | 29 | public function tweet() 30 | { 31 | if ($this->wasAlreadyTweeted()) { 32 | throw CouldNotTweet::tweetWasAlreadySent($this); 33 | } 34 | 35 | //Twitter::account($this->account)->tweet($this->text); 36 | 37 | event(new TweetTweeted($this)); 38 | 39 | //$this->markAsTweeted(); 40 | } 41 | 42 | protected function wasAlreadyTweeted(): bool 43 | { 44 | return ! is_null($this->tweeted_at); 45 | } 46 | 47 | protected function markAsTweeted() 48 | { 49 | $this->update(['tweeted_at' => now()]); 50 | } 51 | 52 | public function scopeNotTweetedYet(Builder $builder) 53 | { 54 | $builder->whereNull('tweeted_at'); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | format('Y-m-d H:i:s'); 19 | }); 20 | } 21 | 22 | /** 23 | * Register any application services. 24 | * 25 | * @return void 26 | */ 27 | public function register() 28 | { 29 | $this->app->alias('bugsnag.multi', \Psr\Log\LoggerInterface::class); 30 | $this->app->alias('bugsnag.multi', \Psr\Log\LoggerInterface::class); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | Passport::routes(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any events for your application. 23 | * 24 | * @return void 25 | */ 26 | public function boot() 27 | { 28 | parent::boot(); 29 | 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | } 42 | 43 | protected function mapWebRoutes() 44 | { 45 | Route::middleware('web') 46 | ->namespace($this->namespace) 47 | ->group(base_path('routes/web.php')); 48 | } 49 | 50 | protected function mapApiRoutes() 51 | { 52 | Route::prefix('api') 53 | ->middleware(['api', 'auth:api']) 54 | ->namespace($this->namespace . '\Api') 55 | ->group(base_path('routes/api.php')); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Providers/ViewServiceProvider.php: -------------------------------------------------------------------------------- 1 | activeAccount = $name; 17 | 18 | return $this; 19 | } 20 | 21 | public function tweet(string $text) 22 | { 23 | $this->sentTweets[$this->activeAccount][] = $text; 24 | } 25 | 26 | public function assertTweeted(string $text, string $account) 27 | { 28 | PHPUnit::assertTrue(in_array($text, $this->sentTweets[$account] ?? []), "Tweet `{$text}` was not sent to `{$account}`"); 29 | } 30 | 31 | public function assertNotTweeted(string $text, string $account) 32 | { 33 | PHPUnit::assertFalse(in_array($text, $this->sentTweets[$account] ?? []), "Tweet `{$text}` was sent to `{$account}`"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Services/Twitter/RealTwitter.php: -------------------------------------------------------------------------------- 1 | twitterApi = $twitterApi; 23 | } 24 | 25 | public function tweet(string $status) 26 | { 27 | if (! app()->environment('production')) { 28 | Log::info("Tweeting {$status}"); 29 | 30 | return; 31 | } 32 | 33 | return $this->twitterApi->post('statuses/update', compact('status')); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Services/Twitter/Twitter.php: -------------------------------------------------------------------------------- 1 | app->singleton(Twitter::class, RealTwitter::class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/helpers.php: -------------------------------------------------------------------------------- 1 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spatie/scheduled-tweets-app", 3 | "description": "A simple app to scheduled tweets.", 4 | "keywords": [ 5 | "spatie", 6 | "framework", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "type": "project", 11 | "require": { 12 | "php": ">=7.1.0", 13 | "abraham/twitteroauth": "^0.9.2", 14 | "barryvdh/laravel-debugbar": "^3.0", 15 | "bugsnag/bugsnag-laravel": "^2.6", 16 | "doctrine/dbal": "^2.6", 17 | "fideloper/proxy": "~4.0", 18 | "laravel/framework": "5.6.*", 19 | "laravel/passport": "^6.0", 20 | "laravel/tinker": "~1.0", 21 | "pda/pheanstalk": "^3.1", 22 | "predis/predis": "^1.1", 23 | "pusher/pusher-php-server": "^3.1", 24 | "spatie/laravel-backup": "^5.0", 25 | "spatie/laravel-query-builder": "^1.10", 26 | "spatie/laravel-tail": "^3.0", 27 | "themsaid/laravel-mail-preview": "^2.0" 28 | }, 29 | "require-dev": { 30 | "filp/whoops": "~2.0", 31 | "friendsofphp/php-cs-fixer": "^2.4", 32 | "fzaninotto/faker": "~1.4", 33 | "laravel/envoy": "^1.3", 34 | "mockery/mockery": "0.9.*", 35 | "phpunit/phpunit": "^7.0", 36 | "nunomaduro/collision": "~1.1" 37 | }, 38 | "autoload": { 39 | "classmap": [ 40 | "database" 41 | ], 42 | "psr-4": { 43 | "App\\": "app/" 44 | }, 45 | "files": [ 46 | "app/helpers.php" 47 | ] 48 | }, 49 | "autoload-dev": { 50 | "psr-4": { 51 | "Tests\\": "tests/" 52 | } 53 | }, 54 | "scripts": { 55 | "deploy": [ 56 | "envoy run deploy" 57 | ], 58 | "deploy-code": [ 59 | "envoy run deploy-code" 60 | ], 61 | "format": [ 62 | "vendor/bin/php-cs-fixer fix" 63 | ], 64 | "post-root-package-install": [ 65 | "php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 66 | ], 67 | "post-create-project-cmd": [ 68 | "php artisan key:generate" 69 | ], 70 | "post-autoload-dump": [ 71 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 72 | "@php artisan package:discover" 73 | ] 74 | }, 75 | "config": { 76 | "preferred-install": "dist", 77 | "sort-packages": true, 78 | "optimize-autoloader": true, 79 | "platform": { 80 | "php": "7.2" 81 | } 82 | }, 83 | "extra": { 84 | "laravel": { 85 | "dont-discover": [] 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Application Environment 22 | |-------------------------------------------------------------------------- 23 | | 24 | | This value determines the "environment" your application is currently 25 | | running in. This may determine how you prefer to configure various 26 | | services your application utilizes. Set this in your ".env" file. 27 | | 28 | */ 29 | 30 | 'env' => env('APP_ENV', 'production'), 31 | 32 | /* 33 | |-------------------------------------------------------------------------- 34 | | Application Debug Mode 35 | |-------------------------------------------------------------------------- 36 | | 37 | | When your application is in debug mode, detailed error messages with 38 | | stack traces will be shown on every error that occurs within your 39 | | application. If disabled, a simple generic error page is shown. 40 | | 41 | */ 42 | 43 | 'debug' => env('APP_DEBUG', false), 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | Application URL 48 | |-------------------------------------------------------------------------- 49 | | 50 | | This URL is used by the console to properly generate URLs when using 51 | | the Artisan command line tool. You should set this to the root of 52 | | your application so that it is used when running Artisan tasks. 53 | | 54 | */ 55 | 56 | 'url' => env('APP_URL', 'http://localhost'), 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Application Timezone 61 | |-------------------------------------------------------------------------- 62 | | 63 | | Here you may specify the default timezone for your application, which 64 | | will be used by the PHP date and date-time functions. We have gone 65 | | ahead and set this to a sensible default for you out of the box. 66 | | 67 | */ 68 | 69 | 'timezone' => 'UTC', 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Application Locale Configuration 74 | |-------------------------------------------------------------------------- 75 | | 76 | | The application locale determines the default locale that will be used 77 | | by the translation service provider. You are free to set this value 78 | | to any of the locales which will be supported by the application. 79 | | 80 | */ 81 | 82 | 'locale' => 'en', 83 | 84 | /* 85 | |-------------------------------------------------------------------------- 86 | | Application Fallback Locale 87 | |-------------------------------------------------------------------------- 88 | | 89 | | The fallback locale determines the locale to use when the current one 90 | | is not available. You may change the value to correspond to any of 91 | | the language folders that are provided through your application. 92 | | 93 | */ 94 | 95 | 'fallback_locale' => 'en', 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Encryption Key 100 | |-------------------------------------------------------------------------- 101 | | 102 | | This key is used by the Illuminate encrypter service and should be set 103 | | to a random, 32 character string, otherwise these encrypted strings 104 | | will not be safe. Please do this before deploying an application! 105 | | 106 | */ 107 | 108 | 'key' => env('APP_KEY'), 109 | 110 | 'cipher' => 'AES-256-CBC', 111 | 112 | /* 113 | |-------------------------------------------------------------------------- 114 | | Logging Configuration 115 | |-------------------------------------------------------------------------- 116 | | 117 | | Here you may configure the log settings for your application. Out of 118 | | the box, Laravel uses the Monolog PHP logging library. This gives 119 | | you a variety of powerful log handlers / formatters to utilize. 120 | | 121 | | Available Settings: "single", "daily", "syslog", "errorlog" 122 | | 123 | */ 124 | 125 | 'log' => env('APP_LOG', 'daily'), 126 | 127 | 'log_level' => env('APP_LOG_LEVEL', 'debug'), 128 | 129 | /* 130 | |-------------------------------------------------------------------------- 131 | | Autoloaded Service Providers 132 | |-------------------------------------------------------------------------- 133 | | 134 | | The service providers listed here will be automatically loaded on the 135 | | request to your application. Feel free to add your own services to 136 | | this array to grant expanded functionality to your applications. 137 | | 138 | */ 139 | 140 | 'providers' => [ 141 | 142 | /* 143 | * Laravel Framework Service Providers... 144 | */ 145 | Illuminate\Auth\AuthServiceProvider::class, 146 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 147 | Illuminate\Bus\BusServiceProvider::class, 148 | Illuminate\Cache\CacheServiceProvider::class, 149 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 150 | Illuminate\Cookie\CookieServiceProvider::class, 151 | Illuminate\Database\DatabaseServiceProvider::class, 152 | Illuminate\Encryption\EncryptionServiceProvider::class, 153 | Illuminate\Filesystem\FilesystemServiceProvider::class, 154 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 155 | Illuminate\Hashing\HashServiceProvider::class, 156 | Illuminate\Mail\MailServiceProvider::class, 157 | Illuminate\Notifications\NotificationServiceProvider::class, 158 | Illuminate\Pagination\PaginationServiceProvider::class, 159 | Illuminate\Pipeline\PipelineServiceProvider::class, 160 | Illuminate\Queue\QueueServiceProvider::class, 161 | Illuminate\Redis\RedisServiceProvider::class, 162 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 163 | Illuminate\Session\SessionServiceProvider::class, 164 | Illuminate\Translation\TranslationServiceProvider::class, 165 | Illuminate\Validation\ValidationServiceProvider::class, 166 | Illuminate\View\ViewServiceProvider::class, 167 | 168 | /* 169 | * Package Service Providers... 170 | */ 171 | Barryvdh\Debugbar\ServiceProvider::class, 172 | Bugsnag\BugsnagLaravel\BugsnagServiceProvider::class, 173 | Spatie\Backup\BackupServiceProvider::class, 174 | Spatie\Tail\TailServiceProvider::class, 175 | Themsaid\MailPreview\MailPreviewServiceProvider::class, 176 | 177 | /* 178 | * Application Service Providers... 179 | */ 180 | App\Providers\AppServiceProvider::class, 181 | App\Providers\AuthServiceProvider::class, 182 | App\Providers\EventServiceProvider::class, 183 | App\Providers\RouteServiceProvider::class, 184 | App\Providers\ViewServiceProvider::class, 185 | TwitterServiceProvider::class, 186 | \App\Providers\BroadcastServiceProvider::class, 187 | 188 | ], 189 | 190 | /* 191 | |-------------------------------------------------------------------------- 192 | | Class Aliases 193 | |-------------------------------------------------------------------------- 194 | | 195 | | This array of class aliases will be registered when this application 196 | | is started. However, feel free to register as many as you wish as 197 | | the aliases are "lazy" loaded so they don't hinder performance. 198 | | 199 | */ 200 | 201 | 'aliases' => [ 202 | 203 | 'App' => Illuminate\Support\Facades\App::class, 204 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 205 | 'Auth' => Illuminate\Support\Facades\Auth::class, 206 | 'Blade' => Illuminate\Support\Facades\Blade::class, 207 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 208 | 'Bus' => Illuminate\Support\Facades\Bus::class, 209 | 'Bugsnag' => Bugsnag\BugsnagLaravel\Facades\Bugsnag::class, 210 | 'Cache' => Illuminate\Support\Facades\Cache::class, 211 | 'Config' => Illuminate\Support\Facades\Config::class, 212 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 213 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 214 | 'DB' => Illuminate\Support\Facades\DB::class, 215 | 'Debugbar' => Barryvdh\Debugbar\Facade::class, 216 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 217 | 'Event' => Illuminate\Support\Facades\Event::class, 218 | 'File' => Illuminate\Support\Facades\File::class, 219 | 'Gate' => Illuminate\Support\Facades\Gate::class, 220 | 'Hash' => Illuminate\Support\Facades\Hash::class, 221 | 'Lang' => Illuminate\Support\Facades\Lang::class, 222 | 'Log' => Illuminate\Support\Facades\Log::class, 223 | 'Mail' => Illuminate\Support\Facades\Mail::class, 224 | 'Notification' => Illuminate\Support\Facades\Notification::class, 225 | 'Password' => Illuminate\Support\Facades\Password::class, 226 | 'Queue' => Illuminate\Support\Facades\Queue::class, 227 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 228 | 'Redis' => Illuminate\Support\Facades\Redis::class, 229 | 'Request' => Illuminate\Support\Facades\Request::class, 230 | 'Response' => Illuminate\Support\Facades\Response::class, 231 | 'Route' => Illuminate\Support\Facades\Route::class, 232 | 'Schema' => Illuminate\Support\Facades\Schema::class, 233 | 'Session' => Illuminate\Support\Facades\Session::class, 234 | 'Storage' => Illuminate\Support\Facades\Storage::class, 235 | 'URL' => Illuminate\Support\Facades\URL::class, 236 | 'Validator' => Illuminate\Support\Facades\Validator::class, 237 | 'View' => Illuminate\Support\Facades\View::class, 238 | 239 | ], 240 | 241 | ]; 242 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'passport', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\Models\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | You may specify multiple password reset configurations if you have more 85 | | than one user table or model in the application and you want to have 86 | | separate password reset settings based on the specific user types. 87 | | 88 | | The expire time is the number of minutes that the reset token should be 89 | | considered valid. This security feature keeps tokens short-lived so 90 | | they have less time to be guessed. You may change this as needed. 91 | | 92 | */ 93 | 94 | 'passwords' => [ 95 | 'users' => [ 96 | 'provider' => 'users', 97 | 'table' => 'password_resets', 98 | 'expire' => 60, 99 | ], 100 | ], 101 | 102 | ]; 103 | -------------------------------------------------------------------------------- /config/backup.php: -------------------------------------------------------------------------------- 1 | [ 6 | 7 | /* 8 | * The name of this application. You can use this name to monitor 9 | * the backups. 10 | */ 11 | 'name' => env('APP_NAME'), 12 | 13 | 'source' => [ 14 | 15 | 'files' => [ 16 | 17 | /* 18 | * The list of directories and files that will be included in the backup. 19 | */ 20 | 'include' => [ 21 | //base_path(), 22 | ], 23 | 24 | /* 25 | * These directories and files will be excluded from the backup. 26 | * 27 | * Directories used by the backup process will automatically be excluded. 28 | */ 29 | 'exclude' => [ 30 | base_path('vendor'), 31 | base_path('node_modules'), 32 | ], 33 | 34 | /* 35 | * Determines if symlinks should be followed. 36 | */ 37 | 'followLinks' => false, 38 | ], 39 | 40 | /* 41 | * The names of the connections to the databases that should be backed up 42 | * Only MySQL and PostgreSQL databases are supported. 43 | */ 44 | 'databases' => [ 45 | 'mysql', 46 | ], 47 | ], 48 | 49 | 'destination' => [ 50 | 51 | /* 52 | * The disk names on which the backups will be stored. 53 | */ 54 | 'disks' => [ 55 | 'backups', 56 | ], 57 | ], 58 | ], 59 | 60 | /* 61 | * You can get notified when specific events occur. Out of the box you can use 'mail' and 'slack'. 62 | * For Slack you need to install guzzlehttp/guzzle. 63 | * 64 | * You can also use your own notification classes, just make sure the class is named after one of 65 | * the `Spatie\Backup\Events` classes. 66 | */ 67 | 'notifications' => [ 68 | 69 | 'notifications' => [ 70 | \Spatie\Backup\Notifications\Notifications\BackupHasFailed::class => ['slack'], 71 | \Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound::class => ['slack'], 72 | \Spatie\Backup\Notifications\Notifications\CleanupHasFailed::class => ['slack'], 73 | \Spatie\Backup\Notifications\Notifications\BackupWasSuccessful::class => ['slack'], 74 | \Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound::class => [], 75 | \Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful::class => [], 76 | ], 77 | 78 | /* 79 | * Here you can specify the notifiable to which the notifications should be sent. The default 80 | * notifiable will use the variables specified in this config file. 81 | */ 82 | 'notifiable' => \Spatie\Backup\Notifications\Notifiable::class, 83 | 84 | 'mail' => [ 85 | 'to' => 'freek@spatie.be', 86 | ], 87 | 88 | 'slack' => [ 89 | 'webhook_url' => env('SLACK_BACKUP_CHANNEL_WEBHOOK'), 90 | ], 91 | ], 92 | 93 | /* 94 | * Here you can specify which backups should be monitored. 95 | * If a backup does not meet the specified requirements the 96 | * UnHealthyBackupWasFound event will be fired. 97 | */ 98 | 'monitorBackups' => [ 99 | [ 100 | 'name' => str_replace('https://', '', env('APP_URL')), 101 | 'disks' => ['backups'], 102 | 'newestBackupsShouldNotBeOlderThanDays' => 1, 103 | 'storageUsedMayNotBeHigherThanMegabytes' => 1000, 104 | ], 105 | 106 | /* 107 | [ 108 | 'name' => 'name of the second app', 109 | 'disks' => ['local', 's3'], 110 | 'newestBackupsShouldNotBeOlderThanDays' => 1, 111 | 'storageUsedMayNotBeHigherThanMegabytes' => 5000, 112 | ], 113 | */ 114 | ], 115 | 116 | 'cleanup' => [ 117 | /* 118 | * The strategy that will be used to cleanup old backups. The default strategy 119 | * will keep all backups for a certain amount of days. After that period only 120 | * a daily backup will be kept. After that period only weekly backups will 121 | * be kept and so on. 122 | * 123 | * No matter how you configure it the default strategy will never 124 | * delete the newest backup. 125 | */ 126 | 'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class, 127 | 128 | 'defaultStrategy' => [ 129 | 130 | /* 131 | * The number of days for which backups must be kept. 132 | */ 133 | 'keepAllBackupsForDays' => 7, 134 | 135 | /* 136 | * The number of days for which daily backups must be kept. 137 | */ 138 | 'keepDailyBackupsForDays' => 16, 139 | 140 | /* 141 | * The number of weeks for which one weekly backup must be kept. 142 | */ 143 | 'keepWeeklyBackupsForWeeks' => 8, 144 | 145 | /* 146 | * The number of months for which one monthly backup must be kept. 147 | */ 148 | 'keepMonthlyBackupsForMonths' => 4, 149 | 150 | /* 151 | * The number of years for which one yearly backup must be kept. 152 | */ 153 | 'keepYearlyBackupsForYears' => 2, 154 | 155 | /* 156 | * After cleaning up the backups remove the oldest backup until 157 | * this amount of megabytes has been reached. 158 | */ 159 | 'deleteOldestBackupsWhenUsingMoreMegabytesThan' => 5000, 160 | ], 161 | ], 162 | ]; 163 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'pusher'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'encrypted' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | */ 30 | 31 | 'stores' => [ 32 | 33 | 'apc' => [ 34 | 'driver' => 'apc', 35 | ], 36 | 37 | 'array' => [ 38 | 'driver' => 'array', 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'table' => 'cache', 44 | 'connection' => null, 45 | ], 46 | 47 | 'file' => [ 48 | 'driver' => 'file', 49 | 'path' => storage_path('framework/cache/data'), 50 | ], 51 | 52 | 'memcached' => [ 53 | 'driver' => 'memcached', 54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 55 | 'sasl' => [ 56 | env('MEMCACHED_USERNAME'), 57 | env('MEMCACHED_PASSWORD'), 58 | ], 59 | 'options' => [ 60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 61 | ], 62 | 'servers' => [ 63 | [ 64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 65 | 'port' => env('MEMCACHED_PORT', 11211), 66 | 'weight' => 100, 67 | ], 68 | ], 69 | ], 70 | 71 | 'redis' => [ 72 | 'driver' => 'redis', 73 | 'connection' => 'default', 74 | ], 75 | 76 | ], 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Cache Key Prefix 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When utilizing a RAM based store such as APC or Memcached, there might 84 | | be other applications utilizing the same cache. So, we'll specify a 85 | | value to get prefixed to all our keys so we can avoid collisions. 86 | | 87 | */ 88 | 89 | 'prefix' => env( 90 | 'CACHE_PREFIX', 91 | str_slug(env('APP_NAME', 'laravel'), '_').'_cache' 92 | ), 93 | 94 | ]; 95 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Database Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here are each of the database connections setup for your application. 24 | | Of course, examples of configuring each database platform that is 25 | | supported by Laravel is shown below to make development simple. 26 | | 27 | | 28 | | All database work in Laravel is done through the PHP PDO facilities 29 | | so make sure you have the driver for your particular database of 30 | | choice installed on your machine before you begin development. 31 | | 32 | */ 33 | 34 | 'connections' => [ 35 | 36 | 'sqlite' => [ 37 | 'driver' => 'sqlite', 38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 39 | 'prefix' => '', 40 | ], 41 | 42 | 'testing' => [ 43 | 'driver' => 'sqlite', 44 | 'database' => ':memory:', 45 | 'prefix' => '', 46 | ], 47 | 48 | 'mysql' => [ 49 | 'driver' => 'mysql', 50 | 'host' => env('DB_HOST', '127.0.0.1'), 51 | 'port' => env('DB_PORT', '3306'), 52 | 'database' => env('DB_DATABASE', 'forge'), 53 | 'username' => env('DB_USERNAME', 'forge'), 54 | 'password' => env('DB_PASSWORD', ''), 55 | 'unix_socket' => env('DB_SOCKET', ''), 56 | 'charset' => 'utf8mb4', 57 | 'collation' => 'utf8mb4_unicode_ci', 58 | 'prefix' => '', 59 | 'strict' => true, 60 | 'engine' => null, 61 | ], 62 | 63 | 'pgsql' => [ 64 | 'driver' => 'pgsql', 65 | 'host' => env('DB_HOST', '127.0.0.1'), 66 | 'port' => env('DB_PORT', '5432'), 67 | 'database' => env('DB_DATABASE', 'forge'), 68 | 'username' => env('DB_USERNAME', 'forge'), 69 | 'password' => env('DB_PASSWORD', ''), 70 | 'charset' => 'utf8', 71 | 'prefix' => '', 72 | 'schema' => 'public', 73 | 'sslmode' => 'prefer', 74 | ], 75 | 76 | 'sqlsrv' => [ 77 | 'driver' => 'sqlsrv', 78 | 'host' => env('DB_HOST', 'localhost'), 79 | 'port' => env('DB_PORT', '1433'), 80 | 'database' => env('DB_DATABASE', 'forge'), 81 | 'username' => env('DB_USERNAME', 'forge'), 82 | 'password' => env('DB_PASSWORD', ''), 83 | 'charset' => 'utf8', 84 | 'prefix' => '', 85 | ], 86 | 87 | ], 88 | 89 | /* 90 | |-------------------------------------------------------------------------- 91 | | Migration Repository Table 92 | |-------------------------------------------------------------------------- 93 | | 94 | | This table keeps track of all the migrations that have already run for 95 | | your application. Using this information, we can determine which of 96 | | the migrations on disk haven't actually been run in the database. 97 | | 98 | */ 99 | 100 | 'migrations' => 'migrations', 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Redis Databases 105 | |-------------------------------------------------------------------------- 106 | | 107 | | Redis is an open source, fast, and advanced key-value store that also 108 | | provides a richer set of commands than a typical key-value systems 109 | | such as APC or Memcached. Laravel makes it easy to dig right in. 110 | | 111 | */ 112 | 113 | 'redis' => [ 114 | 115 | 'client' => 'predis', 116 | 117 | 'default' => [ 118 | 'host' => env('REDIS_HOST', '127.0.0.1'), 119 | 'password' => env('REDIS_PASSWORD', null), 120 | 'port' => env('REDIS_PORT', 6379), 121 | 'database' => 0, 122 | ], 123 | 124 | ], 125 | 126 | ]; 127 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "s3", "rackspace" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | 'url' => env('AWS_URL'), 65 | ], 66 | 67 | ], 68 | 69 | ]; 70 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Log Channels 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the log channels for your application. Out of 24 | | the box, Laravel uses the Monolog PHP logging library. This gives 25 | | you a variety of powerful log handlers / formatters to utilize. 26 | | 27 | | Available Drivers: "single", "daily", "slack", "syslog", 28 | | "errorlog", "custom", "stack" 29 | | 30 | */ 31 | 32 | 'channels' => [ 33 | 'stack' => [ 34 | 'driver' => 'stack', 35 | 'channels' => ['single'], 36 | ], 37 | 38 | 'single' => [ 39 | 'driver' => 'single', 40 | 'path' => storage_path('logs/laravel.log'), 41 | 'level' => 'debug', 42 | ], 43 | 44 | 'daily' => [ 45 | 'driver' => 'daily', 46 | 'path' => storage_path('logs/laravel.log'), 47 | 'level' => 'debug', 48 | 'days' => 7, 49 | ], 50 | 51 | 'slack' => [ 52 | 'driver' => 'slack', 53 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 54 | 'username' => 'Laravel Log', 55 | 'emoji' => ':boom:', 56 | 'level' => 'critical', 57 | ], 58 | 59 | 'syslog' => [ 60 | 'driver' => 'syslog', 61 | 'level' => 'debug', 62 | ], 63 | 64 | 'errorlog' => [ 65 | 'driver' => 'errorlog', 66 | 'level' => 'debug', 67 | ], 68 | ], 69 | 70 | ]; 71 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => [ 59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 60 | 'name' => env('MAIL_FROM_NAME', 'Example'), 61 | ], 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | E-Mail Encryption Protocol 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Here you may specify the encryption protocol that should be used when 69 | | the application send e-mail messages. A sensible default using the 70 | | transport layer security protocol should provide great security. 71 | | 72 | */ 73 | 74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | SMTP Server Username 79 | |-------------------------------------------------------------------------- 80 | | 81 | | If your SMTP server requires a username for authentication, you should 82 | | set it here. This will get used to authenticate with your server on 83 | | connection. You may also set the "password" value below this one. 84 | | 85 | */ 86 | 87 | 'username' => env('MAIL_USERNAME'), 88 | 89 | 'password' => env('MAIL_PASSWORD'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Sendmail System Path 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using the "sendmail" driver to send e-mails, we will need to know 97 | | the path to where Sendmail lives on this server. A default path has 98 | | been provided here, which will work well on most of your systems. 99 | | 100 | */ 101 | 102 | 'sendmail' => '/usr/sbin/sendmail -bs', 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Markdown Mail Settings 107 | |-------------------------------------------------------------------------- 108 | | 109 | | If you are using Markdown based email rendering, you may configure your 110 | | theme and component paths here, allowing you to customize the design 111 | | of the emails. Or, you may simply stick with the Laravel defaults! 112 | | 113 | */ 114 | 115 | 'markdown' => [ 116 | 'theme' => 'default', 117 | 118 | 'paths' => [ 119 | resource_path('views/vendor/mail'), 120 | ], 121 | ], 122 | 123 | ]; 124 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => env('SQS_KEY', 'your-public-key'), 54 | 'secret' => env('SQS_SECRET', 'your-secret-key'), 55 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 56 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 57 | 'region' => env('SQS_REGION', 'us-east-1'), 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => 'default', 64 | 'retry_after' => 90, 65 | 'block_for' => null, 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Failed Queue Jobs 73 | |-------------------------------------------------------------------------- 74 | | 75 | | These options configure the behavior of failed queue job logging so you 76 | | can control which database and table are used to store the jobs that 77 | | have failed. You may change them to any database / table you wish. 78 | | 79 | */ 80 | 81 | 'failed' => [ 82 | 'database' => env('DB_CONNECTION', 'mysql'), 83 | 'table' => 'failed_jobs', 84 | ], 85 | 86 | ]; 87 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'ses' => [ 23 | 'key' => env('SES_KEY'), 24 | 'secret' => env('SES_SECRET'), 25 | 'region' => 'us-east-1', 26 | ], 27 | 28 | 'sparkpost' => [ 29 | 'secret' => env('SPARKPOST_SECRET'), 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\Models\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => env('SESSION_LIFETIME', 120), 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session Encryption 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This option allows you to easily specify that all of your session data 42 | | should be encrypted before it is stored. All encryption will be run 43 | | automatically by Laravel and you can use the Session like normal. 44 | | 45 | */ 46 | 47 | 'encrypt' => false, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session File Location 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the native session driver, we need a location where session 55 | | files may be stored. A default has been set for you but a different 56 | | location may be specified. This is only needed for file sessions. 57 | | 58 | */ 59 | 60 | 'files' => storage_path('framework/sessions'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Connection 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" or "redis" session drivers, you may specify a 68 | | connection that should be used to manage these sessions. This should 69 | | correspond to a connection in your database configuration options. 70 | | 71 | */ 72 | 73 | 'connection' => null, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Database Table 78 | |-------------------------------------------------------------------------- 79 | | 80 | | When using the "database" session driver, you may specify the table we 81 | | should use to manage the sessions. Of course, a sensible default is 82 | | provided for you; however, you are free to change this as needed. 83 | | 84 | */ 85 | 86 | 'table' => 'sessions', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Cache Store 91 | |-------------------------------------------------------------------------- 92 | | 93 | | When using the "apc" or "memcached" session drivers, you may specify a 94 | | cache store that should be used for these sessions. This value must 95 | | correspond with one of the application's configured cache stores. 96 | | 97 | */ 98 | 99 | 'store' => null, 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Sweeping Lottery 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Some session drivers must manually sweep their storage location to get 107 | | rid of old sessions from storage. Here are the chances that it will 108 | | happen on a given request. By default, the odds are 2 out of 100. 109 | | 110 | */ 111 | 112 | 'lottery' => [2, 100], 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Name 117 | |-------------------------------------------------------------------------- 118 | | 119 | | Here you may change the name of the cookie used to identify a session 120 | | instance by ID. The name specified here will get used every time a 121 | | new session cookie is created by the framework for every driver. 122 | | 123 | */ 124 | 125 | 'cookie' => env( 126 | 'SESSION_COOKIE', 127 | str_slug(env('APP_NAME', 'laravel'), '_').'_session' 128 | ), 129 | 130 | /* 131 | |-------------------------------------------------------------------------- 132 | | Session Cookie Path 133 | |-------------------------------------------------------------------------- 134 | | 135 | | The session cookie path determines the path for which the cookie will 136 | | be regarded as available. Typically, this will be the root path of 137 | | your application but you are free to change this when necessary. 138 | | 139 | */ 140 | 141 | 'path' => '/', 142 | 143 | /* 144 | |-------------------------------------------------------------------------- 145 | | Session Cookie Domain 146 | |-------------------------------------------------------------------------- 147 | | 148 | | Here you may change the domain of the cookie used to identify a session 149 | | in your application. This will determine which domains the cookie is 150 | | available to in your application. A sensible default has been set. 151 | | 152 | */ 153 | 154 | 'domain' => env('SESSION_DOMAIN', null), 155 | 156 | /* 157 | |-------------------------------------------------------------------------- 158 | | HTTPS Only Cookies 159 | |-------------------------------------------------------------------------- 160 | | 161 | | By setting this option to true, session cookies will only be sent back 162 | | to the server if the browser has a HTTPS connection. This will keep 163 | | the cookie from being sent to you if it can not be done securely. 164 | | 165 | */ 166 | 167 | 'secure' => env('SESSION_SECURE_COOKIE', false), 168 | 169 | /* 170 | |-------------------------------------------------------------------------- 171 | | HTTP Access Only 172 | |-------------------------------------------------------------------------- 173 | | 174 | | Setting this value to true will prevent JavaScript from accessing the 175 | | value of the cookie and the cookie will only be accessible through 176 | | the HTTP protocol. You are free to modify this option if needed. 177 | | 178 | */ 179 | 180 | 'http_only' => true, 181 | 182 | /* 183 | |-------------------------------------------------------------------------- 184 | | Same-Site Cookies 185 | |-------------------------------------------------------------------------- 186 | | 187 | | This option determines how your cookies behave when cross-site requests 188 | | take place, and can be used to mitigate CSRF attacks. By default, we 189 | | do not enable this as other CSRF protection services are in place. 190 | | 191 | | Supported: "lax", "strict" 192 | | 193 | */ 194 | 195 | 'same_site' => null, 196 | 197 | ]; 198 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/TweetFactory.php: -------------------------------------------------------------------------------- 1 | define(Tweet::class, function (Faker $faker) { 7 | return [ 8 | 'account' => $faker->word, 9 | 'text' => $faker->text, 10 | 'scheduled_for' => $faker->dateTimeBetween('+1 day', '+ 10 days') 11 | ]; 12 | }); 13 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(App\Models\User::class, function (Faker\Generator $faker) { 16 | static $password; 17 | 18 | return [ 19 | 'name' => $faker->name, 20 | 'email' => $faker->unique()->safeEmail, 21 | 'password' => $password ?: $password = bcrypt('secret'), 22 | 'remember_token' => str_random(10), 23 | ]; 24 | }); 25 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('users'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_07_06_212431_create__tweets_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 13 | $table->string('account'); 14 | $table->text('text'); 15 | $table->timestamp('scheduled_for'); 16 | $table->timestamp('tweeted_at')->nullable(); 17 | $table->timestamps(); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UserSeeder::class) 11 | ->call(TweetSeeder::class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /database/seeds/TweetSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /database/seeds/UserSeeder.php: -------------------------------------------------------------------------------- 1 | create(['email' => 'freek@spatie.be']); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scheduled-tweets", 3 | "private": true, 4 | "license": "MIT", 5 | "authors": [ 6 | "Sebastian De Deyne ", 7 | "Freek Van der Herten ", 8 | "Willem Van Bockstal " 9 | ], 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:spatie-custom/blender.git" 13 | }, 14 | "scripts": { 15 | "dev": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 16 | "watch": "NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 17 | "production": "NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 18 | "format": "prettier --write 'resources/assets/**/*.{css,js,vue}'", 19 | "lint": "eslint resources/assets/js --fix --ext js,vue" 20 | }, 21 | "dependencies": { 22 | "axios": "^0.18", 23 | "babel-plugin-syntax-dynamic-import": "^6.18.0", 24 | "caniuse-lite": "^1.0.30000697", 25 | "eslint": "^4.19.1", 26 | "eslint-config-prettier": "^2.9.0", 27 | "eslint-plugin-vue": "^4.4.0", 28 | "form-backend-validation": "^2.3.3", 29 | "laravel-echo": "^1.4.0", 30 | "laravel-mix": "^2.1.0", 31 | "laravel-mix-purgecss": "^2.0.0", 32 | "lodash": "^4.17.10", 33 | "moment": "^2.22.2", 34 | "portal-vue": "^1.3.0", 35 | "postcss-cssnext": "^3.0.2", 36 | "postcss-easy-import": "^3.0.0", 37 | "prettier": "^1.10.2", 38 | "pusher-js": "^4.2.2", 39 | "tailwindcss": "^0.5.0", 40 | "vue": "^2.5.7", 41 | "vuex": "^3.0.1" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Feature 14 | 15 | 16 | 17 | ./tests/Unit 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes If Not A Folder... 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteCond %{REQUEST_URI} (.+)/$ 11 | RewriteRule ^ %1 [L,R=301] 12 | 13 | # Handle Front Controller... 14 | RewriteCond %{REQUEST_FILENAME} !-d 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | RewriteRule ^ index.php [L] 17 | 18 | # Handle Authorization Header 19 | RewriteCond %{HTTP:Authorization} . 20 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 21 | 22 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatie/scheduled-tweets-app/d6d5d4304441c2558177feb6da092ac54ddc7a81/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /resources/assets/css/app.css: -------------------------------------------------------------------------------- 1 | @charset 'UTF-8'; 2 | 3 | @import './bootstrap.css'; 4 | @import './components/*'; 5 | @import './utilities/*'; 6 | 7 | @tailwind utilities; 8 | -------------------------------------------------------------------------------- /resources/assets/css/bootstrap.css: -------------------------------------------------------------------------------- 1 | @tailwind preflight; 2 | 3 | * { 4 | position: relative; 5 | box-sizing: inherit; 6 | margin: 0; 7 | padding: 0; 8 | color: inherit; 9 | font: inherit; 10 | 11 | &:after, 12 | &:before { 13 | box-sizing: inherit; 14 | } 15 | } 16 | 17 | html { 18 | box-sizing: border-box; 19 | } 20 | 21 | h1 { 22 | font-size: inherit; /* Reset normalize 2em */ 23 | } 24 | 25 | a { 26 | text-decoration: none; 27 | } 28 | 29 | ol, 30 | ul { 31 | list-style: none; 32 | } 33 | 34 | img, 35 | svg { 36 | display: block; 37 | vertical-align: middle; 38 | } 39 | 40 | textarea { 41 | outline: none; 42 | } 43 | 44 | body { 45 | font-family: 'Sunflower', sans-serif; 46 | } 47 | -------------------------------------------------------------------------------- /resources/assets/css/components/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /resources/assets/css/utilities/alert.css: -------------------------------------------------------------------------------- 1 | .alert { 2 | @apply bg-green border border border-green text-white px-4 py-3; 3 | } 4 | 5 | .alert-flash { 6 | position: fixed; 7 | right: 25px; 8 | bottom: 25px; 9 | } 10 | -------------------------------------------------------------------------------- /resources/assets/css/utilities/button.css: -------------------------------------------------------------------------------- 1 | .btn { 2 | @apply font-bold py-2 px-4 rounded; 3 | } 4 | 5 | .btn-blue { 6 | @apply bg-blue text-white; 7 | } 8 | 9 | .btn-blue:hover { 10 | @apply bg-blue-dark; 11 | } 12 | 13 | .btn-red { 14 | @apply bg-red text-white; 15 | } 16 | 17 | .btn-red:hover { 18 | @apply bg-red-dark; 19 | } 20 | -------------------------------------------------------------------------------- /resources/assets/css/utilities/form.css: -------------------------------------------------------------------------------- 1 | .form-label { 2 | @apply font-hairline text-grey-darker block mb-2; 3 | } 4 | 5 | .form-label-aside { 6 | @apply font-hairline text-grey-darker mb-2 text-xs; 7 | } 8 | 9 | .form-input { 10 | @apply border-2 border-grey bg-white rounded p-4 w-full; 11 | } 12 | 13 | .tweet-box { 14 | resize: none; 15 | } 16 | 17 | .validation-error { 18 | @apply bg-red-lightest px-4 py-3 text-red-dark; 19 | } 20 | -------------------------------------------------------------------------------- /resources/assets/css/utilities/grid.css: -------------------------------------------------------------------------------- 1 | .flex, 2 | .row { 3 | display: flex; 4 | margin-left: -10px; 5 | margin-right: -10px; 6 | } 7 | 8 | .col { 9 | flex: 1; 10 | padding: 10px; 11 | } 12 | 13 | .section { 14 | padding: 30px; 15 | } 16 | 17 | .container { 18 | max-width: 1200px; 19 | margin: 0 auto; 20 | } 21 | -------------------------------------------------------------------------------- /resources/assets/css/utilities/modal.css: -------------------------------------------------------------------------------- 1 | .modal-backdrop { 2 | position: fixed; 3 | top: 0; 4 | right: 0; 5 | bottom: 0; 6 | left: 0; 7 | overflow: auto; 8 | padding: 2rem; 9 | background-color: rgba(0, 0, 0, 0.5); 10 | } 11 | 12 | .modal { 13 | margin-left: auto; 14 | margin-right: auto; 15 | max-width: 30rem; 16 | margin-top: 2rem; 17 | background-color: #fff; 18 | border-radius: 0.25rem; 19 | padding: 2rem; 20 | -webkit-box-shadow: 0 15px 30px 0 rgba(0, 0, 0, 0.11), 0 5px 15px 0 rgba(0, 0, 0, 0.08); 21 | box-shadow: 0 15px 30px 0 rgba(0, 0, 0, 0.11), 0 5px 15px 0 rgba(0, 0, 0, 0.08); 22 | } 23 | -------------------------------------------------------------------------------- /resources/assets/css/utilities/page.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | @apply text-2xl; 3 | } 4 | -------------------------------------------------------------------------------- /resources/assets/css/utilities/table.css: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | margin: 20px auto; 4 | } 5 | 6 | table, 7 | td, 8 | th { 9 | border-collapse: collapse; 10 | text-align: left; 11 | } 12 | 13 | th { 14 | @apply font-black border-b; 15 | } 16 | 17 | th, 18 | td { 19 | padding: 10px; 20 | } 21 | 22 | .row-text { 23 | width: 50%; 24 | } 25 | 26 | .row-scheduled-at { 27 | width: 20%; 28 | } 29 | 30 | .row-tweeted-at { 31 | width: 20%; 32 | } 33 | -------------------------------------------------------------------------------- /resources/assets/js/api.js: -------------------------------------------------------------------------------- 1 | export default { 2 | async getScheduledTweets() { 3 | const response = await axios.get('api/tweets?filter[not_tweeted_yet]'); 4 | 5 | return response.data.data; 6 | }, 7 | 8 | createScheduledTweet(attributes) { 9 | return axios.post('api/tweets', attributes); 10 | }, 11 | 12 | deleteTweet(scheduledTweetId) { 13 | return axios.delete(`api/tweets/${scheduledTweetId}`); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /resources/assets/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | 3 | window.Vue = require('vue'); 4 | import PortalVue from 'portal-vue'; 5 | import Vuex from 'vuex'; 6 | 7 | Vue.mixin(require('./mixins/Ui.js').default); 8 | Vue.use(PortalVue); 9 | Vue.use(Vuex); 10 | 11 | Vue.component('tweet-list', require('./components/TweetList.vue')); 12 | Vue.component('flash', require('./components/Flash')); 13 | 14 | const app = new Vue({ 15 | el: '#app', 16 | }); 17 | 18 | require('./echo'); 19 | -------------------------------------------------------------------------------- /resources/assets/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load the axios HTTP library which allows us to easily issue requests 3 | * to our Laravel back-end. This library automatically handles sending the 4 | * CSRF token as a header based on the value of the "XSRF" token cookie. 5 | */ 6 | 7 | window.axios = require('axios'); 8 | 9 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 10 | 11 | /** 12 | * Next we will register the CSRF Token as a common header with Axios so that 13 | * all outgoing HTTP requests automatically have it attached. This is just 14 | * a simple convenience so we don't have to attach every token manually. 15 | */ 16 | 17 | let token = document.head.querySelector('meta[name="csrf-token"]'); 18 | 19 | if (token) { 20 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 21 | } else { 22 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 23 | } 24 | 25 | import Echo from 'laravel-echo'; 26 | 27 | if (process.env.MIX_PUSHER_APP_KEY) { 28 | window.Pusher = require('pusher-js'); 29 | 30 | window.Echo = new Echo({ 31 | broadcaster: 'pusher', 32 | key: process.env.MIX_PUSHER_APP_KEY, 33 | cluster: process.env.MIX_PUSHER_APP_CLUSTER, 34 | encrypted: true, 35 | }); 36 | } 37 | -------------------------------------------------------------------------------- /resources/assets/js/components/AddTweetForm.vue: -------------------------------------------------------------------------------- 1 |