initial commit

This commit is contained in:
Constantin Plaiasu 2024-08-24 23:08:42 +03:00
commit db4f3133a3
436 changed files with 138023 additions and 0 deletions

18
.editorconfig Normal file
View file

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

58
.env.example Normal file
View file

@ -0,0 +1,58 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

11
.gitattributes vendored Normal file
View file

@ -0,0 +1,11 @@
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

18
.gitignore vendored Normal file
View file

@ -0,0 +1,18 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode

BIN
.yarn/install-state.gz Normal file

Binary file not shown.

1
.yarnrc.yml Normal file
View file

@ -0,0 +1 @@
nodeLinker: node-modules

66
README.md Normal file
View file

@ -0,0 +1,66 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

View file

@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use App\Services\ApiClient;
use App\Services\SitemapGenerator;
use Illuminate\Console\Command;
class GenerateSitemap extends Command
{
/**
* @var string
*/
protected $signature = 'sitemap:generate';
/**
* @var string
*/
protected $description = 'Generate sitemaps for all site resources.';
/**
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle(ApiClient $apiClient)
{
return app(SitemapGenerator::class)->generate($apiClient);
}
}

View file

@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use App\NewsArticle;
use App\Services\Data\Contracts\NewsProviderInterface;
use App\Services\News\ImportNewsFromRemoteProvider;
use Carbon\Carbon;
use Illuminate\Console\Command;
class UpdateNewsFromRemote extends Command
{
/**
* @var string
*/
protected $signature = 'news:update';
/**
* @var string
*/
protected $description = 'Update news from currently selected 3rd party site.';
/**
* @return void
*/
public function handle()
{
app(ImportNewsFromRemoteProvider::class)->execute();
$this->info('News updated.');
}
}

32
app/Console/Kernel.php Normal file
View file

@ -0,0 +1,32 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View file

@ -0,0 +1,50 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

View file

