diff options
Diffstat (limited to 'app')
27 files changed, 1090 insertions, 0 deletions
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php new file mode 100644 index 0000000..a8c5158 --- /dev/null +++ b/app/Console/Kernel.php @@ -0,0 +1,42 @@ +<?php + +namespace App\Console; + +use Illuminate\Console\Scheduling\Schedule; +use Illuminate\Foundation\Console\Kernel as ConsoleKernel; + +class Kernel extends ConsoleKernel +{ + /** + * The Artisan commands provided by your application. + * + * @var array + */ + protected $commands = [ + // + ]; + + /** + * 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'); + } +} diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php new file mode 100644 index 0000000..7e2563a --- /dev/null +++ b/app/Exceptions/Handler.php @@ -0,0 +1,53 @@ +<?php + +namespace App\Exceptions; + +use Exception; +use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; + +class Handler extends ExceptionHandler +{ + /** + * A list of the exception types that are not reported. + * + * @var array + */ + protected $dontReport = [ + // + ]; + + /** + * A list of the inputs that are never flashed for validation exceptions. + * + * @var array + */ + protected $dontFlash = [ + 'password', + 'password_confirmation', + ]; + + /** + * Report or log an exception. + * + * This is a great spot to send exceptions to Sentry, Bugsnag, etc. + * + * @param \Exception $exception + * @return void + */ + public function report(Exception $exception) + { + parent::report($exception); + } + + /** + * Render an exception into an HTTP response. + * + * @param \Illuminate\Http\Request $request + * @param \Exception $exception + * @return \Illuminate\Http\Response + */ + public function render($request, Exception $exception) + { + return parent::render($request, $exception); + } +} diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php new file mode 100644 index 0000000..6a247fe --- /dev/null +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -0,0 +1,32 @@ +<?php + +namespace App\Http\Controllers\Auth; + +use App\Http\Controllers\Controller; +use Illuminate\Foundation\Auth\SendsPasswordResetEmails; + +class ForgotPasswordController extends Controller +{ + /* + |-------------------------------------------------------------------------- + | Password Reset Controller + |-------------------------------------------------------------------------- + | + | This controller is responsible for handling password reset emails and + | includes a trait which assists in sending these notifications from + | your application to your users. Feel free to explore this trait. + | + */ + + use SendsPasswordResetEmails; + + /** + * Create a new controller instance. + * + * @return void + */ + public function __construct() + { + $this->middleware('guest'); + } +} diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php new file mode 100644 index 0000000..b2ea669 --- /dev/null +++ b/app/Http/Controllers/Auth/LoginController.php @@ -0,0 +1,39 @@ +<?php + +namespace App\Http\Controllers\Auth; + +use App\Http\Controllers\Controller; +use Illuminate\Foundation\Auth\AuthenticatesUsers; + +class LoginController extends Controller +{ + /* + |-------------------------------------------------------------------------- + | Login Controller + |-------------------------------------------------------------------------- + | + | This controller handles authenticating users for the application and + | redirecting them to your home screen. The controller uses a trait + | to conveniently provide its functionality to your applications. + | + */ + + use AuthenticatesUsers; + + /** + * Where to redirect users after login. + * + * @var string + */ + protected $redirectTo = '/home'; + + /** + * Create a new controller instance. + * + * @return void + */ + public function __construct() + { + $this->middleware('guest')->except('logout'); + } +} diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php new file mode 100644 index 0000000..f77265a --- /dev/null +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -0,0 +1,71 @@ +<?php + +namespace App\Http\Controllers\Auth; + +use App\User; +use App\Http\Controllers\Controller; +use Illuminate\Support\Facades\Validator; +use Illuminate\Foundation\Auth\RegistersUsers; + +class RegisterController extends Controller +{ + /* + |-------------------------------------------------------------------------- + | Register Controller + |-------------------------------------------------------------------------- + | + | This controller handles the registration of new users as well as their + | validation and creation. By default this controller uses a trait to + | provide this functionality without requiring any additional code. + | + */ + + use RegistersUsers; + + /** + * Where to redirect users after registration. + * + * @var string + */ + protected $redirectTo = '/home'; + + /** + * Create a new controller instance. + * + * @return void + */ + public function __construct() + { + $this->middleware('guest'); + } + + /** + * Get a validator for an incoming registration request. + * + * @param array $data + * @return \Illuminate\Contracts\Validation\Validator + */ + protected function validator(array $data) + { + return Validator::make($data, [ + 'name' => 'required|string|max:255', + 'email' => 'required|string|email|max:255|unique:users', + 'password' => 'required|string|min:6|confirmed', + ]); + } + + /** + * Create a new user instance after a valid registration. + * + * @param array $data + * @return \App\User + */ + protected function create(array $data) + { + return User::create([ + 'name' => $data['name'], + 'email' => $data['email'], + 'password' => bcrypt($data['password']), + ]); + } +} diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php new file mode 100644 index 0000000..cf726ee --- /dev/null +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -0,0 +1,39 @@ +<?php + +namespace App\Http\Controllers\Auth; + +use App\Http\Controllers\Controller; +use Illuminate\Foundation\Auth\ResetsPasswords; + +class ResetPasswordController extends Controller +{ + /* + |-------------------------------------------------------------------------- + | Password Reset Controller + |-------------------------------------------------------------------------- + | + | This controller is responsible for handling password reset requests + | and uses a simple trait to include this behavior. You're free to + | explore this trait and override any methods you wish to tweak. + | + */ + + use ResetsPasswords; + + /** + * Where to redirect users after resetting their password. + * + * @var string + */ + protected $redirectTo = '/home'; + + /** + * Create a new controller instance. + * + * @return void + */ + public function __construct() + { + $this->middleware('guest'); + } +} diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php new file mode 100644 index 0000000..03e02a2 --- /dev/null +++ b/app/Http/Controllers/Controller.php @@ -0,0 +1,13 @@ +<?php + +namespace App\Http\Controllers; + +use Illuminate\Foundation\Bus\DispatchesJobs; +use Illuminate\Routing\Controller as BaseController; +use Illuminate\Foundation\Validation\ValidatesRequests; +use Illuminate\Foundation\Auth\Access\AuthorizesRequests; + +class Controller extends BaseController +{ + use AuthorizesRequests, DispatchesJobs, ValidatesRequests; +} diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php new file mode 100644 index 0000000..d0ad32d --- /dev/null +++ b/app/Http/Controllers/IndexController.php @@ -0,0 +1,40 @@ +<?php +namespace App\Http\Controllers; +use Illuminate\Http\Request; +use App\Helpers\CryptoHelper; + +use Illuminate\Support\Facades\DB; +use App\Http\Controllers\Controller; + +class IndexController extends Controller { + /** + * Shows the index page. + * + * @return Response + */ + public function showPage(Request $request) { + + + $views = array("whisky", "wodka", "gin", "rum", "misc"); + $query = ""; + + foreach($views as $view) { + if ($query != "") { + $query .= " UNION "; + } + # subquery to get procent, because cheap spirits don't look good + #$query .= "(SELECT name, image_url, spirit_type, spirit_type AS url, spirit_type AS angebotsname, (SELECT MAX(procent) FROM " . $view . "_view) as procent, '' AS linktext FROM ". $view ."_view WHERE original_price > 19.98 AND shop != \"Drankdozijn\" ORDER BY procent DESC LIMIT 1)"; + $query .= "(SELECT name, image_url, spirit_type, spirit_type AS url, spirit_type AS angebotsname, (SELECT MAX(procent) FROM " . $view . "_view) as procent, '' AS linktext FROM ". $view ."_view WHERE original_price > 19.98 ORDER BY procent DESC LIMIT 1)"; + } + $query .= " UNION (SELECT 'Alle Angebote' as name, 'https://angebote.fuselkoenig.de/img/feed-icon-gray.jpg' as image_url, 'RSS-Feeds' as spirit_type, 'feeds' AS url, 'RSS-Feeds' AS angebotsname, (SELECT MAX(procent) FROM all_view) as procent, 'Zu den RSS-Feeds' AS linktext FROM all_view LIMIT 1)"; + + $data = DB::select($query); + + $count = DB::select("SELECT count(*) as count FROM all_view")[0]; + #$data = DB::table('whisky_view')->orderBy('procent', 'DESC')->limit(100)->simplePaginate(20); + + #$views[] = "rss-feeds"; + + return view('fk-index', ['data' => $data, 'views' => $views, 'hits' => $count]); + } +} diff --git a/app/Http/Controllers/LookupController.php b/app/Http/Controllers/LookupController.php new file mode 100644 index 0000000..3a876a9 --- /dev/null +++ b/app/Http/Controllers/LookupController.php @@ -0,0 +1,26 @@ +<?php +namespace App\Http\Controllers; +use Illuminate\Http\Request; +use App\Helpers\CryptoHelper; + +use Illuminate\Support\Facades\DB; +use App\Http\Controllers\Controller; + +use Illuminate\Support\Facades\Input; + +class LookupController extends Controller { + /** + * Shows the index page. + * + * @return Response + */ + public function showPage(Request $request) { + + // Used by external linkshorter for better reporting in web analytics. + $query = "SELECT name, shop, spirit_type FROM all_view WHERE short_url = ? LIMIT 1)"; + + $data = DB::table('all_view')->select('name', 'shop', 'spirit_type')->where('url', "https://l.fuselkoenig.de/" . Input::get('short_url'))->limit(1)->get(); + + return response()->json($data); + } +} diff --git a/app/Http/Controllers/OfferController.php b/app/Http/Controllers/OfferController.php new file mode 100644 index 0000000..9182206 --- /dev/null +++ b/app/Http/Controllers/OfferController.php @@ -0,0 +1,95 @@ +<?php +namespace App\Http\Controllers; +use Illuminate\Http\Request; +use App\Helpers\CryptoHelper; + +use Illuminate\Support\Facades\DB; +use App\Http\Controllers\Controller; + +use Carbon; +use Illuminate\Support\Facades\Input; + +class OfferController extends Controller { + /** + * Shows the index page. + * + * @return Response + */ + public function showPage(Request $request) { + + /* + * Sorting + */ + $sort_by = Input::get("sort"); + switch ($sort_by) { + case("price"): + $sort_by = "discounted_price"; + break; + case("discounted_price"): + $sort_by = "discounted_price"; + break; + case("name"): + $sort_by = "name"; + break; + case("shop"): + $sort_by = "shop"; + break; + case("procent"): + $sort_by = "procent"; + break; + case("time"): + $sort_by = "created_at"; + break; + case("created_at"): + $sort_by = "created_at"; + break; + default: + $sort_by = "created_at"; + break; + } + + $order_by = $request->input("order"); + if ( "asc" != $order_by ) { + $order_by = "desc"; + } + + /* + * Database query + */ + $view_name = \Request::route()->getName(); + #$data = DB::table($view_name . '_view')->whereNotNull('url')->orderBy($sort_by, $order_by)->simplePaginate(10); + $data = DB::table($view_name . '_view')->whereNotNull('url')->orderBy($sort_by, $order_by)->paginate(10); + $count = DB::table($view_name . '_view')->whereNotNull('url')->count(); + + $rss_feed = "/angebote/" . $view_name . "/feed/"; + $query_string = ""; + $query_params = Input::except('page'); + foreach( $query_params as $key => $value) { + $query_string .= "&" . $key . "=" . $value; + } + if ( "search" == $view_name && "" != $query_string ) { + $query_string = ltrim($query_string, "&"); + $rss_feed .= "?" . $query_string; + } + + if ( "misc" == $view_name ) { + $view_name = "Andere Angebote"; + if ( $data->count() ) { + $title = "andere Angebote"; + } else { + $title = "anderen Angebote"; + } + } else if ( "all" == $view_name ) { + $view_name = "Alle Angebote"; + if ( $data->count() ) { + $title = "alle Angebote"; + } else { + $title = "Angebote"; + } + } else { + $title = ucfirst($view_name) . "-Angebote"; + } + + return view('fk-offer', ['data' => $data, 'count' => $count, 'spirit_type' => $view_name, 'rss_feed' => $rss_feed, 'title' => $title ]); + } +} diff --git a/app/Http/Controllers/RSSController.php b/app/Http/Controllers/RSSController.php new file mode 100644 index 0000000..5c30bd9 --- /dev/null +++ b/app/Http/Controllers/RSSController.php @@ -0,0 +1,132 @@ +<?php +namespace App\Http\Controllers; +use Illuminate\Http\Request; +use App\Helpers\CryptoHelper; + +use Illuminate\Support\Facades\DB; +use App\Http\Controllers\Controller; + +use Carbon; +use Illuminate\Support\Facades\Input; +use App\Libraries\Utility; + +class RSSController extends Controller { + /** + * Shows the index page. + * + * @return Response + */ + public function showPage(Request $request) { + + /* + * Sorting + */ + $sort_by = Input::get("sort"); + switch ($sort_by) { + case("price"): + $sort_by = "discounted_price"; + break; + case("discounted_price"): + $sort_by = "discounted_price"; + break; + case("name"): + $sort_by = "name"; + break; + case("shop"): + $sort_by = "shop"; + break; + case("procent"): + $sort_by = "procent"; + break; + case("time"): + $sort_by = "created_at"; + break; + case("created_at"): + $sort_by = "created_at"; + break; + default: + $sort_by = "created_at"; + break; + } + + $order_by = $request->input("order"); + if ( "asc" != $order_by ) { + $order_by = "desc"; + } + + /* + * Database query + */ + $view_name = str_replace("_feed", "", \Request::route()->getName()); + $view_name = str_replace("/angebote/", "", $view_name); + + if ( "search" == $view_name ) { + $query = Input::get("q"); + $q = "%" . Utility::escapeLike($query) . "%"; + $data = DB::table('all_view')->whereNotNull('url')->where('name', 'like', $q)->orWhere('spirit_type', 'like', $q)->orderBy($sort_by, $order_by)->limit(20)->get(); + } else { + $data = DB::table($view_name . '_view')->orderBy($sort_by, $order_by)->limit(20)->get(); + } + + /* + * For strftime(). + */ + setlocale(LC_TIME, 'de_DE.utf8'); + + /* + if ( "" != env('PIWIK_RSS_ID') ) { + $piwik = new \PiwikTracker( env('PIWIK_RSS_ID'), env('PIWIK_RSS_URL') ); + $piwik->setTokenAuth( env('PIWIK_RSS_AUTH_TOKEN') ); + $piwik->setVisitorId( $piwik->getVisitorId() ); + $piwik->setIp( $request->header('X_REAL_IP') ); + $piwik->setUrl( $request->fullUrl() ); + + $piwik->setUrlReferrer( $request->server('HTTP_REFERER') ); + $piwik->setBrowserLanguage( $request->server('HTTP_ACCEPT_LANGUAGE') ); + $piwik->setUserAgent( $request->server('HTTP_USER_AGENT') ); + + $piwik->doTrackPageView( ucfirst($view_name) . "-Feed" ); + + if ( "" != Input::get('sort') ) { + $piwik->doTrackEvent("sort", Input::get('sort') ); + } + if ( "" != Input::get('order') ) { + $piwik->doTrackEvent("order", Input::get('order') ); + } + if ( "" != Input::get('q') ) { + $piwik->doTrackEvent("search_phrase", Input::get('q') ); + } + } + */ + + + + $feed = \App::make("feed"); + + $feed->title = "Sonderangebote"; + $feed->description = 'Finde immer die günstigsten Angebote im Bereich Spirituosen. Regelmäßig neue Schnäppchen.'; + $feed->logo = url('https://angebote.fuselkoenig.de/img/paw-400-400.png'); + $feed->link = url( $request->fullUrl() ); + $feed->setDateFormat('timestamp'); // 'datetime', 'timestamp' or 'carbon' + $feed->pubdate = $data[0]->created_at; + $feed->lang = 'de'; + $feed->setShortening(true); // true or false + $feed->setTextLimit(5000); // maximum length of description text + + foreach ( $data as $offer ) { + + # Adds campagin + $offer->url = $offer->url . "?pk_campaign=feed&pk_kwd=" . urlencode($offer->name) . "&pk_source=" . $view_name . "_feed"; + + if ( "" != env('PIWIK_RSS_ID') ) { + // $piwik->doTrackContentImpression($offer->spirit_type, $offer->name, $offer->long_url); + } + + $desc = '<p><img src="'.$offer->image_url.'"></p><p><strong>'.$offer->spirit_type.'</strong><br>'. $offer->name . ' gesenkt auf <strong>' . \TF::fF($offer->discounted_price) . '€</strong> statt ' . \TF::fF($offer->original_price) . '€ ('.$offer->procent.'% Rabatt auf '. $offer->shop .').'; + $feed->add($offer->name, $offer->shop, $offer->url, $offer->created_at, $desc, $desc); + } + + return $feed->render('atom'); + + } +} diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php new file mode 100644 index 0000000..5092f30 --- /dev/null +++ b/app/Http/Controllers/SearchController.php @@ -0,0 +1,80 @@ +<?php +namespace App\Http\Controllers; +use Illuminate\Http\Request; +use App\Helpers\CryptoHelper; + +use Illuminate\Support\Facades\DB; +use App\Http\Controllers\Controller; + +use Illuminate\Support\Facades\Input; + +use App\Libraries\Utility; + +class SearchController extends Controller { + /** + * Shows the index page. + * + * @return Response + */ + public function showPage(Request $request) { + + /* + * Sorting + */ + $sort_by = Input::get("sort"); + switch ($sort_by) { + case("price"): + $sort_by = "discounted_price"; + break; + case("discounted_price"): + $sort_by = "discounted_price"; + break; + case("name"): + $sort_by = "name"; + break; + case("shop"): + $sort_by = "shop"; + break; + case("procent"): + $sort_by = "procent"; + break; + case("time"): + $sort_by = "created_at"; + break; + case("created_at"): + $sort_by = "created_at"; + break; + default: + $sort_by = "created_at"; + break; + } + + $order_by = $request->input("order"); + if ( "desc" != $order_by ) { + if ( "created_at" == $sort_by &&"asc" != $order_by ) { + $order_by = "desc"; + } else { + $order_by = "asc"; + } + } + + $query = Input::get("q"); + $q = "%" . Utility::escapeLike($query) . "%"; + $data = DB::table('all_view')->whereNotNull('url')->where('name', 'like', $q)->orWhere('spirit_type', 'like', $q)->orWhere('shop', 'like', $q)->orderBy($sort_by, $order_by)->paginate(20); + $count = DB::table('all_view')->whereNotNull('url')->where('name', 'like', $q)->orWhere('spirit_type', 'like', $q)->orWhere('shop', 'like', $q); + + $query_string = ""; + $query_params = Input::except('page'); + foreach( $query_params as $key => $value) { + $query_string .= "&" . $key . "=" . $value; + } + $query_string = ltrim($query_string, "&"); + + /* + * For strftime() in view. + */ + #setlocale(LC_TIME, 'de_DE.utf8'); + + return view('fk-search', ['data' => $data, 'count' => $count, 'search_phrase' => $query, 'rss_feed' => '/angebote/search/feed/?' . $query_string ]); + } +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php new file mode 100644 index 0000000..74b1cbd --- /dev/null +++ b/app/Http/Kernel.php @@ -0,0 +1,62 @@ +<?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 + */ + protected $middleware = [ + \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, + \App\Http\Middleware\TrimStrings::class, + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + \App\Http\Middleware\TrustProxies::class, + ]; + + /** + * The application's route middleware groups. + * + * @var array + */ + protected $middlewareGroups = [ + 'web' => [ + \App\Http\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + // \Illuminate\Session\Middleware\AuthenticateSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + + 'api' => [ + 'throttle:60,1', + 'bindings', + ], + ]; + + /** + * The application's route middleware. + * + * These middleware may be assigned to groups or used individually. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + ]; +} diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php new file mode 100644 index 0000000..033136a --- /dev/null +++ b/app/Http/Middleware/EncryptCookies.php @@ -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 + */ + protected $except = [ + // + ]; +} diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php new file mode 100644 index 0000000..e4cec9c --- /dev/null +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -0,0 +1,26 @@ +<?php + +namespace App\Http\Middleware; + +use Closure; +use Illuminate\Support\Facades\Auth; + +class RedirectIfAuthenticated +{ + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard + * @return mixed + */ + public function handle($request, Closure $next, $guard = null) + { + if (Auth::guard($guard)->check()) { + return redirect('/home'); + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php new file mode 100644 index 0000000..5a50e7b --- /dev/null +++ b/app/Http/Middleware/TrimStrings.php @@ -0,0 +1,18 @@ +<?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 + */ + protected $except = [ + 'password', + 'password_confirmation', + ]; +} diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php new file mode 100644 index 0000000..3ce0214 --- /dev/null +++ b/app/Http/Middleware/TrustProxies.php @@ -0,0 +1,23 @@ +<?php + +namespace App\Http\Middleware; + +use Illuminate\Http\Request; +use Fideloper\Proxy\TrustProxies as Middleware; + +class TrustProxies extends Middleware +{ + /** + * The trusted proxies for this application. + * + * @var array + */ + protected $proxies; + + /** + * The headers that should be used to detect proxies. + * + * @var string + */ + protected $headers = Request::HEADER_X_FORWARDED_ALL; +} diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php new file mode 100644 index 0000000..0c13b85 --- /dev/null +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -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 + */ + protected $except = [ + // + ]; +} diff --git a/app/Libraries/TemplateFunction.php b/app/Libraries/TemplateFunction.php new file mode 100644 index 0000000..54a36de --- /dev/null +++ b/app/Libraries/TemplateFunction.php @@ -0,0 +1,23 @@ +<?php +namespace App\Libraries; +use App\Libraries\TemplateFunction; + +class TemplateFunction { + private static function formatFloat($float, $size = 2) { + return number_format($float, $size, ",", "."); + } + + public static function fF($float, $format = "") { + $f = $float; + if ( 0 == ($f - floor($f))) { + $f = intval($f); + } else { + $f = TemplateFunction::formatFloat($float); + } + return $f; + } + + public static function T($timestamp) { + return gmdate("d.m.Y.", $timestamp); + } +} diff --git a/app/Libraries/Utility.php b/app/Libraries/Utility.php new file mode 100644 index 0000000..95a8b80 --- /dev/null +++ b/app/Libraries/Utility.php @@ -0,0 +1,12 @@ +<?php +namespace App\Libraries; +use App\Libraries\Utility; + +class Utility { + + public static function escapeLike($string) { + $search = array('%', '_'); + $replace = array('\%', '\_'); + return str_replace($search, $replace, $string); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php new file mode 100644 index 0000000..4d3bd77 --- /dev/null +++ b/app/Providers/AppServiceProvider.php @@ -0,0 +1,35 @@ +<?php + +namespace App\Providers; + +use Illuminate\Support\ServiceProvider; +use URL; + +class AppServiceProvider extends ServiceProvider +{ + /** + * Bootstrap any application services. + * + * @return void + */ + public function boot() + { + + URL::forceScheme('https'); + + /* + * For strftime() in view. + */ + setlocale(LC_TIME, 'de_DE.utf8'); + } + + /** + * Register any application services. + * + * @return void + */ + public function register() + { + // + } +} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php new file mode 100644 index 0000000..9784b1a --- /dev/null +++ b/app/Providers/AuthServiceProvider.php @@ -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 policy mappings for the application. + * + * @var array + */ + protected $policies = [ + 'App\Model' => 'App\Policies\ModelPolicy', + ]; + + /** + * Register any authentication / authorization services. + * + * @return void + */ + public function boot() + { + $this->registerPolicies(); + + // + } +} diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php new file mode 100644 index 0000000..352cce4 --- /dev/null +++ b/app/Providers/BroadcastServiceProvider.php @@ -0,0 +1,21 @@ +<?php + +namespace App\Providers; + +use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Facades\Broadcast; + +class BroadcastServiceProvider extends ServiceProvider +{ + /** + * Bootstrap any application services. + * + * @return void + */ + public function boot() + { + Broadcast::routes(); + + require base_path('routes/channels.php'); + } +} diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php new file mode 100644 index 0000000..fca6152 --- /dev/null +++ b/app/Providers/EventServiceProvider.php @@ -0,0 +1,32 @@ +<?php + +namespace App\Providers; + +use Illuminate\Support\Facades\Event; +use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; + +class EventServiceProvider extends ServiceProvider +{ + /** + * The event listener mappings for the application. + * + * @var array + */ + protected $listen = [ + 'App\Events\Event' => [ + 'App\Listeners\EventListener', + ], + ]; + + /** + * Register any events for your application. + * + * @return void + */ + public function boot() + { + parent::boot(); + + // + } +} diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..5ea48d3 --- /dev/null +++ b/app/Providers/RouteServiceProvider.php @@ -0,0 +1,73 @@ +<?php + +namespace App\Providers; + +use Illuminate\Support\Facades\Route; +use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; + +class RouteServiceProvider extends ServiceProvider +{ + /** + * This namespace is applied to your controller routes. + * + * In addition, it is set as the URL generator's root namespace. + * + * @var string + */ + protected $namespace = 'App\Http\Controllers'; + + /** + * Define your route model bindings, pattern filters, etc. + * + * @return void + */ + public function boot() + { + // + + parent::boot(); + } + + /** + * Define the routes for the application. + * + * @return void + */ + public function map() + { + $this->mapApiRoutes(); + + $this->mapWebRoutes(); + + // + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + * + * @return void + */ + protected function mapWebRoutes() + { + Route::middleware('web') + ->namespace($this->namespace) + ->group(base_path('routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapApiRoutes() + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->namespace) + ->group(base_path('routes/api.php')); + } +} diff --git a/app/Shop.php b/app/Shop.php new file mode 100644 index 0000000..1e57060 --- /dev/null +++ b/app/Shop.php @@ -0,0 +1,10 @@ +<?php + +namespace App; + +use Illuminate\Database\Eloquent\Model; + +class Shop extends Model +{ + protected $table = 'shop'; +} diff --git a/app/User.php b/app/User.php new file mode 100644 index 0000000..bfd96a6 --- /dev/null +++ b/app/User.php @@ -0,0 +1,29 @@ +<?php + +namespace App; + +use Illuminate\Notifications\Notifiable; +use Illuminate\Foundation\Auth\User as Authenticatable; + +class User extends Authenticatable +{ + use Notifiable; + + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'name', 'email', 'password', + ]; + + /** + * The attributes that should be hidden for arrays. + * + * @var array + */ + protected $hidden = [ + 'password', 'remember_token', + ]; +} |
