Commit fd3bbb63 authored by Roberto Guido's avatar Roberto Guido

commit iniziale

parents
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vscode
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Events\SluggableCreating;
class Booking extends Model
{
use SluggableID;
public $incrementing = false;
protected $dispatchesEvents = [
'creating' => SluggableCreating::class,
];
public function grant()
{
return $this->belongsTo('App\Grant');
}
public function getNameAttribute()
{
return sprintf('%s %s', $this->grant->name, $this->description);
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Log;
class Config extends Model
{
public static function provideDefault($name)
{
$defaults = [
'start_hour' => 8,
'end_hour' => 24,
'social_year' => date('Y-m-d', strtotime('Sep 15, ' . date('Y')))
];
if (isset($defaults[$name])) {
$c = new Config();
$c->name = $name;
$c->value = $defaults[$name];
$c->save();
return $c;
}
else {
Log::error('Configuration type not found: ' . $name);
return null;
}
}
}
<?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');
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Events\SluggableCreating;
class Contact extends Model
{
use SluggableID;
public $incrementing = false;
protected $dispatchesEvents = [
'creating' => SluggableCreating::class,
];
public function getNameAttribute()
{
return sprintf('%s %s', $this->firstname, $this->lastname);
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Events\SluggableCreating;
class Customer extends Model
{
use SluggableID;
public $incrementing = false;
protected $dispatchesEvents = [
'creating' => SluggableCreating::class,
];
public function grants()
{
return $this->hasMany('App\Grant')->orderBy('year', 'desc');
}
public function contacts()
{
return $this->belongsToMany('App\Contact')->orderBy('lastname', 'asc');
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Events\SluggableCreating;
class CustomerType extends Model
{
use SluggableID;
public $incrementing = false;
protected $dispatchesEvents = [
'creating' => SluggableCreating::class,
];
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Events\SluggableCreating;
class Equipment extends Model
{
use SluggableID;
public $incrementing = false;
protected $dispatchesEvents = [
'creating' => SluggableCreating::class,
];
}
<?php
namespace App\Events;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Queue\SerializesModels;
class SluggableCreating
{
use SerializesModels;
public $sluggable;
public function __construct(Model $sluggable)
{
$this->sluggable = $sluggable;
}
}
<?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.
*
* @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);
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Events\SluggableCreating;
class Grant extends Model
{
use SluggableID;
public $incrementing = false;
protected $dispatchesEvents = [
'creating' => SluggableCreating::class,
];
public function customer()
{
return $this->belongsTo('App\Customer');
}
public function getNameAttribute()
{
return sprintf('%s %s', $this->customer->name, $this->year);
}
}
<?php
function myConf($name)
{
$c = App\Config::where('name', $name)->first();
if ($c == null)
$c = App\Config::provideDefault($name);
return $c->value;
}
function currentSocialYear()
{
$current_month = date('m');
if ($current_month < 8)
return sprintf('%s/%s', date('Y', strtotime('-1 years')), date('Y'));
else
return sprintf('%s/%s', date('Y'), date('Y', strtotime('+1 years')));
}
<?php
function months()
{
return [
'Gennaio',
'Febbraio',
'Marzo',
'Aprile',
'Maggio',
'Giugno',
'Luglio',
'Agosto',
'Settembre',
'Ottobre',
'Novembre',
'Dicembre'
];
}
function floatToTime($f)
{
if (strpos($f, '.') !== false)
return sprintf('%02d:30', intval($f));
else
return sprintf('%02d:00', $f);
}
function timeToFloat($f)
{
list($hours, $minutes) = explode(':', $f);
if ($minutes == '30')
return ((int) $hours) + 0.5;
else
return (int) $hours;
}
<?php
function decodeDate($date)
{
list($day, $month, $year) = explode('/', $date);
return sprintf('%s-%s-%s', $year, $month, $day);
}
<?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');
}
}
<?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 = '/';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
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' => Hash::make($data['password']),
]);
}
}
<?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');
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Customer;
use App\Room;
use App\Booking;
class BookingController extends Controller
{
public function create(Request $request)
{
$selected_day = $request->input('day');
$selected_room = Room::find($request->input('room'));
$selected_start_hour = $request->input('hour');
$selected_end_hour = $selected_start_hour + 1;
$selected_start_hour = floatToTime($selected_start_hour);
if ($selected_end_hour > myConf('end_hour'))
$selected_end_hour = $selected_start_hour + 0.5;
$selected_end_hour = floatToTime($selected_end_hour);
return view('booking.create', compact('selected_room', 'selected_day', 'selected_start_hour', 'selected_end_hour'));
}
private function guessTotalHours($request)
{
$from = $request->input('from');
if (empty($from))
$from = timeToFloat($request->input('selected_start_hour'));
$to = $request->input('to');
if (empty($to))
$to = timeToFloat($request->input('selected_end_hour'));
$type = $request->input('type');
switch($type) {
case 'recurring':
case 'course':
return 10;
break;
case 'occasional':
case 'party':
return ($to - $from);
break;
}
}
public function wizard(Request $request, $step)
{
switch ($step) {
case 'customers':
$customer_id = $request->input('customer_id');
if (empty($customer_id) || $customer_id == 'new')
$customer = new Customer();
else
$customer = Customer::find($customer_id);
return view('booking.customers.grants', compact('customer'));
break;
case 'spaces':
$type = $request->input('type');
switch($type) {
case 'recurring':
case 'course':
return view('booking.spaces.recurring', $request->only(['selected_room', 'selected_day', 'selected_start_hour', 'selected_end_hour']));
break;
case 'occasional':