@ -0,0 +1,271 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Jenssegers\Agent\Agent;
use Illuminate\Support\Facades\Cookie;
use GuzzleHttp\Client;
use App\Services\DeviceDetect;
class AdsController
{
protected $primary_buttons;
protected $primary_buttons_mobile;
protected $primary_buttons_android;
protected $primary_buttons_ios;
protected $primary_pops = '(AU|NZ)';
protected $mac_os_modal = '(XYZ)';
protected $us_secondary_link;
protected $primary_link;
protected $secondary_link;
// protected $pop_s2s_source = 'http://aringours.com/?tid=867257';
// protected $pop_s2s_source_secondary = 'http://aringours.com/?tid=867257';
// protected $pop_s2s_source_us = 'http://aringours.com/?tid=985767';
protected $pop_s2s_source;
protected $pop_s2s_source_secondary;
protected $pop_s2s_source_us;
protected $primary_soap2day = '(AU|NZ|SI)';
protected $primary_soap2day_mobile = '(AU|NZ|SI|SA)';
protected $primary_soap2day_mobile_no_android = '(XYZ)';
protected $primary_soap2day_mobile_no_ios = '(XYZ)';
public function __construct()
{
$this->primary_buttons = config('ads.buttons.countries.primary');
$this->primary_buttons_mobile = config('ads.buttons.countries.primary_mobile');
$this->primary_buttons_android = config('ads.buttons.countries.primary_android');
$this->primary_buttons_ios = config('ads.buttons.countries.primary_ios');
$this->pop_s2s_source = config('ads.pop.links.primary');
$this->pop_s2s_source_secondary = config('ads.pop.links.secondary');
$this->pop_s2s_source_us = config('ads.pop.links.primary_us');
$this->primary_link = config('ads.buttons.links.primary');
$this->secondary_link = config('ads.buttons.links.secondary');
$this->us_secondary_link = config('ads.buttons.links.secondary_us');
}
protected $direct = [];
protected $sources = [];
public function shouldGetModal($country_code) {
$agent = new Agent();
$is_primary = (bool) preg_match('~' . $this->primary_buttons . '~', $country_code);
$is_primary_mobile = (bool) preg_match('~' . $this->primary_buttons_mobile . '~', $country_code);
$is_primary_android = (bool) preg_match('~' . $this->primary_buttons_android . '~', $country_code);
if ($agent->isAndroidOS() && $is_primary_android) {
return true;
}
if ($agent->isMobile() && $is_primary_mobile) {
return true;
}
return $is_primary === true;
}
protected function getCountries():\stdClass
{
$req_src = 'all';
$get_src = 'true';
$client = new Client(['headers' => ['user-agent' => 'Putlocker FairFan Countries Service']]);
try {
$direct = true;
$response = $client->get('https://fairfan.com/api/availability.php?'.http_build_query(compact('req_src', 'get_src')));
$data = json_decode($response->getBody()->getContents());
$this->direct = $data->direct;
$this->sources = $data->sources;
return $data;
} catch (\Throwable $th) {
}
}
protected function getSourcesCountries()
{
return $this->sources;
}
public function isSourceCountry($country)
{
return in_array($country, $this->getSourcesCountries()) || $this->isFairfanDirectCountry($country);
}
protected function isFairfanDirectCountry($country) {
return in_array($country, $this->direct);
}
public function getFairfanLink($type, $tmdb_id, $country, $season = null, $episode = null)
{
$direct = $this->isFairfanDirectCountry($country);
$request_options = compact('type', 'tmdb_id', 'country');
if (isset($season)) {
$request_options = array_merge($request_options, compact('season', 'episode'));
$request_options['type'] = 'episode';
}
if ($direct) {
$request_options = array_merge($request_options, compact('direct'));
$client = new Client(['headers' => ['user-agent' => config('app.name') . ' FairFan Link Service']]);
try {
$response = $client->get('https://fairfan.com/api/availability.php?'.http_build_query($request_options));
$data = json_decode($response->getBody()->getContents());
if (isset($data->url)) {
return $data->url;
}
} catch (\Throwable $th) {
}
} else {
$client = new Client(['headers' => ['user-agent' => config('app.name') . ' FairFan Source Availability Service']]);
try {
$response = $client->get('https://fairfan.com/api/availability.php?'.http_build_query($request_options));
$data = json_decode($response->getBody()->getContents());
if (isset($data->url)) {
return $data->url;
}
} catch (\Throwable $th) {
}
}
return null;
}
public function isPrimaryCountry($country_code):bool
{
// return self::isCountry(self::$primary) || (($detect->isMobile() || $detect->isAndroidOS() || $detect->isiPadOS()) && self::isCountry(self::$primary_buttons_mobile));
$agent = new Agent();
return (bool) preg_match('~' . $this->primary_buttons . '~', $country_code) ||
(preg_match('~' . $this->primary_buttons_ios. '~', $country_code) && $agent->isiOS()) ||
(preg_match('~' . $this->primary_buttons_android. '~', $country_code) && $agent->isAndroidOS()) ||
(preg_match('~' . $this->primary_buttons_mobile. '~', $country_code) && $agent->isMobile()) ||
(preg_match('~' . $this->mac_os_modal. '~', $country_code) && $this->isMacOs($agent->getUserAgent()));
}
protected function isPrimaryPopCountry($country_code):bool
{
return (bool) preg_match('~' . $this->primary_pops . '~', $country_code);
}
protected function isMacOs($userAgent):bool
{
$dd = DeviceDetect::getDeviceDetector($userAgent);
return (bool) $dd->is_mac;
}
/**
* Get watch Button Link
*/
protected function getLink($country_code, $type, $id, $season = null, $episode = null):string
{
if ($this->isSourceCountry($country_code)) {
$link = $this->getFairfanLink($type, $id, $country_code, $season, $episode);
if (isset($link)) {
return $link;
}
}
$is_us = (bool) preg_match('~' . '(US)' . '~', $country_code);
if ($is_us) {
$this->secondary_link = $this->us_secondary_link;
}
$is_primary = (bool) preg_match('~' . $this->primary_buttons . '~', $country_code);
$is_primary_mobile = (bool) preg_match('~' . $this->primary_buttons_mobile . '~', $country_code);
$is_primary_android = (bool) preg_match('~' . $this->primary_buttons_android . '~', $country_code);
$is_primary_ios = (bool) preg_match('~' . $this->primary_buttons_ios . '~', $country_code);
$is_mac_os = (bool) preg_match('~' . $this->mac_os_modal . '~', $country_code);
$agent = new Agent();
return ($is_primary || ($is_primary_android && $agent->isAndroidOS()) || ($is_primary_ios && $agent->isiOS()) || ($is_primary_mobile && $agent->isMobile()) || ($is_mac_os && $this->isMacOs($agent->getUserAgent())) ) ? $this->primary_link : $this->secondary_link;
}
/**
* Watch Button
*/
public function index(Request $request, $type, $id, $season = null, $episode = null)
{
$this->getCountries();
$country_code = $request->headers->get('cf-ipcountry');
$link = $this->getLink($country_code, $type, $id, $season, $episode);
// $link = 'https://s.optzsrv.com/d.php?z=8278&sub=25';
// $link = 'https://intorterraon.com/4/5374775';
Cookie::queue('return', Str::random(5), 43200);
return view('loading', compact('link'));
}
public function getPop(Request $request)
{
$disabledCall = fn() => response('/* disabled */', 200, ['Content-Type' => 'application/javascript', 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0']);
$agent = new Agent();
if ($agent->isBot()) return $disabledCall();
$country_code = $request->headers->get('cf-ipcountry');
// primary countries
$isMobileCountry = (bool) preg_match('~' . config('ads.pop.countries.primary_mobile') . '~', $country_code);
$isMobileNoAndroidCountry = (bool) preg_match('~' . config('ads.pop.countries.primary_android') . '~', $country_code);
$isMobileNoIosCountry = (bool) preg_match('~' . config('ads.pop.countries.primary_ios') . '~', $country_code);
$isCountry = (bool) preg_match('~' . config('ads.pop.countries.primary') . '~', $country_code);
if ($isMobileNoAndroidCountry && ($agent->isMobile() && !$agent->isAndroidOS()) && !$request->hasCookie('return')) return $disabledCall();
if ($isMobileNoIosCountry && ($agent->isMobile() && !$agent->isiOS()) && !$request->hasCookie('return')) return $disabledCall();
if ($isMobileCountry && $agent->isMobile() && !$request->hasCookie('return')) return $disabledCall();
if ($isCountry && !$request->hasCookie('return')) return $disabledCall();
// // iOS new pop
// if (in_array($country_code, ['US','GB']) && $agent->isiOS()) {
// // do nothing, let the pop load
// } else {
// if ((in_array($country_code, ["US","AU","GB","CA","NZ"]) && !$request->hasCookie('return') && $agent->isMobile()) || (in_array($country_code, ['NZ']) && !$request->hasCookie('return'))) {
// return response('/* disabled */', 200, ['Content-Type' => 'application/javascript', 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0']);
// }
// }
return response($this->isPrimaryPopCountry($country_code) ? $this->getPopJs('primary', $country_code) : $this->getPopJs('secondary', $country_code), 200, ['Content-Type' => 'application/javascript', 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0']);
}
/**
* Get Js Script Data
*/
public function getPopJs($type, $country_code):string
{
$cache_key = implode('_', ['pop_js_neox', $type, $country_code]);
return Cache::remember($cache_key, 15*60, function() use ($type, $country_code){
return $type === 'primary' ? '/* primary '.$country_code.' */'.file_get_contents($country_code === 'US' ? $this->pop_s2s_source_us:$this->pop_s2s_source, false, stream_context_create(["ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
)])) : '/* secondary */'.file_get_contents($country_code === 'US' ? $this->pop_s2s_source_us : $this->pop_s2s_source_secondary, false, stream_context_create(["ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
)]));
});
}
}

View file

@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View file

@ -0,0 +1,92 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\SearchRequest;
use App\Models\News;
use App\Services\ApiClient;
use App\Services\TmdbClient;
use Illuminate\Http\Request;
use App\Supports\Traits\Helpers;
use Illuminate\Support\Str;
use App\Supports\Traits\CleanItems;
use App\Supports\Traits\TopContent;
use stdClass;
use Symfony\Component\HttpFoundation\Response;
class HomeController extends Controller
{
use CleanItems, TopContent;
public function index(ApiClient $api, TmdbClient $tmdb)
{
$meta = [];
$meta['title'] = config('site.home.title');
$meta['description'] = Str::limit(config('site.home.description'), 150);
$meta['full_description'] = config('site.home.description');
$meta['keywords'] = config('site.home.keywords', false);
$meta['image'] = asset('images/custom-icon.png');
$nowplaying = $this->formatTmdbResponse($tmdb->getNowPlayingMovies(1), false, [], 12)['data'];
$upcoming = $this->formatTmdbResponse($tmdb->getUpcomingMovies(1), false, [], 12)['data'];
$comingsoon = $this->formatTmdbResponse($tmdb->getComingSoonMovies(1), false, [], 6)['data'];
$airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data'];
$hero = $this->getHomeHeroSliderData($api->getTrendingMovies(1, 7), $tmdb);
// dd($hero);
$popular_movies = self::formatApiResponse($api->getPopularMovies(1, 12), false)['data'];
$popular_shows = self::formatApiResponse($api->getTrendingShows(1, 12), false, [], 12)['data'];
$trending_movies = self::formatApiResponse($api->getTrendingMovies(1, 12), false, [], 12)['data'];
$trending_shows = self::formatApiResponse($api->getTrendingShows(1, 12), false)['data'];
$recent_added = $trending_movies[4];
return view('home', compact('meta', 'hero', 'popular_movies', 'popular_shows', 'trending_movies', 'trending_shows', 'nowplaying', 'upcoming', 'comingsoon', 'airing', 'recent_added'));
}
public function homesearch()
{
$meta = [];
$meta['title'] = config('site.homesearch.title');
$meta['description'] = Str::limit(config('site.homesearch.description'), 150);
$meta['full_description'] = config('site.homesearch.description');
$meta['keywords'] = config('site.homesearch.keywords', false);
$meta['image'] = asset('images/custom-icon.png');
$content = config('site.homesearch.content');
return view('homesearch', compact('meta', 'content'));
}
public function search(SearchRequest $request, ApiClient $api, TmdbClient $tmdb)
{
$query = $request->validated()['search'];
$results = $tmdb->getSearch($query);
$data = $this->formatTmdbSearchResponse($results);
$meta = [];
$meta['title'] = config('site.search.title');
$meta['description'] = Str::replace(['{QUERY}'], $query, config('site.search.description'));
$meta['keywords'] = config('site.search.keywords', false);
$meta['image'] = asset('images/custom-icon.png');
$meta['page_title'] = 'Search Results for: '. $query;
// sleep(2);
return view('search', compact('data', 'meta'));
}
}

View file

@ -0,0 +1,166 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\MoreMoviesGenreRequest;
use App\Http\Requests\MoreMoviesRequest;
use App\Http\Resources\MoreTitles;
use DipeshSukhia\LaravelHtmlMinify\LaravelHtmlMinifyFacade;
use DipeshSukhia\LaravelHtmlMinify\Middleware\LaravelMinifyHtml;
use Illuminate\Http\Request;
use App\Services\ApiClient;
use App\Services\TmdbClient;
use App\Supports\Traits\CleanItems;
use Illuminate\Support\Facades\Cache;
use App\Supports\SchemaBuilder;
use Illuminate\Support\Facades\View;
use App\Supports\Traits\Helpers;
use App\Supports\Traits\TopContent;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Vite;
class MovieController extends Controller
{
use CleanItems, TopContent;
public function index(TmdbClient $tmdb, ApiClient $api, AdsController $adsController, string $id, string $slug)
{
$call = function() use($tmdb, $id){
$id = self::decodeId($id);
$data = $tmdb->getMovie($id);
// dd($movie);
// $data = $this->formatTmdbMovie($movie);
// dd($data);
// $data['meta']['title'] = 'Watch ' . $movie['title'];
return $data;
};
$results = $call();// Cache::remember(implode('__', ['movie', $id]),3600, $call);
$meta['schema'] = SchemaBuilder::getMovieSchema($results);
$data = $results;
// dd($data);
$top = $this->getTopContent($tmdb, $api);
// dd($tmdb->getUpcomingMovies(1),);
if (empty($data['similar']))
$data['similar'] = $this->formatApiResponse($api->getPopularMovies(1, 8), false)['data'];
$upcoming = $this->formatTmdbResponse($tmdb->getUpcomingMovies(1), false, [], 12)['data'];
$meta['title'] = Str::replace(['{TITLE}', '{YEAR}'], [$data['title'], $data['year']], config('site.movies.detail.title'));
$meta['description'] = Str::limit(Str::replace(['{TITLE}', '{OVERVIEW}'], [$data['title'], $data['overview']], config('site.movies.detail.description')), 150);// sprintf(config('site.movies.detail.description'), $data['overview']);
$meta['keywords'] = config('site.movies.detail.keywords');
$meta['image'] = $data['backdrop'];
$movie = $data;
// $modal = $adsController->shouldGetModal(request()->headers->get('cf-ipcountry', 'AU'));
return view('movie', compact('movie', 'upcoming', 'meta', 'top'));
}
public function movies( ApiClient $api, TmdbClient $tmdb, ?int $page = 1,)
{
$results = $this->formatApiResponse($api->getPopularMovies($page, 36),true, ['name' => Route::current()->getName()]);
$meta['title'] = config('site.movies.list.title', 'Popular Movies');
if ($page > 1) $meta['title'] .= sprintf(' - Page %s', $page);
$meta['page_title'] = config('site.movies.list.title', 'Popular Movies');
$meta['description'] = config('site.movies.list.description', 'Popular Movies');
$meta['keywords'] = config('site.movies.list.keywords');
$meta['image'] = asset('images/custom-icon.png');
$meta['route'] = Route::current();
$pagination = $results['pagination'];
// dd($pagination);
$data = $results['data'];
$type = 'movie';
$genre = false;
return view('list', compact('data', 'pagination', 'meta', 'type', 'genre'));
}
public function movies_more( ApiClient $api, TmdbClient $tmdb, MoreMoviesRequest $moreMoviesRequest)
{
$results = $this->formatApiResponse($api->getPopularMovies($moreMoviesRequest->validated()['page'], 36), true);
$items = MoreTitles::collection($results['data']);
$has_more_pages = $results['pagination']->hasMorePages();
$current_page = $results['pagination']->currentPage();
$html = LaravelHtmlMinifyFacade::htmlMinify(view('components.more_titles', compact('items'))->render());
return response()->json(compact('current_page', 'has_more_pages', 'html'));
}
public function movies_genre_more( ApiClient $api, TmdbClient $tmdb, MoreMoviesGenreRequest $moreMoviesRequest)
{
$genre = Helpers::getMovieGenreBySlug($moreMoviesRequest->validated()['genre']);
$results = $this->formatApiResponse($api->getGenreMovies($genre->id, $moreMoviesRequest->validated()['page'], 36), true);
$items = MoreTitles::collection($results['data']);
$has_more_pages = $results['pagination']->hasMorePages();
$current_page = $results['pagination']->currentPage();
$html = LaravelHtmlMinifyFacade::htmlMinify(view('components.more_titles', compact('items'))->render());
return response()->json(compact('current_page', 'has_more_pages', 'genre', 'html'));
}
public function genres( ApiClient $api, TmdbClient $tmdb, string $genre, ?int $page = 1)
{
$genre = Helpers::getMovieGenreBySlug($genre);
if (is_null($genre)) abort(404);
$results = $this->formatApiResponse($api->getGenreMovies($genre->id, $page, 36), true, ['name' => Route::current()->getName(), 'params' => ['genre' => $genre->slug]]);
$meta['title'] = sprintf(config('site.movies.genres.title', 'Genre Movies'), $genre->name);
if ($page > 1) $meta['title'] .= sprintf(' - Page %s', $page);
$meta['page_title'] = sprintf(config('site.movies.genres.title', 'Genre Movies'), $genre->name);
$meta['description'] = sprintf(config('site.movies.genres.description', 'Genre Movies'), $genre->name);
$meta['keywords'] = config('site.movies.genres.keywords', null);
$meta['image'] = asset('images/custom-icon.png');
$meta['route'] = Route::current();
$pagination = $results['pagination'];
// dd($pagination);
$data = $results['data'];
$type = 'movie';
return view('list', compact('data', 'pagination', 'meta', 'genre', 'type'));
}
public function country( ApiClient $api, TmdbClient $tmdb, string $country, ?int $page = 1)
{
$country = Helpers::getCountryBySlug($country);
if (is_null($country)) abort(404);
$results = $this->formatTmdbResponse($tmdb->getCountryMovies($country->code, $page), true, ['name' => Route::current()->getName(), 'params' => ['country' => $country->slug]]);
$meta['title'] = sprintf(config('site.movies.country.title', 'Genre Movies'), $country->name);
$meta['description'] = sprintf(config('site.movies.country.description', 'Genre Movies'), $country->name);
$meta['image'] = asset('images/custom.jpg');
$meta['route'] = 'movie';
$pagination = $results['pagination'];
$data = $results['data'];
if (defined('SHOULD_PRERENDER')) {
return view('prerender.list', compact('data', 'pagination', 'meta'));
}
$pagination = self::encodeForInertia($pagination);
$data = self::encodeForInertia($data ?? []);
$meta = self::encodeForInertia($meta ?? []) ;
}
public function toprated( ApiClient $api, TmdbClient $tmdb, ?int $page = 1)
{
$results = $this->formatTmdbResponse($tmdb->getTopRatedMovies($page), true, ['name' => Route::current()->getName()]);
$meta['title'] = config('site.movies.top-imdb.title', 'Top IMDb Movies');
$meta['description'] = config('site.movies.top-imd.description', 'Top IMDb Movies');
$meta['image'] = asset('images/custom.jpg');
$meta['route'] = 'movie';
$pagination = $results['pagination'];
$data = $results['data'];
if (defined('SHOULD_PRERENDER')) {
return view('prerender.list', compact('data', 'pagination', 'meta'));
}
$pagination = self::encodeForInertia($pagination);
$data = self::encodeForInertia($data ?? []);
$meta = self::encodeForInertia($meta ?? []) ;
return Inertia::render('List', compact('data', 'pagination', 'meta'));
}
}

View file

@ -0,0 +1,119 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreNewsRequest;
use App\Http\Requests\UpdateNewsRequest;
use App\Models\News;
use App\Services\News\ImportNewsFromRemoteProvider;
use App\Supports\Traits\CleanItems;
use Inertia\Inertia;
use Illuminate\Support\Str;
use App\Supports\Traits\Helpers;
class NewsController extends Controller
{
use CleanItems;
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$news = News::orderByDesc('created_at')->limit(10)->get();
return $news;
}
public function list( ?int $page = 1)
{
$paginatedData = News::orderByDesc('created_at')->paginate(10, ['*'], '', $page);
$results = $paginatedData->map(fn($item) => (Object)$item->toArray())->map(function($article){
$article->title = Str::limit($article->title, 60);
$article->body = Str::limit($article->body, 150);
$article->meta['image'] = Helpers::getImageFullUrl( $article->meta['image'], 320, 180);
return $article;
});
// dd($results);
$meta['title'] = config('site.news.list.title', 'Popular Movies');
$meta['description'] = config('site.news.list.description', 'Popular Movies');
$meta['image'] = asset('assets/images/fb-capture.png');
$meta['route'] = 'news';
$pagination = ['total' => $paginatedData->lastPage(), 'page' => $page];
$data = $results;
if (defined('SHOULD_PRERENDER')) {
return view('prerender.list', compact('data', 'pagination', 'meta'));
}
$pagination = self::encodeForInertia($pagination);
$data = self::encodeForInertia($data ?? []);
$meta = self::encodeForInertia($meta ?? []) ;
return Inertia::render('News', compact('data', 'pagination', 'meta'));
}
/**
* Display the specified resource.
*
* @param \App\Models\News $news
* @return \Illuminate\Http\Response
*/
public function show(News $news, $slug, $id)
{
$article = (Object)$news->find($id)->toArray();
dd($article);
if (defined('SHOULD_PRERENDER')) {
return view('prerender.list', compact('data', 'pagination', 'meta'));
}
return Inertia::render('News', compact('data', 'pagination', 'meta'));
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\News $news
* @return \Illuminate\Http\Response
*/
public function edit(News $news)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\UpdateNewsRequest $request
* @param \App\Models\News $news
* @return \Illuminate\Http\Response
*/
public function update(UpdateNewsRequest $request, News $news)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\News $news
* @return \Illuminate\Http\Response
*/
public function destroy(News $news)
{
//
}
/**
* @return JsonResponse
*/
public function importFromRemoteProvider()
{
app(ImportNewsFromRemoteProvider::class)->execute();
return $this->success();
}
}

View file

@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\ProfileUpdateRequest;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Inertia\Inertia;
use Inertia\Response;
class ProfileController extends Controller
{
/**
* Display the user's profile form.
*/
public function edit(Request $request): Response
{
return Inertia::render('Profile/Edit', [
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
'status' => session('status'),
]);
}
/**
* Update the user's profile information.
*/
public function update(ProfileUpdateRequest $request): RedirectResponse
{
$request->user()->fill($request->validated());
if ($request->user()->isDirty('email')) {
$request->user()->email_verified_at = null;
}
$request->user()->save();
return Redirect::route('profile.edit');
}
/**
* Delete the user's account.
*/
public function destroy(Request $request): RedirectResponse
{
$request->validate([
'password' => ['required', 'current_password'],
]);
$user = $request->user();
Auth::logout();
$user->delete();
$request->session()->invalidate();
$request->session()->regenerateToken();
return Redirect::to('/');
}
}

View file

@ -0,0 +1,209 @@
<?php
namespace App\Http\Controllers;
use DipeshSukhia\LaravelHtmlMinify\LaravelHtmlMinifyFacade;
use Illuminate\Http\Request;
use App\Services\ApiClient;
use App\Services\TmdbClient;
use App\Supports\SchemaBuilder;
use App\Supports\Traits\CleanItems;
use App\Supports\Traits\TopContent;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use Illuminate\Support\Str;
use App\Supports\Traits\Helpers;
use App\Http\Requests\MoreMoviesRequest;
use App\Http\Resources\MoreTitles;
class ShowController extends Controller
{
use CleanItems, TopContent;
public function index(TmdbClient $tmdb, ApiClient $api, int $id, string $slug = null )
{
$airing = [];
$call = function() use($tmdb, $id, &$season, &$airing){
$id = self::decodeId($id);
$show = $tmdb->getShow($id);
$data = $this->formatTmdbShow($show);
$airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data'];
return $data;
};
$results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call);
// dd($results);
$data = $results;
// dd($data);
// dd($data);
$meta['image'] = $data['backdrop'];
$meta['schema'] = SchemaBuilder::getShowSchema($results);
$meta['title'] = Str::replace(['{TITLE}'], [$data['title']], config('site.shows.detail.title'));
$meta['description'] = Str::limit(Str::replace(['{OVERVIEW}'], [$data['overview']], config('site.shows.detail.description')), 150);
$meta['keywords'] = config('site.shows.detail.keywords', '');
$is_show_page = false;
$show = $data;
// dd($season);
$season = false;
$episode = false;
return view('show', compact('show', 'season', 'meta', 'is_show_page', 'airing', 'episode'));
}
public function season(TmdbClient $tmdb, ApiClient $api, int $id, int $season = null, string $slug = null )
{
$airing = [];
$is_show_page = is_null($season);
$call = function() use($tmdb, $id, &$season, &$airing){
$id = self::decodeId($id);
$show = $tmdb->getShow($id);
$data = $this->formatTmdbShow($show);
if (isset($season)) {
$season_number = (int)$season;
// dd($movie);
$season = $tmdb->getSeason($show['id'], $season_number);
$season = $this->formatTmdbSeason($season, $show);
}
$airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data'];
// dd($data);
// $data['meta']['title'] = 'Watch ' . $movie['title'];
return $data;
};
$results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call);
// dd($results);
$data = $results;
// dd($data);
// dd($data);
$meta['image'] = $data['backdrop'];
$show = $data;
$episode = false;
$meta['schema'] = SchemaBuilder::getShowSeasonSchema($results, $season);
$meta['title'] = Str::replace(['{TITLE}', '{SEASON}', '{SEASON_TITLE}'], [$data['title'], $season['season_number'], $season['name']], config('site.shows.detail_season.title'));
$meta['description'] = Str::limit(Str::replace(['{OVERVIEW}', '{SEASON}'], [ !empty($season['overview']) ? $season['overview'] : sprintf('Season %s - ', $season['season_number']) . $data['overview'], $season['season_number']], config('site.shows.detail_season.description')), 150);
$meta['keywords'] = config('site.shows.detail_season.keywords');
// dd($season);
return view('show', compact('show', 'season', 'meta', 'is_show_page', 'airing', 'episode'));
}
public function episode(TmdbClient $tmdb, ApiClient $api, AdsController $adsController, int $id, int $season, int $episode, string $slug)
{
$similar = [];
$season_number = $season;
$episode_number = $episode;
$call = function() use($tmdb, $id, &$season, &$episode, &$similar, $season_number, $episode_number){
$id = self::decodeId($id);
$show = $tmdb->getShow($id);
$data = $this->formatTmdbShow($show);
$season = $tmdb->getSeason($show['id'], $season_number);
$season = $this->formatTmdbSeason($season);
$episode = $tmdb->getEpisode($show['id'], $season_number, $episode_number);
$episode = $this->formatTmdbEpisode($episode);
// $episode
// dd($data);
// $data['meta']['title'] = 'Watch ' . $movie['title'];
return $data;
};
$results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call);
// dd($results);
$meta['schema'] = SchemaBuilder::getShowEpisodeSchema($results, $season, $episode);
$data = $results;
$top = $this->getTopContent($tmdb, $api);
// dd($data);
// dd($upcoming);
$meta['title'] = Str::replace(['{TITLE}', '{SEASON}', '{EPISODE}', '{EPISODE_TITLE}'], [$data['title'], $season_number, $episode_number, $episode['name']], config('site.shows.detail_episode.title'));
$meta['description'] = Str::limit(Str::replace(['{OVERVIEW}', '{SEASON}', '{EPISODE}'], [$episode['overview'], $season_number, $episode_number], config('site.shows.detail_episode.description')), 150);
$meta['image'] = $episode['backdrop'];
$meta['keywords'] = config('site.shows.detail_episode.keywords');
// dd($season);
if (defined('SHOULD_PRERENDER')) {
return view('prerender.show', compact('data', 'season', 'episode', 'meta', 'top'));
}
$modal = $adsController->shouldGetModal(request()->headers->get('cf-ipcountry', 'AU'));
$meta = self::encodeForInertia($meta ?? []) ;
$top = self::encodeForInertia($top);
$data = self::encodeForInertia($data ?? []);
$season = self::encodeForInertia($season ?? []);
$episode = self::encodeForInertia($episode ?? []);
return Inertia::render('Show', compact('data', 'season', 'episode', 'meta', 'top', 'modal'));
}
public function shows( ApiClient $api, TmdbClient $tmdb, ?int $page = 1,)
{
$results = $this->formatApiResponse($api->getPopularShows($page, 36), true, ['name' => Route::current()->getName()]);
$meta['title'] = config('site.shows.list.title', 'Popular Shows');
if ($page > 1) $meta['title'] .= sprintf(' - Page %s', $page);
$meta['page_title'] = config('site.shows.list.title', 'Popular Shows');
$meta['description'] = config('site.shows.list.description', 'Popular Shows');
$meta['keywords'] = config('site.shows.list.keywords', false);
$meta['image'] = asset('images/custom-icon.png');
$meta['type'] = 'TV Shows';
$meta['route'] = Route::current();
$pagination = $results['pagination'];
$data = $results['data'];
$type = 'show';
$genre = false;
return view('list', compact('data', 'pagination', 'meta', 'type', 'genre'));
}
public function shows_more( ApiClient $api, TmdbClient $tmdb, MoreMoviesRequest $moreMoviesRequest)
{
$results = $this->formatApiResponse($api->getPopularShows($moreMoviesRequest->validated()['page'], 36), true);
$items = MoreTitles::collection($results['data']);
$has_more_pages = $results['pagination']->hasMorePages();
$current_page = $results['pagination']->currentPage();
$html = LaravelHtmlMinifyFacade::htmlMinify(view('components.more_titles', compact('items'))->render());
return response()->json(compact('current_page', 'has_more_pages', 'html'));
}
public function genres( ApiClient $api, TmdbClient $tmdb, string $genre, ?int $page = 1)
{
$genre = Helpers::getShowGenreBySlug($genre);
if (is_null($genre)) abort(404);
$results = $this->formatApiResponse($api->getGenreShows($genre->id, $page, 36), true, ['name' => Route::current()->getName(), 'params' => ['genre' => $genre->slug]]);
$meta['title'] = sprintf(config('site.shows.genres.title', 'Genre Shows'), $genre->name);
if ($page > 1) $meta['title'] .= sprintf(' - Page %s', $page);
$meta['page_title'] = sprintf(config('site.shows.genres.title', 'Genre Shows'), $genre->name);
$meta['description'] = sprintf(config('site.shows.genres.description', 'Genre Shows'), $genre->name);
$meta['keywords'] = config('site.shows.genres.keywords');
$meta['image'] = asset('images/custom-icon.png');
$meta['route'] = Route::current();
$pagination = $results['pagination'];
// dd($pagination);
$data = $results['data'];
$type = 'show';
return view('list', compact('data', 'pagination', 'meta', 'genre', 'type'));
}
}

76
app/Http/Kernel.php Normal file
View file

@ -0,0 +1,76 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array<int, class-string|string>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\RedirectIfInsecure::class,
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
// Middleware to minify Blade
];
/**
* The application's route middleware groups.
*
* @var array<string, array<int, class-string|string>>
*/
protected $middlewareGroups = [
'web' => [
// \App\Http\Middleware\EncryptCookies::class,
// \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
// \Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\View\Middleware\ShareErrorsFromSession::class,
// \App\Http\Middleware\VerifyCsrfToken::class,
// \App\Http\Middleware\AddLinkHeadersForPreloadedFonts::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class,
\DipeshSukhia\LaravelHtmlMinify\Middleware\LaravelMinifyHtml::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
// 'prerenderIfCrawler' => \App\Http\Middleware\PrerenderIfCrawler::class,
// 'blockAdLink' => \App\Http\Middleware\BlockAdLink::class,
];
}

View file

@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Support\Collection;
class AddLinkHeadersForPreloadedFonts
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Illuminate\Http\Response
*/
public function handle($request, $next)
{
return tap($next($request), function ($response) {
if (config('fonts') !== []) {
$response->header('Link', Collection::make(config('fonts'))
->map(fn ($url) => "<{$url}>; " . 'rel="preload"; as=font; type="font/woff2"; crossorigin')
->join(', '));
}
});
}
}

View file

@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View file

@ -0,0 +1,90 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class BlockAdLink
{
protected $crawlerUserAgents = [
'Chrome-Lighthouse',
'google',
'Yahoo! Slurp',
'bingbot',
'yandex',
'baiduspider',
'facebookexternalhit',
'twitterbot',
'rogerbot',
'linkedinbot',
'embedly',
'quora link preview',
'showyoubot',
'outbrain',
'pinterest/0.',
'slackbot',
'vkShare',
'W3C_Validator',
'redditbot',
'Applebot',
'WhatsApp',
'flipboard',
'tumblr',
'bitlybot',
'SkypeUriPreview',
'nuzzel',
'Discordbot',
'Qwantify',
'pinterestbot',
'Bitrix link preview',
'XING-contenttabreceiver',
'developers.google.com/+/web/snippet',
];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, string $routeName = null)
{
if ($this->shouldBlock($request)) {
// abort(403, 'Unauthorized', ['X-Robots-Tag' => 'noindex, nofollow']);
return response('', 200)
->header('X-Robots-Tag', 'noindex, nofollow')
->header('Content-Type', 'application/javascript');
exit;
}
return $next($request);
}
protected function shouldBlock(Request $request): bool
{
$userAgent = strtolower($request->server->get('HTTP_USER_AGENT'));
$bufferAgent = $request->server->get('X-BUFFERBOT');
$shouldBlock = false;
if ( ! $userAgent) return false;
if ( ! $request->isMethod('GET')) return false;
// prerender if _escaped_fragment_ is in the query string
if ($request->query->has('_escaped_fragment_')) $shouldBlock = true;
// prerender if a crawler is detected
foreach ($this->crawlerUserAgents as $crawlerUserAgent) {
if (Str::contains($userAgent, strtolower($crawlerUserAgent))) {
$shouldBlock = true;
}
}
if ($bufferAgent) $shouldBlock = true;
return $shouldBlock;
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,90 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class PrerenderIfCrawler
{
protected $crawlerUserAgents = [
'Yahoo! Slurp',
'bingbot',
'yandex',
'baiduspider',
'facebookexternalhit',
'twitterbot',
'rogerbot',
'linkedinbot',
'embedly',
'quora link preview',
'showyoubot',
'outbrain',
'pinterest/0.',
'slackbot',
'vkShare',
'W3C_Validator',
'redditbot',
'Applebot',
'WhatsApp',
'flipboard',
'tumblr',
'bitlybot',
'SkypeUriPreview',
'nuzzel',
'Discordbot',
'Qwantify',
'pinterestbot',
'Bitrix link preview',
'XING-contenttabreceiver',
'developers.google.com/+/web/snippet',
];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, string $routeName = null)
{
if ($this->shouldPrerender($request)) {
define('SHOULD_PRERENDER', true);
// Always fallback to client routes if not prerendering
// otherwise prerender routes will override client side routing
} else if ($routeName !== 'homepage') {
// return app(HomeController::class)->show();
}
return $next($request);
}
protected function shouldPrerender(Request $request): bool
{
$userAgent = strtolower($request->server->get('HTTP_USER_AGENT'));
$bufferAgent = $request->server->get('X-BUFFERBOT');
$shouldPrerender = false;
if ( ! $userAgent) return false;
if ( ! $request->isMethod('GET')) return false;
// prerender if _escaped_fragment_ is in the query string
if ($request->query->has('_escaped_fragment_')) $shouldPrerender = true;
// prerender if a crawler is detected
foreach ($this->crawlerUserAgents as $crawlerUserAgent) {
if (Str::contains($userAgent, strtolower($crawlerUserAgent))) {
$shouldPrerender = true;
}
}
if ($bufferAgent) $shouldPrerender = true;
return $shouldPrerender;
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
class RedirectIfInsecure
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// if not local environment AND the request isn't safe
if (!app()->isLocal() && !$request->secure()) {
// redirect to the mathching secure url
// return redirect()->secure($request->path());
}
return $next($request);
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
}

View file

@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array<int, string>|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}

View file

@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
class ValidateSignature extends Middleware
{
/**
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $except = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source',
// 'utm_term',
];
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,85 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
*/
public function rules(): array
{
return [
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function authenticate(): void
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function ensureIsNotRateLimited(): void
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
}
/**
* Get the rate limiting throttle key for the request.
*/
public function throttleKey(): string
{
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests;
use App\Supports\Traits\Helpers;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class MoreMoviesGenreRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'genre' => ['string', 'required', Rule::in(Helpers::getMovieGenreList()->pluck('slug'))],
'page' => 'integer|required'
];
}
}

View file

@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class MoreMoviesRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
// 'route' => 'string|required',
'page' => 'integer|required'
];
}
}

View file

@ -0,0 +1,23 @@
<?php
namespace App\Http\Requests;
use App\Models\User;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ProfileUpdateRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)],
];
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class SearchRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'search' => 'required|min:2'
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreNewsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
//
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateNewsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
//
];
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class MoreTitles extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this['id'],
'title' => $this['title'],
'route' => $this['route'],
'slug' => $this['slug'],
'image' => $this['image'],
];
// return parent::toArray($request);
}
}

15
app/Models/News.php Normal file
View file

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class News extends Model
{
use HasFactory;
public function getMetaAttribute()
{
return json_decode($this->attributes['meta'], true);
}
}

51
app/Models/User.php Normal file
View file

@ -0,0 +1,51 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'admins';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}

View file

@ -0,0 +1,94 @@
<?php
namespace App\Policies;
use App\Models\News;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class NewsPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function viewAny(User $user)
{
//
}
/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $user
* @param \App\Models\News $news
* @return \Illuminate\Auth\Access\Response|bool
*/
public function view(User $user, News $news)
{
//
}
/**
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function create(User $user)
{
//
}
/**
* Determine whether the user can update the model.
*
* @param \App\Models\User $user
* @param \App\Models\News $news
* @return \Illuminate\Auth\Access\Response|bool
*/
public function update(User $user, News $news)
{
//
}
/**
* Determine whether the user can delete the model.
*
* @param \App\Models\User $user
* @param \App\Models\News $news
* @return \Illuminate\Auth\Access\Response|bool
*/
public function delete(User $user, News $news)
{
//
}
/**
* Determine whether the user can restore the model.
*
* @param \App\Models\User $user
* @param \App\Models\News $news
* @return \Illuminate\Auth\Access\Response|bool
*/
public function restore(User $user, News $news)
{
//
}
/**
* Determine whether the user can permanently delete the model.
*
* @param \App\Models\User $user
* @param \App\Models\News $news
* @return \Illuminate\Auth\Access\Response|bool
*/
public function forceDelete(User $user, News $news)
{
//
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Providers;
use App\Services\ApiClient;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
class ApiServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton(ApiClient::class, function ($app) {
return new ApiClient(
$app['config']['services']['api']['api_url'],
$app['config']['services']['api']['per_page'],
$app['config']['services']['api']['domain_src'],
$app['config']['services']['api']['use_cache'],
$app['config']['services']['api']['cache_ttl'],
);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [ApiClient::class];
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace App\Providers;
use App\Services\Data\Contracts\NewsProviderInterface;
use App\Services\Data\News\ImdbNewsProvider;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// bind news provider
$this->app->bind(
NewsProviderInterface::class,
ImdbNewsProvider::class
);
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// dd($this->app['request']->headers->get('x-forwarded-host'));
$this->app['request']->server->set('HTTPS', true);
if ($this->app['request']->headers->has('x-forwarded-host')) {
$this->app['url']->forceRootUrl('https://'.$this->app['request']->server->get('HTTP_X_FORWARDED_HOST'));
}
// if (env('APP_ENV') !== 'local') {
// }
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}

View file

@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*
* @return bool
*/
public function shouldDiscoverEvents()
{
return false;
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class HelperServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
foreach (glob(app()->basePath('app').'/Supports/*.php') as $filename){
require_once($filename);
}
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}

View file

@ -0,0 +1,52 @@
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/dashboard';
/**
* Define your route model bindings, pattern filters, and other route configuration.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
}

View file

@ -0,0 +1,46 @@
<?php
namespace App\Providers;
use App\Services\TmdbClient;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
class TmdbServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton(TmdbClient::class, function ($app) {
return new TmdbClient(
$app['config']['services']['tmdb']['key'],
$app['config']['services']['tmdb']['use_cache'],
$app['config']['services']['tmdb']['cache_ttl'],
);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [TmdbClient::class];
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}

214
app/Services/ApiClient.php Normal file
View file

@ -0,0 +1,214 @@
<?php
namespace App\Services;
use App\Option;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Cache;
class ApiClient
{
private $url;
private $per_page;
private $use_cache;
private $cache_time;
private $domain_src;
public function __construct($url, $per_page, $domain_src, $use_cache = true, $cache_time = 3600)
{
$this->url = Str::endsWith($url, '/') ? $url : $url . '/';
$this->per_page = $per_page;
$this->use_cache = $use_cache;
$this->cache_time = $cache_time;
$this->domain_src = $domain_src;
}
public function getMovie(int $id)
{
$action = sprintf('movie/%s', $id);
if ($this->use_cache === true) {
$key = $action . $this->page . $this->language;
$results = Cache::remember($key, $this->cache_time, function () use ($action) {
return $this->_call($action);
});
} else {
$results = $this->_call($action);
}
return $results;
}
public function getMoviesByTag(String $title, $page = 1)
{
$path = sprintf('movie/tag/%s', $this->per_page);
$options = [
'page' => $page,
'title' => urlencode(Str::of($title)->replace('-', ' ')->title())
];
$key = Str::slug(implode(' ', [$path, $title, $page]), '_');
if ($this->use_cache === true) {
$results = Cache::remember($key, $this->cache_time, function () use ($path, $options, $key) {
return $this->_call($path, $options);
});
} else {
$results = $this->_call($path, $options);
}
return $results;
}
public function getShowsByTag(String $title, $page = 1)
{
$path = sprintf('show/tag/%s', $this->per_page);
$options = [
'page' => $page,
'title' => urlencode(Str::of($title)->replace('-', ' ')->title())
];
$key = Str::slug(implode(' ', [$path, $title, $page]), '_');
if ($this->use_cache === true) {
$results = Cache::remember($key, $this->cache_time, function () use ($path, $options, $key) {
return $this->_call($path, $options);
});
} else {
$results = $this->_call($path, $options);
}
return $results;
}
public function getPopularMovies($page = 1, $per_page = null)
{
$per_page = is_null($per_page) ? $this->per_page : $per_page;
$path = 'movie/popular/' . $this->domain_src . '/' . $per_page;
$options = compact('page');
$key = Str::slug($path . ' ' . $page, '_');
if ($this->use_cache === true) {
$results = Cache::remember($key, $this->cache_time, function () use ($path, $options) {
return $this->_call($path, $options);
});
} else {
$results = $this->_call($path, $options);
}
return $results;
}
public function getPopularShows($page = 1, $per_page = null)
{
$per_page = is_null($per_page) ? $this->per_page : $per_page;
$path = 'show/popular/' . $this->domain_src . '/' . $per_page;
$options = compact('page');
$key = Str::slug($path . ' ' . $page, '_');
if ($this->use_cache === true) {
$results = Cache::remember($key, $this->cache_time, function () use ($path, $options) {
return $this->_call($path, $options);
});
} else {
$results = $this->_call($path, $options);
}
return $results;
}
public function getTrendingMovies($page = 1, $per_page = null)
{
$per_page = is_null($per_page) ? $this->per_page : $per_page;
$path = 'movie/trending/' . $this->domain_src . '/' . $per_page;
$options = compact('page');
$key = Str::slug($path . ' ' . $page, '_');
if ($this->use_cache === true) {
$results = Cache::remember($key, $this->cache_time, function () use ($path, $options) {
return $this->_call($path, $options);
});
} else {
$results = $this->_call($path, $options);
}
return $results;
}
public function getTrendingShows($page = 1, $per_page = null)
{
$per_page = is_null($per_page) ? $this->per_page : $per_page;
$path = 'show/trending/' . $this->domain_src . '/' . $per_page;
$options = compact('page');
$key = Str::slug($path . ' ' . $page, '_');
if ($this->use_cache === true) {
$results = Cache::remember($key, $this->cache_time, function () use ($path, $options) {
return $this->_call($path, $options);
});
} else {
$results = $this->_call($path, $options);
}
return $results;
}
public function getGenreMovies($id, $page = 1, $per_page = null)
{
$per_page = is_null($per_page) ? $this->per_page : $per_page;
$path = 'movie/popular/' . $this->domain_src . '/' . $per_page;
$options = [
'page' => $page,
'genre_id' => $id
];
$key = Str::slug(implode(' ', [$path, $id, $page, $per_page]), '_');
if ($this->use_cache === true) {
$results = Cache::remember($key, $this->cache_time, function () use ($path, $options) {
return $this->_call($path, $options);
});
} else {
$results = $this->_call($path, $options);
}
return $results;
}
public function getGenreShows($id, $page = 1, $per_page = null)
{
$per_page = is_null($per_page) ? $this->per_page : $per_page;
$path = 'show/popular/' . $this->domain_src . '/' . $per_page;
$options = [
'page' => $page,
'genre_id' => $id
];
$key = Str::slug(implode(' ', [$path, $id, $page, $per_page]), '_');
if ($this->use_cache === true) {
$results = Cache::remember($key, $this->cache_time, function () use ($path, $options) {
return $this->_call($path, $options);
});
} else {
$results = $this->_call($path, $options);
}
return $results;
}
private function _call(string $path, array $options = [])
{
$url = empty($options) ? $this->url . $path : $this->url . $path . '?' . Arr::query($options);
// $response = Http::get($url);
$response = Http::withHeaders(['referer' => route('home')])->get($url);
if (!$response) {
return false;
}
$body = $response->getBody();
$results = json_decode($body);
if (isset($results->status_code)) {
abort(403, $results->status_message);
}
return json_decode($body);
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Services\Data\Contracts;
use Illuminate\Support\Collection;
interface NewsProviderInterface
{
/**
* @return Collection
*/
public function getArticles(int $limit = 10);
/**
* @return Collection
*/
public function getSingleArticle(string $slug);
}

View file

@ -0,0 +1,60 @@
<?php
namespace App\Services\Data\News;
use GuzzleHttp\Client;
use Symfony\Component\DomCrawler\Crawler;
use App\Services\Data\Contracts\NewsProviderInterface;
use Illuminate\Support\Str;
class ImdbNewsProvider implements NewsProviderInterface
{
/**
* @var Client
*/
private $http;
public function __construct(Client $http)
{
$this->http = $http;
}
public function getArticles(int $limit = 10)
{
$articles = [];
$html = $this->http->get('https://www.imdb.com/news/movie', ['headers' => ['User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' ]])->getBody()->getContents();
$strippedHtml = preg_replace('/<script(.*?)>(.*?)<\/script>/is', '', $html);
$crawler = new Crawler($strippedHtml);
// grab every news article on the page
$articles = $crawler->filter('.ipc-page-section .ipc-list-card')->each(function(Crawler $node) {
try {
return [
'title' => $node->filter('a.ipc-link')->text(),
'body' => Str::beforeLast($node->filter('.ipc-html-content-inner-div')->text(), 'See full article at '),
'meta' => [
'date' => $node->filter('.ipc-inline-list .ipc-inline-list__item')->first()->text(),
'author' => Str::replaceFirst('by ', '',$node->filter('.ipc-inline-list')->children('.ipc-inline-list__item')->eq(1)->text()),
'source' => Str::afterLast($node->filter('.ipc-html-content-inner-div')->text(), 'See full article at '),
'image' => substr($node->filter('img.ipc-image')->attr('src'), 0, strpos($node->filter('img.ipc-image')->attr('src'), '._')) . '.jpg',
'url' => $node->filter('a.ipc-link')->attr('href'),
]
];
// dump($d);
// throw new \Exception("Error Processing Request", 1);
} catch (\Throwable $th) {
// throw $th;
}
});
return collect(array_filter($articles));
}
public function getSingleArticle(string $slug)
{
}
}

View file

@ -0,0 +1,88 @@
<?php
namespace App\Services;
use DeviceDetector\ClientHints;
use DeviceDetector\DeviceDetector;
use DeviceDetector\Parser\Device\AbstractDeviceParser;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use DeviceDetector\Parser\OperatingSystem;
use DeviceDetector\Parser\Client\Browser;
use Illuminate\Support\Str;
use stdClass;
class DeviceDetect {
public static function getDeviceDetector($userAgent = null):stdClass
{
AbstractDeviceParser::setVersionTruncation(AbstractDeviceParser::VERSION_TRUNCATION_NONE);
$clientHints = ClientHints::factory($_SERVER);
$dd = new DeviceDetector($userAgent, $clientHints);
$dd->discardBotInformation();
$dd->skipBotDetection();
if (is_null($userAgent)) {
return (Object)[
'os' => null,
'browser' => null,
'device' => null,
'is_bot' => null,
'is_safari' => null,
'is_chrome' => null,
'is_mobile' => null,
'is_mac' =>null,
'is_windows' =>null,
];
}
AbstractDeviceParser::setVersionTruncation(AbstractDeviceParser::VERSION_TRUNCATION_NONE);
$clientHints = ClientHints::factory($_SERVER);
$dd = new DeviceDetector($userAgent, $clientHints);
$dd->discardBotInformation();
$dd->skipBotDetection();
$redisConnection = RedisAdapter::createConnection('redis:///var/lib/redis/redis.sock/14');
$cache = new RedisAdapter($redisConnection, 43200);
// $cache = new ApcuAdapter();
$data = $cache->get(Str::slug($userAgent).'_', function() use ($cache, $dd) {
$dd->setCache(
new \DeviceDetector\Cache\PSR6Bridge($cache)
);
$dd->parse();
$osFamily = OperatingSystem::getOsFamily($dd->getOs('name'));
$browserFamily = Browser::getBrowserFamily($dd->getClient('name'));
if ($dd->isTablet() || $dd->isPhablet()) {
$viewport = 'tablet';
} else if ($dd->isSmartphone() || $dd->isFeaturePhone()) {
$viewport = 'phone';
} else {
$viewport = 'desktop';
}
$data = (Object)[
'os' => $osFamily,
'browser' => $browserFamily,
'device' => $dd->getDeviceName(),
'is_bot' => $dd->isBot(),
'is_safari' => 'Safari' === $browserFamily,
'is_chrome' => 'Chrome' === $browserFamily,
'is_mobile' => 'phone' === $viewport,
'is_mac' => 'Mac' === $osFamily,
'is_windows' => 'Windows' === $osFamily,
];
if ($data->is_bot) {
$data->bot = $dd->getBot()['name'] ?? null;
}
return $data;
});
return $data;
}
}

View file

@ -0,0 +1,55 @@
<?php
namespace App\Services\News;
use App\Models\News as NewsArticle;
use App\Services\Data\Contracts\NewsProviderInterface;
use Carbon\Carbon;
use Illuminate\Support\Str;
class ImportNewsFromRemoteProvider
{
/**
* @var NewsProviderInterface
*/
private $newsProvider;
/**
* @var NewsArticle
*/
private $newsArticle;
/**
* @param NewsProviderInterface $newsProvider
* @param NewsArticle $newsArticle
*/
public function __construct(
NewsProviderInterface $newsProvider,
NewsArticle $newsArticle
) {
$this->newsProvider = $newsProvider;
$this->newsArticle = $newsArticle;
}
public function execute()
{
$newArticles = $this->newsProvider->getArticles()->map(function($article) {
$article['slug'] = Str::slug(Str::limit($article['title'], 50));
$article['meta'] = json_encode($article['meta']);
$article['created_at'] = Carbon::now();
$article['updated_at'] = Carbon::now();
return $article;
});
$existing = $this->newsArticle->whereIn('slug', $newArticles->pluck('slug'))->get();
// filter out already existing articles
$newArticles = $newArticles->filter(function($newArticle) use($existing) {
return ! $existing->first(function($existingArticle) use($newArticle) {
return $existingArticle['title'] === $newArticle['title'] || $existingArticle['slug'] === $newArticle['slug'];
});
})->unique('slug');
$this->newsArticle->insert($newArticles->toArray());
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Services;
use samdark\sitemap\Sitemap;
use App\Services\ApiClient;
use App\Supports\Traits\CleanItems;
class SitemapGenerator {
use CleanItems;
public function generate(ApiClient $api)
{
$sitemap = new Sitemap(public_path('sitemap.xml'));
$movies = $this->formatApiResponse($api->getTrendingMovies(1, 500), false)['data'];
$shows = $this->formatApiResponse($api->getTrendingShows(1, 500), false)['data'];
foreach ($movies as $key => $movie) {
if ($movie['slug'] === '') continue;
$sitemap->addItem(route('movie', ['id' => $movie['id'], 'slug' => $movie['slug']]), time(), Sitemap::DAILY, 0.9);
}
foreach ($shows as $key => $show) {
if ($show['slug'] === '') continue;
$sitemap->addItem(route('show', ['id' => $show['id'], 'slug' => $show['slug']]), time(), Sitemap::DAILY, 0.9);
}
$sitemap->write();
// dd($movies);
}
}

275
app/Services/TmdbClient.php Normal file
View file

@ -0,0 +1,275 @@
<?php
namespace App\Services;
use App\Http\Resources\MovieDetail;
use App\Services\TmdbClient as ServicesTmdbClient;
use App\Supports\Traits\CleanItems;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
use Tmdb\Client;
use Tmdb\Event\BeforeRequestEvent;
use Tmdb\Event\Listener\Request\AcceptJsonRequestListener;
use Tmdb\Event\Listener\Request\ApiTokenRequestListener;
use Tmdb\Event\Listener\Request\ContentTypeJsonRequestListener;
use Tmdb\Event\Listener\Request\UserAgentRequestListener;
use Tmdb\Event\RequestEvent;
use Tmdb\Token\Api\ApiToken;
use Tmdb\Token\Api\BearerToken;
use Tmdb\Event\Listener\Psr6CachedRequestListener;
use Tmdb\Event\Listener\Request\LanguageFilterRequestListener;
use Tmdb\Event\Listener\Request\RegionFilterRequestListener;
class TmdbClient
{
use CleanItems;
private static $instance;
private $ttl = 3600*24;
private $use_cache = true;
/** @var Client $client **/
public $client;
private static $api_keys = ['aba8176c9250ba755ca1783de87528a2', '5c6763d6500cc611d442a5414e951c05'];
public function __construct($tmdb_key = null, $use_cache = false, $cache_time = 3600)
{
// 5c6763d6500cc611d442a5414e951c05
$this->ttl = $cache_time;
$this->use_cache = $use_cache;
$api_key_key = array_rand(self::$api_keys);
if(!defined("TMDB_API_KEY")){
define('TMDB_API_KEY', self::$api_keys[$api_key_key]);
}
$token = defined('TMDB_BEARER_TOKEN') && TMDB_BEARER_TOKEN !== 'TMDB_BEARER_TOKEN' ?
new BearerToken(TMDB_BEARER_TOKEN) :
new ApiToken(TMDB_API_KEY);
$ed = new \Symfony\Component\EventDispatcher\EventDispatcher();
$client = new Client(
[
/** @var ApiToken|BearerToken */
'api_token' => $token,
'event_dispatcher' => [
'adapter' => $ed
],
// We make use of PSR-17 and PSR-18 auto discovery to automatically guess these, but preferably set these explicitly.
'http' => [
'client' => null,
'request_factory' => null,
'response_factory' => null,
'stream_factory' => null,
'uri_factory' => null,
]
]
);
/**
* Required event listeners and events to be registered with the PSR-14 Event Dispatcher.
*/
// $cache = new FilesystemAdapter('php-tmdb', 86400, '/home/cache');
$redisConnection = RedisAdapter::createConnection('redis:///var/lib/redis/redis.sock/15');
$cache = new RedisTagAwareAdapter($redisConnection, 43200);
// $requestListener = new RequestListener($client->getHttpClient(), $ed);
$requestListener = new Psr6CachedRequestListener(
$client->getHttpClient(),
$ed,
$cache,
$client->getHttpClient()->getPsr17StreamFactory(),
[]
);
$ed->addListener(RequestEvent::class, $requestListener);
$apiTokenListener = new ApiTokenRequestListener($client->getToken());
$ed->addListener(BeforeRequestEvent::class, $apiTokenListener);
$acceptJsonListener = new AcceptJsonRequestListener();
$ed->addListener(BeforeRequestEvent::class, $acceptJsonListener);
$jsonContentTypeListener = new ContentTypeJsonRequestListener();
$ed->addListener(BeforeRequestEvent::class, $jsonContentTypeListener);
$userAgentListener = new UserAgentRequestListener();
$ed->addListener(BeforeRequestEvent::class, $userAgentListener);
// $regionFilerListener = new RegionFilterRequestListener();
// $ed->addListener(BeforeRequestEvent::class, $regionFilerListener);
// $languageFilerListener = new LanguageFilterRequestListener();
// $ed->addListener(BeforeRequestEvent::class, $languageFilerListener);
$this->client = $client;
// self::$client = $client;
}
/**
* @return Client
*/
public static function getClient() {
// Check is $_instance has been set
if(!isset(self::$instance))
{
// Creates sets object to instance
self::$instance = new TmdbClient();
}
// Returns the instance
return self::$instance::$client;
}
public function getMovie(int $id)
{
try {
$call = fn() => $this->formatTmdbMovie($this->client->getMoviesApi()->getMovie($id, ['append_to_response'=>'credits,videos,similar,keywords']));
if ($this->use_cache)
return Cache::remember('movie'.$id, $this->ttl, $call);
return $call();
} catch (\Throwable $th) {
return abort(404, 'Not Found');
}
}
public function getShow(int $id)
{
try {
$call = fn() => $this->client->getTvApi()->getTvshow($id, ['append_to_response'=>'credits,videos,similar,recommendations,keywords']);
if ($this->use_cache)
return Cache::remember('show'.$id, $this->ttl, $call);
return $call();
} catch (\Throwable $th) {
return abort(404, 'Not Found');
}
}
public function getSeason(int $id, int $season_number)
{
$call = fn() => $this->client->getTvSeasonApi()->getSeason($id, $season_number, ['append_to_response'=>'credits,videos,keywords']);
if ($this->use_cache)
return Cache::remember('show'.$id.'_'.$season_number, $this->ttl, $call);
return $call();
}
public function getEpisode(int $id, int $season_number, int $episode_number)
{
$call = fn() => $this->client->getTvEpisodeApi()->getEpisode($id, $season_number, $episode_number, ['append_to_response'=>'credits,videos']);
if ($this->use_cache)
return Cache::remember('episode'.$id.'_'.$season_number.'_'.$episode_number, $this->ttl, $call);
return $call();
}
public function getUpcomingMovies($page = 1)
{
$call = fn() => $this->client->getMoviesApi()->getUpcoming();
if ($this->use_cache)
return Cache::remember('upcomingtmdb'.$page, $this->ttl, $call);
return $call();
}
public function getPopularMovies($page = 1)
{
$call = fn() => $this->client->getMoviesApi()->getPopular();
if ($this->use_cache)
return Cache::remember('populartmdb'.$page, $this->ttl, $call);
return $call();
}
public function getPopularShows($page = 1)
{
$call = fn() => $this->client->getTvApi()->getPopular();
if ($this->use_cache)
return Cache::remember('populartvtmdb'.$page, $this->ttl, $call);
return $call();
}
public function getAiringShows($page = 1)
{
$call = fn() => $this->client->getTvApi()->getOnTheAir();
if ($this->use_cache)
return Cache::remember('airingtmdb'.$page, $this->ttl, $call);
return $call();
}
public function getComingSoonMovies($page = 1)
{
$from = Carbon::now()
->subDay()
->format('Y-m-d');
$to = Carbon::now()
->addMonth()
->format('Y-m-d');
$call = fn() => $this->client->getMoviesApi()->getUpcoming(['sort_by' => 'popularity.desc',
'with_release_type' => '2|3',
'primary_release_date.gte' => $from,
'primary_release_date.lte' => $to,
'region' => 'US',
'language' => 'en',
'include_adult' => 'false',
'page' => $page,]);
if ($this->use_cache)
return Cache::remember('comingsoontmdb'.$page, $this->ttl, $call);
return $call();
}
public function getNowPlayingMovies($page = 1)
{
$call = fn() => $this->client->getMoviesApi()->getNowPlaying();
if ($this->use_cache)
return Cache::remember('nowplayingtmdb'.$page, $this->ttl, $call);
return $call();
}
public function getCountryMovies($country = 'us', $page = 1)
{
// dd($country);
$call = fn() => $this->client->getDiscoverApi()->discoverMovies(['language' => 'en-US', 'page' => $page, 'region' => $country, 'watch_region' => $country]);
if ($this->use_cache)
// return Cache::remember('country'.$country.$page, $this->ttl, $call);
return $call();
}
public function getTopRatedMovies($page = 1)
{
// dd($country);
// dd($page);
$call = fn() => $this->client->getMoviesApi()->getTopRated(['language' => 'en-US', 'page' => $page]);
if ($this->use_cache)
return Cache::remember('toprated'.$page, $this->ttl, $call);
return $call();
}
public function getSearch(string $query)
{
$kw = str_replace('-', ' ',$query);
$kw = urlencode($kw);
$call = fn() => $this->client->getSearchApi()->searchMulti($kw);
if ($this->use_cache)
return Cache::remember('search'.$kw, $this->ttl, $call);
return $call();
}
}

204
app/Supports/Helpers.php Normal file
View file

@ -0,0 +1,204 @@
<?php
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Carbon;
function img_url($size, $path, $photon = true, $w = 300, $h = 450)
{
if (empty($path)) {
return asset('images/placeholder.webp');
}
if ($photon) {
// return "//i1.wp.com/image.tmdb.org/t/p/{$size}{$path}?resize=300,450";
// return "https://cdn.statically.io/img/image.tmdb.org/f=auto,q=80,w={$w},h={$h}/t/p/{$size}{$path}";
return "https://i1.wp.com/image.tmdb.org/t/p/{$size}{$path}?ssl=1&resize={$w},{$h}";
}
return "https://image.tmdb.org/t/p/{$size}{$path}";
}
function item($item)
{
if (isset($item->title)) { // is movie
$title = $item->title;
$link = route('movie', ['id' => $item->id, 'name' => Str::slug($item->title)]);
} else {
$title = $item->name;
$link = route('show', ['id' => $item->id, 'name' => Str::slug($item->name)]);
}
return (object)[
'link' => $link,
'title' => $title
];
}
function release_date($release_date)
{
return date('M d, Y', strtotime($release_date));
}
function release_date_year($release_date)
{
return date('Y', strtotime($release_date));
}
function minToHour($min, $array_in = false)
{
if ($array_in) {
if (!empty($min)) {
$min = $min[0];
} else {
return 'NA';
}
}
$d = floor($min / 1440);
$h = floor(($min - $d * 1440) / 60);
$m = $min - ($d * 1440) - ($h * 60);
if ($min < 60) {
return "{$m}m";
}
return "{$h}h {$m}m";
}
if (!function_exists('cast_to_object')) {
function cast_to_object($array)
{
$object = new stdClass();
foreach ($array as $key => $value) {
$object->$key = is_array($value) ? cast_to_object($value) : $value;
}
return $object;
}
}
function get_movie_genres_list($as_object = true)
{
$genres = [
['id' => '28', 'name' => 'Action'],
['id' => '12', 'name' => 'Adventure'],
['id' => '16', 'name' => 'Animation'],
['id' => '35', 'name' => 'Comedy'],
['id' => '80', 'name' => 'Crime'],
['id' => '99', 'name' => 'Documentary'],
['id' => '18', 'name' => 'Drama'],
['id' => '10751', 'name' => 'Family'],
['id' => '14', 'name' => 'Fantasy'],
['id' => '36', 'name' => 'History'],
['id' => '27', 'name' => 'Horror'],
['id' => '10402', 'name' => 'Music'],
['id' => '9648', 'name' => 'Mystery'],
['id' => '10749', 'name' => 'Romance'],
['id' => '878', 'name' => 'Science Fiction'],
['id' => '10770', 'name' => 'TV Movie'],
['id' => '53', 'name' => 'Thriller'],
['id' => '10752', 'name' => 'War'],
['id' => '37', 'name' => 'Western'],
];
return $as_object ? cast_to_object($genres) : $genres;
}
function get_tv_genres_list($as_object = true)
{
$genres = [
['id' => '10759', 'name' => 'Action & Adventure'],
['id' => '16', 'name' => 'Animation'],
['id' => '35', 'name' => 'Comedy'],
['id' => '80', 'name' => 'Crime'],
['id' => '99', 'name' => 'Documentary'],
['id' => '18', 'name' => 'Drama'],
['id' => '10751', 'name' => 'Family'],
['id' => '10762', 'name' => 'Kids'],
['id' => '9648', 'name' => 'Mystery'],
['id' => '10763', 'name' => 'News'],
['id' => '10764', 'name' => 'Reality'],
['id' => '10765', 'name' => 'Sci-Fi & Fantasy'],
['id' => '10766', 'name' => 'Soap'],
['id' => '10767', 'name' => 'Talk'],
['id' => '10768', 'name' => 'War & Politics'],
['id' => '37', 'name' => 'Western'],
];
return $as_object ? cast_to_object($genres) : $genres;
}
function genres($genres, $type = 'movie', $as_object = true)
{
$path = $type === 'movie' ? 'films' : 'tv-shows';
$results = array_map(function ($genre) use ($path) {
return [
'link' => url($path . '/genre/' . Str::slug($genre->name) . '/' . $genre->id),
'name' => $genre->name
];
}, $genres);
return $as_object ? cast_to_object($results) : $results;
}
function actors($actors, $limit = 5)
{
return array_map(function ($actor) {
return (object)[
'name' => $actor->name
];
}, collect($actors)->take($limit)->toArray());
// return collect($results)->take(3);
}
function detect_device()
{
// return new \Jenssegers\Agent\Agent();
}
function is_bing()
{
$agent = detect_device();
$bing_regex = '/bingbot|bing|slurp|altavista|trident|aol|dogpile|duckduckbot|ecosia|ekoru|elliot|enow|excite|gaia|givero|goodshop|info|kol|lilo|metacrawler|mojeek|oceanhero|oscobo|qwantify|searchencrypt|searchscene|serch|swiss|webcrawler|youcare|msnbot/i';
// dd($agent->getUserAgent());
// return $agent->match($bing_regex);
}
function get_country_code()
{
$country_code = 'RO';
if (isset($_SERVER['HTTP_CF_IPCOUNTRY'])) {
$country_code = $_SERVER['HTTP_CF_IPCOUNTRY'];
} elseif (isset($_SERVER['HTTP_CF_IPCOUNTRY'])) {
$country_code = $_SERVER['COUNTRY_CODE'];
}
return $country_code;
}
function is_country($country = 'US', $negate = false)
{
$res = (bool) preg_match('~'.$country.'~', get_country_code());
return $negate ? !$res : $res;
}
function is_primary_country($negate = false)
{
$res = (bool) preg_match('~'.config('ads.country_primary').'~', get_country_code());
return $negate ? !$res : $res;
}
function host_key() {
return ucfirst(str_replace('.', '', $_SERVER['HTTP_HOST']));
}
function url_starts_with($perma)
{
return (bool) preg_match('~/'.$perma.'~', ltrim(request()->getPathInfo()));
}

152
app/Supports/Markup.php Normal file
View file

@ -0,0 +1,152 @@
<?php
namespace App\Supports;
use Spatie\SchemaOrg\Movie;
use Spatie\SchemaOrg\Schema;
class Markup {
protected static function MinutesToDuration($s) {
$days = floor($s / 1440);
$s = $s - $days * 1440;
$hours = floor($s / 60);
$s = $s - $hours * 60;
$dur = "PT";
if ($days > 0) {$dur .= $days . "D";}
if ($hours > 0) {$dur .= $hours . "H";}
$dur .= $s . "M";
return $dur;
}
public static function getMovieMarkupData($mov) {
$movie = Schema::movie()
->name($mov->title)
->description($mov->title.' - '.$mov->overview)
->image(img_url('w300', $mov->poster_path, true ))
->url(item($mov)->link)
->duration(self::MinutesToDuration($mov->runtime))
->genre(collect($mov->genres)->pluck('name')->all())
->keywords(collect($mov->keywords->keywords)->implode('name', ','))
->datePublished($mov->release_date);
if (isset($mov->vote_average)) {
$rating = Schema::aggregateRating()
->bestRating(10)
->worstRating(1)
->ratingValue($mov->vote_average)
->ratingCount($mov->vote_count)
->ratingExplanation('Community Rating');
$movie->aggregateRating($rating);
}
$actors = [];
foreach( collect($mov->credits->cast)->take(5) as $cast) {
$actors[]=Schema::person()->name($cast->name)->image(img_url('w185', $cast->profile_path));
}
$movie->actor($actors);
$directors = [];
foreach( collect($mov->credits->crew)->filter(function($value, $key){ return $value->job === 'Director';}) as $cast) {
$directors[]=Schema::person()->name($cast->name);
}
$movie->director($directors);
return $movie->toScript();
}
}
// function dd($v) {
// var_dump($v);
// exit;
// }
function getTvMarkupData($mov) {
// dd($mov);
// dd($mov['keywords']);
if (isset($mov->vote_average)) {
$rating = Schema::aggregateRating()
->bestRating(10)
->worstRating(1)
->ratingValue($mov->vote_average)
->ratingCount($mov->vote_count)
->ratingExplanation('Community Rating');
}
$movie = Schema::tVSeries()
->name($mov->name)
->description($mov->name.' - '.$mov->overview)
->image(img_url('w300', $mov->poster_path, true ))
->url(item($mov)->link)
// ->duration(MinutesToDuration($mov['episode_run_time'][0]))
->genre(collect($mov->genres)->pluck('name')->toArray())
->keywords(collect($mov->keywords->results)->implode('name', ','))
->datePublished($mov->first_air_date)
->numberOfEpisodes($mov->number_of_episodes)
->numberOfSeasons($mov->number_of_seasons)
;
if (isset($rating)) {
$movie->aggregateRating($rating);
}
$actors = [];
foreach( collect($mov->credits->cast)->take(5) as $cast) {
$actors[]=Schema::person()->name($cast->name)->image(img_url('w185', $cast->profile_path));
}
$movie->actor($actors);
$directors = [];
foreach( collect($mov->credits->crew)->filter(function($value, $key){ return $value->job === 'Producer' || $value->job === 'Executive Producer';})->take(5) as $cast) {
$directors[]=Schema::person()->name($cast->name);
}
$movie->creator($directors);
return $movie->toScript();
}
function getTvSeasonMarkupData($mov) {
// dd($mov);
// dd($mov['keywords']);
$rating = Schema::aggregateRating()
->bestRating(10)
->worstRating(1)
->ratingValue($mov['vote_average'])
->ratingCount($mov['vote_count'])
->ratingExplanation('Community Rating');
$movie = Schema::tVSeries()
->name($mov->name)
->description($mov->name.' - '.$mov['overview'])
->image(img_url('w300', $mov['poster_path'], true ))
->url(build_permalink('tv/' . $mov['id'] .'/' .str_slug($mov->name)))
// ->duration(MinutesToDuration($mov['episode_run_time'][0]))
->aggregateRating($rating)
->genre(collect($mov['genres'])->pluck('name')->toArray())
->keywords(collect($mov['keywords']['results'])->implode('name', ','))
->datePublished($mov['first_air_date'])
->numberOfEpisodes($mov['number_of_episodes'])
->numberOfSeasons($mov['number_of_seasons'])
;
$actors = [];
foreach( collect($mov['credits']['cast'])->take(5) as $cast) {
$actors[]=Schema::person()->name($cast['name'])->url(build_permalink('people/'.str_slug($cast['name']).'/'.$cast['id']))->image(img_url('w185', $cast['profile_path']));
}
$movie->actor($actors);
$directors = [];
foreach( collect($mov['credits']['crew'])->filter(function($value, $key){ return $value['job'] === 'Producer' || $value['job'] === 'Executive Producer';})->take(5) as $cast) {
$directors[]=Schema::person()->name($cast['name']);
}
$movie->creator($directors);
return $movie->toScript();
}

View file

@ -0,0 +1,322 @@
<?php
namespace App\Supports;
use App\Services\TmdbClient;
use App\Supports\Traits\Helpers;
use Carbon\Carbon;
use Carbon\CarbonInterval;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Cache;
use Spatie\SchemaOrg\Schema;
use Symfony\Component\VarExporter\Internal\Values;
class SchemaBuilder
{
// use Helpers;
public static function getMovieSchema(array $movie): array
{
$schema = [];
$movie = (object)$movie;
$movieSchema = Schema::movie()
->name($movie->title)
->description($movie->title . ' - ' . $movie->overview)
->url(route('movie', ['id' => $movie->id, 'slug' => $movie->slug]))
->duration('PT' . Str::of($movie->runtime)->replace(' ', '')->upper())
->datePublished(Carbon::parse($movie->release_date)->format('Y-m-d'))
->genre(collect($movie->genres)->pluck('name')->all())
->image($movie->poster);
if (isset($movie->vote_average) && $movie->vote_count) {
$rating = Schema::aggregateRating()
->bestRating(10)
->worstRating(1)
->ratingValue($movie->vote_average)
->ratingCount($movie->vote_count)
->ratingExplanation('Community Rating');
$movieSchema->aggregateRating($rating);
}
$actors = collect($movie->cast)->take(5)->map(function ($actor) {
return Schema::person()->name($actor['name'])->image($actor['image']);
})->values()->all();
$movieSchema->actors($actors);
$directors = collect($movie->crew['directors'])->filter(fn ($director) => Str::of($director['as'])->contains('director', true))->map(function ($director) {
// dd($director);
return Schema::person()->name($director['name'])->image($director['image']);
})->values()->all();
$movieSchema->directors($directors);
$schema[] = json_encode($movieSchema->toArray(), JSON_UNESCAPED_UNICODE);
// if (isset($movie->trailer)) {
// $videoSchema = Schema::videoObject()
// ->name($movie->title)
// ->description($movie->overview)
// ->thumbnailUrl($movie->poster)
// ->uploadDate(Carbon::parse($movie->release_date)->toIso8601String())
// ->duration('PT' . Str::of($movie->runtime)->replace(' ', '')->upper())
// ->embedUrl($movie->trailer);
// $schema[] = json_encode($videoSchema->toArray(), JSON_UNESCAPED_UNICODE);
// }
if (isset($movie->similar) && !empty($movie->similar)) {
$carousel = Schema::itemList();
foreach ($movie->similar as $key => $similarMovie) {
// dd($similarMovie);
if (!isset($similarMovie['slug']) || $similarMovie['slug'] === '') continue;
$listItems[] = Schema::listItem()
->position($key + 1)
->item(
Schema::movie()
->url(route('movie', ['id' => $movie->id, 'slug' => $similarMovie['slug']]))
->name($similarMovie['title'])
->image($similarMovie['image'])
->datePublished($similarMovie['date'])
);
}
$carousel->itemListElement(
$listItems
);
$schema[] = json_encode($carousel->toArray(), JSON_UNESCAPED_UNICODE);
}
return $schema;
}
public static function getShowSchema(array $movie): array
{
$schema = [];
$movie = (object)$movie;
$movieSchema = Schema::tVSeries()
->name($movie->title)
->description($movie->title . ' - ' . $movie->overview)
->url(route('show', ['id' => $movie->id, 'slug' => $movie->slug]))
// ->duration('PT' . Str::of($movie->runtime)->replace(' ', '')->upper())
->datePublished(Carbon::parse($movie->first_air_date)->format('Y-m-d'))
->numberOfEpisodes($movie->number_of_episodes)
->numberOfSeasons($movie->number_of_seasons)
->genre(collect($movie->genres)->pluck('name')->all())
->image($movie->poster);
if (isset($movie->vote_average) && $movie->vote_count) {
$rating = Schema::aggregateRating()
->bestRating(10)
->worstRating(1)
->ratingValue($movie->vote_average)
->ratingCount($movie->vote_count)
->ratingExplanation('Community Rating');
$movieSchema->aggregateRating($rating);
}
$actors = collect($movie->cast)->take(5)->map(function ($actor) {
return Schema::person()->name($actor['name'])->image($actor['image']);
})->values()->all();
$movieSchema->actor($actors);
$directors = collect($movie->crew)->filter(fn ($director) => Str::of($director['as'])->contains('producer', true))->map(function ($director) {
return Schema::person()->name($director['name'])->image($director['image']);
})->values()->all();
$movieSchema->producer($directors);
$schema[] = json_encode($movieSchema->toArray(), JSON_UNESCAPED_UNICODE);
// if (isset($movie->trailer)) {
// $videoSchema = Schema::videoObject()
// ->name($movie->title)
// ->description($movie->overview)
// ->thumbnailUrl($movie->poster)
// ->uploadDate(Carbon::parse($movie->first_air_date)->toIso8601String())
// ->duration('PT' . Str::of($movie->runtime)->replace(' ', '')->upper())
// ->embedUrl($movie->trailer);
// $schema[] = json_encode($videoSchema->toArray(), JSON_UNESCAPED_UNICODE);
// }
if (isset($movie->similar) && !empty($movie->similar)) {
$carousel = Schema::itemList();
$listItems = [];
foreach ($movie->similar as $key => $similarMovie) {
// dd($similarMovie);
$listItems[] = Schema::listItem()
->position($key + 1)
->item(
Schema::tVSeries()
->url(route('show', ['id' => $movie->id, 'slug' => $similarMovie['slug']]))
->name($similarMovie['title'])
->image($similarMovie['image'])
->datePublished($similarMovie['date'])
);
}
$carousel->itemListElement(
$listItems
);
$schema[] = json_encode($carousel->toArray(), JSON_UNESCAPED_UNICODE);
}
return $schema;
}
public static function getShowSeasonSchema($show, $season): array
{
$schema = [];
$movie = (object)$show;
$movieSchema = Schema::tVSeason()
->name($season['name'])
->description($season['overview'])
->url(route('show.season', ['id' => $movie->id, 'slug' => $movie->slug, 'season' => $season['season_number']]))
// ->duration('PT' . Str::of($movie->runtime)->replace(' ', '')->upper())
->datePublished(Carbon::parse($season['air_date'])->format('Y-m-d'))
->numberOfEpisodes($movie->number_of_episodes)
->genre(collect($movie->genres)->pluck('name')->all())
->image($movie->poster)
->seasonNumber($season['season_number'])
->partOfTVSeries(Schema::tVSeries()->name($movie->title)->url((route('show', ['id' => $movie->id, 'slug' => $movie->slug]))));
if (isset($movie->vote_average) && $movie->vote_count) {
$rating = Schema::aggregateRating()
->bestRating(10)
->worstRating(1)
->ratingValue($movie->vote_average)
->ratingCount($movie->vote_count)
->ratingExplanation('Community Rating');
$movieSchema->aggregateRating($rating);
}
if (!empty($season['episodes'])) {
$showEpisodes = [];
array_map(function ($ep) use (&$showEpisodes) {
$showEpisodes[] = Schema::episode()
->name($ep['name'])
->description($ep['overview'])
->episodeNumber($ep['episode_number']);
}, $season['episodes']->all());
$movieSchema->episode($showEpisodes);
}
$actors = collect($season['cast'])->take(5)->map(function ($actor) {
return Schema::person()->name($actor['name'])->image($actor['image']);
})->values()->all();
$movieSchema->actor($actors);
$directors = collect($season['crew'])->filter(fn ($director) => Str::of($director['as'])->contains('producer', true))->map(function ($director) {
return Schema::person()->name($director['name'])->image($director['image']);
})->values()->all();
$movieSchema->producer($directors);
$schema[] = json_encode($movieSchema->toArray(), JSON_UNESCAPED_UNICODE);
// if (isset($movie->trailer)) {
// $videoSchema = Schema::videoObject()
// ->name($movie->title)
// ->description($movie->overview)
// ->thumbnailUrl($movie->poster)
// ->uploadDate(Carbon::parse($movie->first_air_date)->toIso8601String())
// ->duration('PT' . Str::of($movie->runtime)->replace(' ', '')->upper())
// ->embedUrl($movie->trailer);
// $schema[] = json_encode($videoSchema->toArray(), JSON_UNESCAPED_UNICODE);
// }
if (isset($movie->similar) && !empty($movie->similar)) {
$carousel = Schema::itemList();
$listItems = [];
foreach ($movie->similar as $key => $similarMovie) {
// dd($similarMovie);
$listItems[] = Schema::listItem()
->position($key + 1)
->item(
Schema::tVSeries()
->url(route('show', ['id' => $movie->id, 'slug' => $similarMovie['slug']]))
->name($similarMovie['title'])
->image($similarMovie['image'])
->datePublished($similarMovie['date'])
);
}
$carousel->itemListElement(
$listItems
);
$schema[] = json_encode($carousel->toArray(), JSON_UNESCAPED_UNICODE);
}
return $schema;
}
public static function getShowEpisodeSchema($show, $season, $episode): array
{
$schema = [];
$movie = (object)$show;
$movieSchema = Schema::tVEpisode()
->name($episode['name'])
->description($episode['overview'])
->url(route('show.episode', ['id' => $movie->id, 'slug' => $movie->slug, 'season' => $episode['season_number'], 'episode' => $episode['episode_number']]))
->duration('PT' . Str::of($movie->runtime)->replace(' ', '')->upper())
->datePublished(Carbon::parse($episode['air_date'])->format('Y-m-d'))
// ->numberOfEpisodes($movie->number_of_episodes)
->genre(collect($movie->genres)->pluck('name')->all())
->image($episode['backdrop'])
->episodeNumber($episode['episode_number'])
->partOfSeason(
Schema::tVSeason()
->name($season['name'])
->seasonNumber($episode['season_number'])
->url(route('show.season', ['id' => $movie->id, 'slug' => $movie->slug, 'season' => $season['season_number']]))
)
->partOfTVSeries(Schema::tVSeries()->name($movie->title)->url((route('show', ['id' => $movie->id, 'slug' => $movie->slug]))));
if (isset($episode['vote_average']) && $episode['vote_count']) {
$rating = Schema::aggregateRating()
->bestRating(10)
->worstRating(1)
->ratingValue($episode['vote_average'])
->ratingCount($episode['vote_count'])
->ratingExplanation('Community Rating');
$movieSchema->aggregateRating($rating);
}
// if (!empty($season['episodes'])) {
// $showEpisodes = [];
// array_map(function($ep) use(&$showEpisodes){
// $showEpisodes[] = Schema::episode()
// ->name($ep['name'])
// ->description($ep['overview'])
// ->episodeNumber($ep['episode_number']);
// },$season['episodes']->all());
// $movieSchema->episode($showEpisodes);
// }
// $actors = collect($episode['cast'])->take(5)->map(function($actor){
// return Schema::person()->name($actor['name'])->image($actor['image']);
// })->values()->all();
// $movieSchema->actors($actors);
// $directors = collect($episode['crew'])->filter(fn($director) => Str::of($director['as'])->contains('producer', true))->map(function($director){
// return Schema::person()->name($director['name'])->image($director['image']);
// })->values()->all();
// $movieSchema->producers($directors);
$schema[] = json_encode($movieSchema->toArray(), JSON_UNESCAPED_UNICODE);
// if (isset($episode['trailer'])) {
// $videoSchema = Schema::videoObject()
// ->name($movie->title)
// ->description($movie->overview)
// ->thumbnailUrl($movie->poster)
// ->uploadDate(Carbon::parse($movie->first_air_date)->toIso8601String())
// ->duration('PT' . Str::of($movie->runtime)->replace(' ', '')->upper())
// ->embedUrl($movie->trailer);
// $schema[] = json_encode($videoSchema->toArray(), JSON_UNESCAPED_UNICODE);
// }
if (isset($movie->similar) && !empty($movie->similar)) {
$carousel = Schema::itemList();
$listItems = [];
foreach ($movie->similar as $key => $similarMovie) {
// dd($similarMovie);
$listItems[] = Schema::listItem()
->position($key + 1)
->item(
Schema::tVSeries()
->url(route('show', ['id' => $movie->id, 'slug' => $similarMovie['slug']]))
->name($similarMovie['title'])
->image($similarMovie['image'])
->datePublished($similarMovie['date'])
);
}
$carousel->itemListElement(
$listItems
);
$schema[] = json_encode($carousel->toArray(), JSON_UNESCAPED_UNICODE);
}
return $schema;
}
}

View file

@ -0,0 +1,368 @@
<?php
namespace App\Supports\Traits;
use App\Services\TmdbClient;
use App\Supports\Traits\Helpers;
use Carbon\Carbon;
use Carbon\CarbonInterval;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Cache;
trait CleanItems {
use Helpers;
protected function getPageLabel(?string $label)
{
switch ($label) {
case 'pagination.previous':
return 'Previous';
break;
case 'pagination.next':
return 'Next';
break;
default:
return $label;
break;
}
}
protected function getPageUrl(?string $url, $route_name = 'movies')
{
if (isset($url) && preg_match('~page=(\d+)~', $url, $matches)) {
[,$page] = $matches;
return route($route_name, compact('page'));
}
return $url;
}
public function formatTmdbMovie($data):array
{
$movie = [];
$movie['id'] = self::encodeId($data['id']);
$movie['real_id'] = $data['id'];
// dd($data);
// dump($data);
$movie['title'] = $data['title'];
$movie['slug'] = Str::slug($data['title']);
$movie['overview'] = $data['overview'];
$movie['tagline'] = $data['tagline'];
$movie['vote_average'] = round($data['vote_average'], 1);
$movie['vote_count'] = $data['vote_count'];
$movie['poster'] = $this->getImageUrl($data['poster_path'], 'w500', 300, 450);
$movie['backdrop'] = $this->getImageUrl($data['backdrop_path'], 'w780', null, null, true);
$movie['backdrop_path'] = $data['backdrop_path'];
$movie['release_date'] = $this->formatReleaseDate($data['release_date']);
$movie['year'] = Carbon::parse($data['release_date'])->format('Y');
$movie['genres'] = $this->formatGenres($data['genres']);
$movie['cast'] = $this->getCast($data['credits']['cast'] ?? [], 8);
$movie['crew']['directors'] = $this->getCrew($data['credits']['crew'] ?? [], 8, true);
$movie['crew']['producers'] = $this->getMovieProdcer($data['credits']['crew'] ?? [], 2);
$movie['runtime'] = CarbonInterval::make($data['runtime'], 'minute')->cascade()->forHumans(['short' => true]);
$movie['duration'] = CarbonInterval::make($data['runtime'], 'minute')->totalSeconds;
$movie['countries'] = collect($data['production_countries'])->implode('name', ', ');
$movie['companies'] = collect($data['production_companies'])->implode('name', ', ');
$movie['trailer'] = $data['videos']['results'][0]['key'] ?? false;
if($movie['trailer']) $movie['trailer'] = 'https://www.youtube-nocookie.com/embed/' . $movie['trailer'];
$movie['similar'] = $this->formatTmdbResponse($data['similar'] ?? [], false, [], 8)['data'] ?? [];
$movie['keywords'] = $data['keywords']['keywords'] ?? [];
$movie['share'] = self::getShareLinks(route('movie', ['id' => $movie['id'], 'slug' => $movie['slug']]), $movie['title'], Str::limit($movie['overview'], 100), $movie['poster']);
$movie['languages'] = self::getSpokenLanguages($data['spoken_languages']);
// dump($movie);
return $movie;
}
public function formatTmdbShow($data):array
{
// dd($data);
$show = [];
$show['id'] = self::encodeId($data['id']);
$show['real_id'] = $data['id'];
$show['title'] = $data['name'];
$show['slug'] = Str::slug($data['name']);
$show['overview'] = $data['overview'];
$show['last_episode'] = ['season' => $data['last_episode_to_air']['season_number'] ?? 1, 'episode' => $data['last_episode_to_air']['episode_number'] ?? 1, 'name' => sprintf('S%sE%s : %s', $data['last_episode_to_air']['season_number'] ?? 1, $data['last_episode_to_air']['episode_number'] ?? 1, $data['last_episode_to_air']['name'] ?? 'Episode 1')];
$show['tagline'] = $data['tagline'];
$show['vote_average'] = round($data['vote_average'], 1);
$show['vote_count'] = $data['vote_count'];
$show['number_of_episodes'] = $data['number_of_episodes'];
$show['number_of_seasons'] = $data['number_of_seasons'];
$show['poster'] = $this->getImageUrl($data['poster_path'], 'w500', 230, 345);
$show['backdrop'] = $this->getImageUrl($data['backdrop_path'], 'w1280', 1280, 720);
$show['first_air_date'] = $this->formatReleaseDate($data['first_air_date']);
$show['genres'] = $this->formatGenres($data['genres']);
$show['cast'] = $this->getCast($data['credits']['cast'] ?? [], 8);
$show['creators'] = $this->getCreators($data['created_by'] ?? [], 8);
$show['crew'] = $this->getCrew($data['credits']['crew'] ?? [], 8);
$show['runtime'] = isset($data['episode_run_time'][0]) ? CarbonInterval::make($data['episode_run_time'][0], 'minute')->cascade()->forHumans(['short' => true]) : false;
$show['duration'] = isset($data['episode_run_time'][0]) ? CarbonInterval::make($data['episode_run_time'][0], 'minute')->totalSeconds : false;
$show['countries'] = collect($data['production_countries'])->implode('name', ', ');
$show['companies'] = collect($data['production_companies'])->implode('name', ', ');
$show['trailer'] = $data['videos']['results'][0]['key'] ?? false;
$show['seasons'] = collect($data['seasons'])->where('season_number', '>', 0)->map(function($season){
$season['poster'] = $this->getImageUrl($season['poster_path'], 'w500', 240, 360);
unset($season['poster_path']);
return $season;
})->values()->all();
$show['similar'] = $this->formatTmdbResponse($data['recommendations'], false, [], 6)['data'] ?? [];
$show['keywords'] = $data['keywords']['results'] ?? [];
// dd($show);
return $show;
}
public function formatTmdbSeason($data, $showData):array
{
// dd($data);
$show = $data;
$show['label'] = 'S'.str_pad($data['season_number'], 2, '0', STR_PAD_LEFT);
$show['overview'] = $data['overview'] !== '' ? $data['overview'] : $showData['overview'];
$show['cast'] = $this->getCast($show['credits']['cast'] ?? $showData['credits']['cast'] ?? [], 8);
$show['crew'] = $this->getCrew($show['credits']['crew'] ?? $showData['credits']['crew'] ?? [], 8);
$show['air_date'] = Helpers::formatReleaseDate($data['air_date']);
$show['poster'] = $this->getImageUrl($data['poster_path'], 'w500', 230, 345);
$show['episodes'] = collect($show['episodes'])->map(function($episode){
$episode['air_date'] = Helpers::formatReleaseDate($episode['air_date']);
$episode['label'] = /* 'S'.str_pad($episode['season_number'], 2, '0', STR_PAD_LEFT). 'E'.*/str_pad($episode['episode_number'], 2, '0', STR_PAD_LEFT);
$episode['backdrop'] = $this->getImageUrl($episode['still_path'], 'w1280', 1280, 720);
unset($episode['still_path']);
return $episode;
});
$show['keywords'] = $data['keywords']['results'] ?? [];
unset($show['credits']);
return $show;
}
public function formatTmdbEpisode($data):array
{
// dd($data);
$episode = $data;
$episode['label'] = 'S'.str_pad($episode['season_number'], 2, '0', STR_PAD_LEFT).'E'.str_pad($episode['episode_number'], 2, '0', STR_PAD_LEFT);
$episode['backdrop'] = $this->getImageUrl($episode['still_path'], 'w1280', 1280, 720);
$episode['cast'] = $this->getCast($episode['credits']['cast'] ?? [], 8);
$episode['crew'] = $this->getCrew($episode['credits']['crew'] ?? [], 8);
$episode['air_date'] = Helpers::formatReleaseDate($episode['air_date']);
$episode['vote_average'] = round($episode['vote_average']/2, 1);
$episode['label'] = 'S'.str_pad($episode['season_number'], 2, '0', STR_PAD_LEFT).'E'.str_pad($episode['episode_number'], 2, '0', STR_PAD_LEFT);
unset($episode['still_path']);
unset($episode['credits']);
return $episode;
}
protected static function setItemTypeMovie($item)
{
$item['type'] = 'movie';
return $item;
}
protected static function setItemTypeShow($item)
{
$item['type'] = 'show';
return $item;
}
public static function encodeForInertia($data):string
{
$data = base64_encode(json_encode($data));
return $data;
}
public function getHomeHeroSliderData($movies, TmdbClient $tmdb)
{
return Cache::remember('home_hero_slider_nyxy', 3600 * 6, function()use($movies, $tmdb){
$movies = (array)$movies;
// dd($movies['data']);
$movies = collect($movies['data'])->map(fn($item) => self::setItemTypeMovie((array)$item))->map(function($movie) use($tmdb){
$movie = (array)$movie;
return $tmdb->getMovie($movie['id']);
// dd($this->formatTmdbMovie($movie));
// return $this->formatTmdbMovie($movie);
})
->map(function($item){
$item['overview'] = Str::limit($item['overview'], 250);
return $item;
});
// dd($movies);
return $movies->all();
});
// $shows = collect($shows['data'])->map(fn($item) => self::setItemTypeShow($item));
// dd($movies, $shows);
}
public function formatApiResponse(Object $data, $with_pagination = true, $route = [], $limit = false): array
{
// dd($data->data);
// dd($route);
$response = [];
$results = [];
if (!empty($data->data)) {
$items = collect($data->data);
$route_name = isset($items->first()->title) ? 'movies':'shows';
$results = $items->map(function($item, $key){
return [
'id' => self::encodeId($item->id),
// 'real_id' => $item->id,
'title' => $item->title ?? $item->name,
'views' => $item->views,
'vote_average' => round($item->vote_average, 1),
'overview' => $item->overview ?? $item->overview,
'image' => self::getImageUrl($item->poster_path, 'w500', 300, 450),
'backdrop' => self::getImageUrl($item->backdrop_path, 'w780', null, null, true),
// 'link' => self::getItemUrl($item),
'slug' => Str::slug($item->title ?? $item->name),
'year' => Carbon::parse($item->release_date ?? '')->format('Y'),
'route' => isset($item->title) ? 'movie' : 'show',
// 'count' => $key + 1
];
})->when($limit, fn($collection) => $collection->take($limit))->all();
}
// dd($results);
$response['data'] =/* base64_encode(json_encode( */$results/* )) */;
// $paginator = new LengthAwarePaginator($data->data, $data->total, 30, $data->current_page, [
// 'path' => Paginator::resolveCurrentPath()
// ]);
// dd($data->links);
if ($with_pagination) {
$response['pagination'] = new LengthAwarePaginator($response['data'], $data->total, $data->per_page, $data->current_page, [
'path' => request()->url()
]);
// dd($response['pagination']->links());
// $response['pagination'] = [
// 'current_page' => $data->current_page,
// 'per_page' => $data->per_page,
// 'from' => $data->from,
// 'to' => $data->to,
// 'total' => $data->total,
// 'last_page' => $data->last_page,
// ];
// $links = [];
// $pages = range($data->current_page - 5, $data->current_page + 5);
// foreach ($pages as $page) {
// if ($page > 0 && $page != $data->current_page) {
// $links[] = [
// 'page' => $page,
// 'link' => route($route['name'], ['page' => $page, ...$route['params'] ?? []])
// ];
// }
// }
// $response['pagination']['links'] = $links;
}
// dd($response);
return $response;
}
public function formatTmdbSearchResponse(array $data): array
{
// dd($data->data);
// dd($data);
$response = [];
$results = [];
if (!empty($data['results'])) {
$items = collect($data['results'])->filter(fn($item) => in_array($item['media_type'], ['movie', 'tv']))->map(fn($item) =>(Object)$item);
$results = $items->map(function($item) {
return [
'id' => self::encodeId($item->id),
'title' => $item->title ?? $item->name,
// 'overview' => $item->overview ?? $item->overview,
'image' => self::getImageUrl($item->poster_path, 'w500', 230, 345),
// 'backdrop' => self::getImageUrl($item->backdrop_path, 'original', 1920, 1080),
// 'image_low' => self::getImageUrl($item->poster_path, 'w500', 20, 30), first_air_date
'link' => self::getItemUrl($item),
'slug' => Str::slug($item->title ?? $item->name),
'year' => isset($item->release_date) ? Carbon::parse($item->release_date ?? '')->format('Y') : Carbon::parse($item->first_air_date ?? '')->format('Y'),
'type' => match($item->media_type) {'movie' => 'movie', 'tv' => 'show'},
];
})->groupBy('type')->map(fn($typeItems) => $typeItems->all())->all();
}
// dd($results);
return $results;
}
public function formatTmdbResponse(array $data, $with_pagination = false, $route = [], $limit = false): array
{
// dd($data->data);
// dd($data);
$response = [];
$results = [];
if (!empty($data['results'])) {
$items = collect($data['results'])->map(fn($item) =>(Object)$item);
$type = isset($items->first()->title) ? 'movie':'show';
$results = $items->map(function($item) use($type){
// dd($item);
return [
'id' => self::encodeId($item->id),
'title' => $item->title ?? $item->name,
'views' => $item->vote_count,
'vote_average' => round($item->vote_average, 1),
// 'overview' => $item->overview ?? $item->overview,
'image' => self::getImageUrl($item->poster_path, 'w185', null, null),
'backdrop' => self::getImageUrl($item->backdrop_path, 'w780', null, null, true),
// 'link' => self::getItemUrl($item),
'slug' => Str::slug($item->title ?? $item->name),
'year' => Carbon::parse($item->release_date ?? $item->first_air_date ?? '')->format('Y'),
'date' => $item->release_date ?? $item->first_air_date ?? Carbon::now()->format('Y-m-d'),
'route' => isset($item->title) ? 'movie' : 'show',
'type' => $type,
];
})->when($limit, fn($collection) => $collection->take($limit))->all();
}
// dd($results);
$response['data'] =/* base64_encode(json_encode( */$results/* )) */;
// $paginator = new LengthAwarePaginator($data->data, $data->total, 30, $data->current_page, [
// 'path' => Paginator::resolveCurrentPath()
// ]);
// dd($data->links);
if ($with_pagination) {
// dd($data);
$response['pagination'] = [
'current_page' => $data['page'],
'per_page' => 20,
'total' => $data['total_results'],
'last_page' => $data['total_pages'],
];
$links = [];
$pages = range($data['page'] - 5, $data['page'] + 5);
foreach ($pages as $page) {
if ($page > 0 && $page != $data['page']) {
$links[] = [
'page' => $page,
'link' => route($route['name'], ['page' => $page, ...$route['params'] ?? []])
];
}
}
$response['pagination']['links'] = $links;
}
// dd($response);
return $response;
}
}

View file

@ -0,0 +1,54 @@
<?php
namespace App\Supports\Traits;
trait HandlesSeo
{
/**
* @param array $data
* @param array $options
* @return Response|void
*/
protected function handleSeo(&$data = [], $options = [])
{
if (Request::method() === 'GET') {
$data['seo'] = $this->getMetaTags($data, $options) ?: null;
}
if (defined('SHOULD_PRERENDER')) {
$viewName = Arr::get($options, 'prerender.view') ?: $this->namespaceFromRouteAction();
$viewPath = "prerender.$viewName";
$view = null;
// load view from app views folder or fall back to common views otherwise
if (view()->exists($viewPath)) {
$view = view($viewPath);
} else {
$view = view("common::$viewPath");
}
return response($view->with(['meta' => $data['seo'], 'htmlBaseUri' => app(AppUrl::class)->htmlBaseUri]));
}
}
protected function getMetaTags($data = [], $options = []): ?MetaTags
{
$namespace = Arr::get($options, 'prerender.config', $this->namespaceFromRouteAction());
if ($seoConfig = config("seo.$namespace")) {
$dataForSeo = Arr::get($options, 'prerender.dataForSeo') ?: $data;
return new MetaTags($seoConfig, $dataForSeo, $namespace);
}
return null;
}
protected function namespaceFromRouteAction(): string
{
// 'App/Http/Controllers/ArtistController@show'
$uses = request()->route()->action['uses'];
// get resource name and verb from route action
preg_match('/\\\(\w+?)Controller@(\w+)$/', $uses, $matches);
$resource = Str::kebab($matches[1]);
$verb = Str::kebab($matches[2]);
return "$resource.$verb";
}
}

View file

@ -0,0 +1,255 @@
<?php
namespace App\Supports\Traits;
use Carbon\Carbon;
use Hashids\Hashids;
use Illuminate\Support\Str;
use League\CommonMark\Util\UrlEncoder;
use stdClass;
trait Helpers
{
public static function getImageUrl(?string $path = null, string $size = 'original', ?int $w = 300, ?int $h = 450, $backdrop_placeholder = false): string|null
{
if (is_null($path)) {
return null;
if ($backdrop_placeholder)
return config('app.env') === 'production' ? "https://i1.wp.com/".Str::replace('https://', '', asset('images/lazy_one.webp')) : asset('images/lazy_one.webp');
return config('app.env') === 'production' ? "https://i1.wp.com/".Str::replace('https://', '', asset('images/lazy.webp')) : asset('images/lazy_one.webp');
}
// return "https://cdn.statically.io/img/image.tmdb.org/f=auto,q=80,w={$w},h={$h}/t/p/{$size}{$path}";
if (is_null($w) && is_null($h))
return "https://i1.wp.com/image.tmdb.org/t/p/{$size}{$path}?ssl=1";
return "https://i1.wp.com/image.tmdb.org/t/p/{$size}{$path}?ssl=1&resize={$w},{$h}";
// return "https://image.tmdb.org/t/p/{$size}{$path}";
}
public static function getImageFullUrl(?string $url = null, int $w = 300, int $h = 450): string
{
if (is_null($url)) {
return asset('images/placeholder.webp');
}
return "https://i1.wp.com/".Str::of($url)->replace('https://', '')."?ssl=1&resize={$w},{$h}";
// return "https://image.tmdb.org/t/p/{$size}{$path}";
}
protected static function getHashIds():Hashids
{
return new Hashids('', 8, 'abcdefghijklmnopqrstuvwxyz');
}
public static function encodeId($id):int
{
return $id;
return self::getHashIds()->encode($id);
}
public static function decodeId($id):int
{
return $id;
return self::getHashIds()->decode($id)[0] ?? abort(404);
}
public static function getItemUrl(Object $item): string
{
if (isset($item->title)) {
return Str::slug($item->title);
}
if (isset($item->name)) {
return Str::slug($item->name);
}
}
public static function formatReleaseDate(?string $release_date): string
{
return Carbon::parse($release_date)->format('M d, Y');
}
public static function formatGenres(array $genres, $type = 'movie'): array
{
return collect($genres)->map(fn ($genre) => [
'name' => $genre['name'],
'id' => $genre['id'],
'slug' => Str::slug($genre['name']),
])->all();
}
public static function getCast(array $actors, int $limit = 5): array
{
return collect($actors)->map(fn ($actor) => [
'id' => $actor['id'],
'name' => $actor['name'],
'as' => $actor['character'],
'image' => self::getImageUrl($actor['profile_path'], 'w500', 200, 300),
])->take($limit)->all();
}
public static function getCreators(array $actors, int $limit = 5): array
{
return collect($actors)->map(fn ($actor) => [
'id' => $actor['id'],
'name' => $actor['name'],
// 'as' => $actor['character'],
'image' => self::getImageUrl($actor['profile_path'], 'w500', 200, 300),
])->take($limit)->all();
}
public static function getCrew(array $actors, int $limit = 5, $is_movie = false): array
{
return collect($actors)
->when($is_movie, fn($col) => $col->filter(fn($director) => in_array($director['job'], ['Director'])))
->when(!$is_movie, fn($col) => $col->filter(fn($director) => in_array($director['job'], ['Producer', 'Executive Producer', 'Creator', 'Writer', 'Director'])))
->map(fn ($actor) => [
'id' => $actor['id'],
'name' => $actor['name'],
'as' => $actor['job'],
'image' => self::getImageUrl($actor['profile_path'], 'w500', 200, 300),
])->take($limit)->all();
}
public static function getSpokenLanguages(array $spoken_languages): array
{
return collect($spoken_languages)
->map(fn($language) => $language['english_name'])
->all();
}
public static function getMovieProdcer(array $actors, int $limit = 5): array
{
return collect($actors)
->filter(fn($director) => in_array($director['job'], ['Executive Producer']))
->map(fn ($actor) => [
'id' => $actor['id'],
'name' => $actor['name'],
'as' => $actor['job'],
'image' => self::getImageUrl($actor['profile_path'], 'w500', 200, 300),
])->take($limit)->all();
}
public static function getMovieGenreBySlug($slug):stdClass|null
{
return self::getMovieGenreList()->where('slug', $slug)->first();
}
public static function getShowGenreBySlug($slug):stdClass|null
{
return self::getShowGenreList()->where('slug', $slug)->first();
}
public static function getShowGenreList()
{
$genres = [
['id' => '10759', 'name' => 'Action & Adventure'],
['id' => '16', 'name' => 'Animation'],
['id' => '35', 'name' => 'Comedy'],
['id' => '80', 'name' => 'Crime'],
['id' => '99', 'name' => 'Documentary'],
['id' => '18', 'name' => 'Drama'],
['id' => '10751', 'name' => 'Family'],
['id' => '10762', 'name' => 'Kids'],
['id' => '9648', 'name' => 'Mystery'],
['id' => '10763', 'name' => 'News'],
['id' => '10764', 'name' => 'Reality'],
['id' => '10765', 'name' => 'Sci-Fi & Fantasy'],
['id' => '10766', 'name' => 'Soap'],
['id' => '10767', 'name' => 'Talk'],
['id' => '10768', 'name' => 'War & Politics'],
['id' => '37', 'name' => 'Western'],
];
return collect($genres)->map(function ($genre) {
$genre = (object)$genre;
$genre->slug = Str::slug($genre->name);
return $genre;
});
}
public static function getMovieGenreList()
{
$genres = [
['id' => '28', 'name' => 'Action'],
['id' => '12', 'name' => 'Adventure'],
['id' => '16', 'name' => 'Animation'],
['id' => '35', 'name' => 'Comedy'],
['id' => '80', 'name' => 'Crime'],
['id' => '99', 'name' => 'Documentary'],
['id' => '18', 'name' => 'Drama'],
['id' => '10751', 'name' => 'Family'],
['id' => '14', 'name' => 'Fantasy'],
['id' => '36', 'name' => 'History'],
['id' => '27', 'name' => 'Horror'],
['id' => '10402', 'name' => 'Music'],
['id' => '9648', 'name' => 'Mystery'],
['id' => '10749', 'name' => 'Romance'],
['id' => '878', 'name' => 'Science Fiction'],
['id' => '10770', 'name' => 'TV Movie'],
['id' => '53', 'name' => 'Thriller'],
['id' => '10752', 'name' => 'War'],
['id' => '37', 'name' => 'Western'],
];
return collect($genres)->map(function ($genre) {
$genre = (object)$genre;
$genre->slug = Str::slug($genre->name);
return $genre;
});
}
public static function getCountriesList()
{
$countries = [
['code' => 'us', 'name' => 'United States', 'slug' => 'united-states'],
['code' => 'gb', 'name' => 'United Kingdom', 'slug' => 'united-kingdom'],
['code' => 'au', 'name' => 'Australia', 'slug' => 'australia'],
['code' => 'ca', 'name' => 'Canada', 'slug' => 'canada'],
['code' => 'ie', 'name' => 'Ireland', 'slug' => 'ireland'],
['code' => 'kr', 'name' => 'South Korea', 'slug' => 'south-korea'],
['code' => 'my', 'name' => 'Malaysia', 'slug' => 'malaysia'],
['code' => 'id', 'name' => 'Indonesia', 'slug' => 'indonesia'],
['code' => 'tr', 'name' => 'Turkey', 'slug' => 'turkey'],
['code' => 'ar', 'name' => 'Argentina', 'slug' => 'argentina'],
['code' => 'kh', 'name' => 'Cambodia', 'slug' => 'cambodia'],
['code' => 'th', 'name' => 'Thailand', 'slug' => 'thailand'],
['code' => 'br', 'name' => 'Brazil', 'slug' => 'brazil'],
['code' => 'mx', 'name' => 'Mexico', 'slug' => 'mexico'],
['code' => 'jp', 'name' => 'Japan', 'slug' => 'japan'],
];
return collect($countries)->map(fn($country) => (Object)$country);
}
public static function getCountryBySlug($slug):stdClass|null
{
return self::getCountriesList()->where('slug', $slug)->first();
}
public static function getShareLinks(string $url, string $title, string $description, string $image):array
{
return [
[
'name' => 'Facebook',
'url' => sprintf('https://www.facebook.com/sharer/sharer.php?u=%s', urlencode($url)),
'icon' => 'la-facebook-f'
],
[
'name' => 'Linkedin',
'url' => sprintf('http://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s', urlencode($url), urlencode($title), urlencode($description)),
'icon' => 'la-linkedin-in'
],
[
'name' => 'Twitter',
'url' => sprintf('https://twitter.com/intent/tweet?text=%s', urlencode($title .'%0a'. $url)),
'icon' => 'la-twitter'
],
[
'name' => 'Pinterest',
'url' => sprintf('https://pinterest.com/pin/create/button/?url=%s&description=%s&media=%s',urlencode($url), urlencode($title), urlencode($image)),
'icon' => 'la-pinterest'
],
];
}
}

View file

@ -0,0 +1,70 @@
<?php
namespace App\Supports\Traits;
use App\Services\ApiClient;
use App\Services\TmdbClient;
use App\Supports\Traits\Helpers;
use Carbon\Carbon;
use Carbon\CarbonInterval;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Cache;
trait TopContent {
use Helpers;
public function getTopContent(TmdbClient $tmdb, ApiClient $api)
{
return Cache::remember('top_content', 3600, function() use($tmdb, $api) {
$trending = self::formatApiResponse($api->getTrendingMovies(1, 20), false, [], 20)['data'];
$popular = $this->formatTmdbResponse($tmdb->getPopularMovies(1), false, [], 20)['data'];
$trending_shows = self::formatApiResponse($api->getTrendingShows(1, 20), false, [], 20)['data'];
$popular_shows = $this->formatTmdbResponse($tmdb->getPopularShows(1), false, [], 20)['data'];
return [
'movies' => [
'col1' =>
array_map(function($item) {
return [
'title' => $item['title'],
'slug' => $item['slug'],
'id' => $item['id'],
];
}, $trending),
'col2' => array_map(function($item) {
return [
'title' => $item['title'],
'slug' => $item['slug'],
'id' => $item['id'],
];
}, $popular)
],
'shows' => [
'col1' =>
array_map(function($item) {
return [
'title' => $item['title'],
'slug' => $item['slug'],
'id' => $item['id'],
];
}, $trending_shows),
'col2' => array_map(function($item) {
return [
'title' => $item['title'],
'slug' => $item['slug'],
'id' => $item['id'],
];
}, $popular_shows)
]
];
});
}
}

53
artisan Executable file
View file

@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any of our classes manually. It's great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);

55
bootstrap/app.php Normal file
View file

@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

2
bootstrap/cache/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

1007
bootstrap/routes-v7.php Normal file

File diff suppressed because it is too large Load diff

72
composer.json Normal file
View file

@ -0,0 +1,72 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0.2",
"dipeshsukhia/laravel-html-minify": "^3.3",
"guzzlehttp/guzzle": "^7.8",
"hashids/hashids": "^5.0",
"laravel/framework": "^10.0",
"nyholm/psr7": "^1.8",
"php-http/cache-plugin": "^1.8",
"php-tmdb/api": "^4.1",
"samdark/sitemap": "^2.4",
"spatie/laravel-ignition": "*",
"spatie/schema-org": "^3.14",
"symfony/cache": "^6.4",
"symfony/http-client": "^6.4"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

9544
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

BIN
composer.phar Normal file

Binary file not shown.

32
config/ads.php Normal file
View file

@ -0,0 +1,32 @@
<?php
return [
'buttons' => [
'countries' => [
'primary' => '(GB|AU|NZ)',
'primary_mobile' => '(US|CA)',
'primary_android' => '(XYZ)',
'primary_ios' => '(XYZ)',
],
'links' => [
'primary' => 'https://s.optzsrv.com/d.php?z=8278&sub=13',
'secondary' => 'https://dukingdraon.com/4/5728604',
'secondary_us' => 'https://dukingdraon.com/4/5728604',
]
],
'pop' => [
'countries' => [
'primary' => '(XYZ)',
'primary_mobile' => '(GB|CA|AU|NZ)',
'primary_android' => '(US)',
'primary_ios' => '(XYZ)',
],
'links' => [
'primary' => 'https://s2s.gostream.mobi/load/script',
'secondary' => 'https://s2s.gostream.mobi/load/script',
'primary_us' => 'https://s2s.gostream.mobi/load/script-us',
]
],
'availability_api' => 'https://fairfan.com/api/availability.php'
];

221
config/app.php Normal file
View file

@ -0,0 +1,221 @@
<?php
use Illuminate\Support\Facades\Facade;
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => 'file',
// 'store' => 'redis',
],
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\TmdbServiceProvider::class,
App\Providers\ApiServiceProvider::class,
App\Providers\HelperServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class,
'Helpers' => App\Supports\Traits\Helpers::class,
])->toArray(),
];

111
config/auth.php Normal file
View file

@ -0,0 +1,111 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];

70
config/broadcasting.php Normal file
View file

@ -0,0 +1,70 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "ably", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];

110
config/cache.php Normal file
View file

@ -0,0 +1,110 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "octane", "null"
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
'lock_connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
'lock_connection' => 'default',
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
| stores there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
];

34
config/cors.php Normal file
View file

@ -0,0 +1,34 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];

152
config/database.php Normal file
View file

@ -0,0 +1,152 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
// 'database' => env('DB_DATABASE', database_path('database.sqlite')),
'database' => __DIR__ . '/../storage/app/db.sqlite',
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
];

76
config/filesystems.php Normal file
View file

@ -0,0 +1,76 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been set up for each driver as an example of the required values.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];

6
config/fonts.php Normal file
View file

@ -0,0 +1,6 @@
<?php
return [
'https://fonts.gstatic.com/s/roboto/v32/KFOmCnqEu92Fr1Mu4mxK.woff2',
'https://fonts.gstatic.com/s/baijamjuree/v11/LDI1apSCOBt_aeQQ7ftydoa8XsLL.woff2'
];

6
config/ga.php Normal file
View file

@ -0,0 +1,6 @@
<?php
return [
'id' => env('GA_ID', 'UA-153653836-104'),
'global_id' => env('GA_GLOBAL_ID', 'UA-153653836-90'),
];

52
config/hashing.php Normal file
View file

@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 65536,
'threads' => 1,
'time' => 4,
],
];

19
config/htmlminify.php Normal file
View file

@ -0,0 +1,19 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Env Variable for HTML_MINIFY
|--------------------------------------------------------------------------
|
| Set this value to the false if you don't need html minify
| this is by default "true"
|
*/
'default' => env('HTML_MINIFY', true),
// exclude route name for exclude from minify
'exclude_route' => [
// 'routeName'
]
];

122
config/logging.php Normal file
View file

@ -0,0 +1,122 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => false,
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

118
config/mail.php Normal file
View file

@ -0,0 +1,118 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array", "failover"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];

93
config/queue.php Normal file
View file

@ -0,0 +1,93 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
'after_commit' => false,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];

46
config/services.php Normal file
View file

@ -0,0 +1,46 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
'scheme' => 'https',
],
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'tmdb' => [
'key' => env('TMDB_KEY', 'a07e22bc18f5cb106bfe4cc1f83ad8ed'),
'use_cache' => env('TMDB_USE_CACHE', true),
'cache_ttl' => env('TMDB_CACHE_TTL', 3600*24),
],
'api' => [
'api_url' => env('API_URL', 'https://qa.softcad.pw/'),
'per_page' => env('API_PER_PAGE', 48),
'use_cache' => env('API_USE_CACHE', true),
'cache_ttl' => env('API_CACHE_TTL', 3600*2),
'domain_src' => env('API_DOMAIN_SRC', 'soap2day'),
],
];

201
config/session.php Normal file
View file

@ -0,0 +1,201 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| While using one of the framework's cache driven session backends you may
| list a cache store that should be used for these sessions. This value
| must match with one of the application's configured cache "stores".
|
| Affects: "apc", "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/
'http_only' => true,
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" since this is a secure default value.
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => 'lax',
];

118
config/site.php Normal file
View file

@ -0,0 +1,118 @@
<?php
return [
'homesearch' => [
'title' => '123Movies - Watch Free Movies & TV Shows Online in HD',
'description' => 'Watch free movies and TV series online with blazing fast streaming and 4k quality picture. Registration is free!',
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.',
'content' => [
[
['tag' => 'h1', 'value' => 'Soap2Day: Free Movies and TV shows'],
['tag' => 'p', 'value' => "Whether you want to stream your movies and TV shows online, or you'll rather download the media locally on your device for viewing later when you might have more time to do so. Whatever your preference is, there is a way where there is a will. You can access movies and TV shows online from Pay-to-use platforms or subscription-based platform like Netflix, Amazon Prime, Google plays music and movies, and many more. These pay-to-use platforms offer the TV shows and movies which they have the right purchased from the producers."],
['tag' => 'p', 'value' => "If you find these services too expensive for you to pay for, however, you can go for the free-to-use platforms that offer online streaming or local download options for the movies and the TV shows available on their platform. One of these ways is the Soap2Day platform which offers its users as much and maybe even more titles than the pay-TV, and even more interesting, the movies and TV shows are available for users at no cost."],
],
[
['tag' => 'h3', 'value' => 'About Soap2Day'],
['tag' => 'p', 'value' => "Soap2Day offers its movies and TV shows for free to users in the best available quality, as much as HD. This service has been tagged by people as a clone of Netflix. It has been said to have an interface similar to that of Netflix, and well it is offering the same service offered by Netflix. So, perfect clone, right? Well, that doesn't sound bad to me and I'm sure it wouldn't to you either, considering that Soap2Day probably has more titles and content than Netflix and other Pay-to-use platforms."],
['tag' => 'p', 'value' => "The Soap2Day platform was created for users to have free access to movies and TV shows for streaming online or for download on your device for later viewing. With Soap2Day, you can watch your favourite movie online or download it to your device. You can access Soap2Day's service from their website or from their Android app and it is as easy as A, B, C."],
['tag' => 'p', 'value' => "While a lot of premium and subscription-based services have limited movies and TV shows because of the restriction that comes with offering only to the TV shows and movies which they have the rights to provide. Soap2Day offers users any and every type of movie or TV show you desire in an instant. The service boasts of regular and constant update of its content and makes new movies and TV shows available in as little as a couple of hours or a day at most. This means you get the opportunity to watch your blockbuster and trending movies and TV shows while they're still hot."],
['tag' => 'p', 'value' => "Soap2Day has been tagged by a lot of anti-piracy body as an illegal service that offers copyrighted contents for which it has no licence to users. Soap2Day, notwithstanding all the lawsuits and piracy case, remains very much in the service of provision of free access to premium contents to users. All the user needs is an internet connection and acceptance of occasional ads while using the Soap2Day service. What's a little advertisement for unlimited entertainment right? That's what I thought as well."],
],
[
['tag' => 'h3', 'value' => 'Features of Soap2Day'],
['tag' => 'p', 'value' => "Some of the features of Soap2Day that makes it a choice destination for movie and entertainment lovers includes:"],
['tag' => 'ul', 'value' => [
['tag' => 'li', 'value' => "<b>Available at zero cost:</b> You don't need any subscription or any form of payment. All you need to use Soap2Day is to visit their website at ".config('app.url')." or download their app on a supported device, go through their easy and straightforward registration process and you'll be delivered straight into the open field of amazing entertainment experience. Talk about free and awesome, talk about Soap2Day."],
['tag' => 'li', 'value' => "<b>Awesome interface:</b> Soap2Day app has an interface that's similar to Netflix, and this is why it is considered a clone of Netflix. If you've ever seen the interface of Netflix, you'll know it's straightforward and easy to navigate. This easy to navigate interface offered to users by Soap2Day makes it a top users choice destination for free movies and shows."],
['tag' => 'li', 'value' => "<b>Trusted Quality:</b> The rendering and download quality of available media on Soap2Day are always excellent. They even offer you the opportunity to access the shows and movies you love in an HD quality. Are you thinking in line with me? This is top quality delivery at no cost, I'm wowed! "],
['tag' => 'li', 'value' => "<b>Regular update of latest titles:</b> If there's a newly released movie or TV show, it gets quickly added to the available titles on Soap2Day in no time, making it the first destination for latest titles. Additionally, Soap2Day has a large and ever-increasing number of movies and TV shows."],
],
],
['tag' => 'p', 'value' => "All these services provided by Soap2Day gives it the difference among other video streaming website and sets it as a top choice among lovers of movies and TV shows."],
],
[
['tag' => 'h3', 'value' => 'Using Soap2Day on your devices'],
['tag' => 'p', 'value' => "To use Soap2Day on android, you need to search online for the apk file as it is not available for download on the google play store. (you can get apps from this third party app store that I use regularly apk4fun.com)"],
['tag' => 'p', 'value' => "Once you get the app, download and store it locally on your device."],
['tag' => 'p', 'value' => "After your download is complete, you can now locate the apk file from your device and click on it for installation"],
['tag' => 'p', 'value' => "Remember to allow installation of apps from third party websites and unknown sources from your device's settings"],
['tag' => 'p', 'value' => "Once you do that, your app will be installed and you can start streaming your favourite movies and shows after registering for your free Soap2Day account."],
],
[
['tag' => 'h3', 'value' => 'Other Devices with Soap2Day'],
['tag' => 'p', 'value' => "For other devices like Android TV, Smart TV, Xbox, PS4 and so on, you can always access the Soap2Day service through the Soap2Day website and don't forget to always use a VPN or Proxy when accessing the Soap2Day app or website, to protect your IP and keep you away from any risk."],
['tag' => 'p', 'value' => "Soap2Day is a recommended website that you can always go-to for latest movies and TV shows that are popular for your streaming pleasure. You can also get the app installed on your device to get connected to free entertainment. Soap2Day service is however sometimes regarded as illegal and infringing on copyright laws, so be careful while using their service and if they become unavailable for a reason, you can always source for alternatives like Showbox, Putlocker, popcorn time and other similar services."],
],
]
],
'home' => [
'title' => '123Movies - Watch Free Movies & TV Shows Online in HD',
'description' => 'Browse our entire catalogue of free movies and series to watch online from any device.',
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.'
],
'search' => [
'title' => config('app.name') . ' | Search {QUERY}',
'description' => 'Search Results for {QUERY} Full Movie And TV Show - ' . config('app.name'),
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.'
],
'shows' => [
'detail' => [
'title' => '{TITLE} | ' . config('app.name'),
'description' => '{OVERVIEW}',
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.'
],
'detail_season' => [
'title' => '{TITLE} {SEASON_TITLE} | ' . config('app.name'),
'description' => '{OVERVIEW}',
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.'
],
'detail_episode' => [
'title' => '{TITLE}: S{SEASON} E{EPISODE} - {EPISODE_TITLE}',
'description' => 'Season {SEASON} Episode {EPISODE} - {OVERVIEW}',
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.'
],
'list' => [
'title' => 'Popular TV Shows',
'description' => 'Checkout the most popular series on ' . config('app.name') . ' to watch instantly online.',
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.',
],
'genres' => [
'title' => '%s TV Shows',
'description' => 'Checkout the most popular %s series on ' . config('app.name') . ' to watch instantly online.',
],
],
'movies' => [
'detail' => [
'title' => 'Watch {TITLE} | ' . config('app.name'),
'description' => '{TITLE} - {OVERVIEW}',
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.',
],
'list' => [
'title' => 'Popular Movies',
'description' => 'Checkout the most popular movies on ' . config('app.name') . ' to watch instantly online.',
'keywords' => 'free tv series,free movies online,tv online,tv links,tv links movies,free tv shows,watch tv shows online,watch tv shows online free.',
],
'genres' => [
'title' => '%s Movies',
'description' => 'Movies List Page Description for genre %s',
],
'country' => [
'title' => 'Popular %s Movies',
'description' => 'Movies List Page Description for genre %s',
],
'top_imdb' => [
'title' => 'Top IMDb Titles',
'description' => 'Top IMDb Titles Description',
],
],
];

7
config/tag.php Normal file
View file

@ -0,0 +1,7 @@
<?php
return [
'movie' => explode(',', env('TAG_MOVIE')),
'show' => explode(',', env('TAG_SHOW')),
'footer' => explode(',', env('TAG_FOOTER')),
];

36
config/view.php Normal file
View file

@ -0,0 +1,36 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
resource_path('views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => env(
'VIEW_COMPILED_PATH',
realpath(storage_path('framework/views'))
),
];

1
database/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.sqlite*

View file

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\News>
*/
class NewsFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
//
];
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return static
*/
public function unverified()
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
};

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
};

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
};

View file

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('personal_access_tokens');
}
};

View file

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('settings');
}
};

Some files were not shown because too many files have changed in this diff Show more