├── .env.example
├── .gitattributes
├── .gitignore
├── .travis.yml
├── app
├── Category.php
├── Client.php
├── Console
│ ├── Commands
│ │ ├── CreateUser.php
│ │ ├── Inspire.php
│ │ └── SpawnOccurrences.php
│ └── Kernel.php
├── Events
│ ├── Event.php
│ ├── ServiceWasCreated.php
│ └── ServiceWasUpdated.php
├── Exceptions
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── Api
│ │ │ ├── CategoryController.php
│ │ │ ├── ClientController.php
│ │ │ └── OccurrenceController.php
│ │ ├── Auth
│ │ │ ├── AuthController.php
│ │ │ └── PasswordController.php
│ │ ├── CategoryController.php
│ │ ├── ClientController.php
│ │ ├── Controller.php
│ │ ├── HomeController.php
│ │ ├── ServiceController.php
│ │ └── SettingsController.php
│ ├── Kernel.php
│ ├── Middleware
│ │ ├── Authenticate.php
│ │ ├── EncryptCookies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ └── VerifyCsrfToken.php
│ ├── Requests
│ │ └── Request.php
│ ├── api_routes.php
│ └── routes.php
├── Jobs
│ └── Job.php
├── Listeners
│ ├── .gitkeep
│ ├── CreateServiceOccurrence.php
│ └── UpdateServiceOccurrences.php
├── Occurrence.php
├── Occurrences
│ ├── OccurrenceCreator.php
│ └── OccurrenceRepository.php
├── Policies
│ └── .gitkeep
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Service.php
├── User.php
└── helpers.php
├── artisan
├── bootstrap
├── app.php
├── autoload.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── compile.php
├── database.php
├── filesystems.php
├── mail.php
├── queue.php
├── services.php
├── session.php
└── view.php
├── database
├── .gitignore
├── factories
│ └── ModelFactory.php
├── migrations
│ ├── .gitkeep
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2016_07_14_092017_create_clients_table.php
│ ├── 2016_07_14_092024_create_services_table.php
│ ├── 2016_07_14_125816_create_occurrences_table.php
│ ├── 2016_07_16_212605_create_categories_table.php
│ ├── 2016_07_17_085858_add_preferred_currency_and_email_notifications_to_users_table.php
│ ├── 2016_07_17_095203_create_cache_table.php
│ ├── 2016_07_18_123554_drop_unique_index_for_tax_number_from_clients_table.php
│ └── 2016_07_31_180730_fix_occurrences_occurs_at_column_by_dropping_table.php
└── seeds
│ ├── .gitkeep
│ ├── DatabaseSeeder.php
│ └── SampleDataSeeder.php
├── gulpfile.js
├── license.md
├── overview.png
├── package.json
├── phpunit.xml
├── public
├── .htaccess
├── build
│ ├── css
│ │ ├── app-13224de714.css
│ │ └── app.css.map
│ ├── fonts
│ │ ├── FontAwesome.otf
│ │ ├── fontawesome-webfont.eot
│ │ ├── fontawesome-webfont.svg
│ │ ├── fontawesome-webfont.ttf
│ │ ├── fontawesome-webfont.woff
│ │ ├── fontawesome-webfont.woff2
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.svg
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ ├── js
│ │ ├── all.js.map
│ │ ├── app-832c11af61.js
│ │ └── app.js.map
│ └── rev-manifest.json
├── css
│ ├── app.css
│ └── app.css.map
├── favicon.ico
├── index.php
├── js
│ ├── app.js
│ └── app.js.map
├── robots.txt
└── web.config
├── readme.md
├── resources
├── assets
│ ├── js
│ │ └── app.js
│ └── less
│ │ ├── app.less
│ │ └── themes
│ │ └── paper
│ │ ├── bootswatch.less
│ │ └── variables.less
├── lang
│ └── en
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
└── views
│ ├── auth
│ ├── emails
│ │ └── password.blade.php
│ ├── login.blade.php
│ ├── passwords
│ │ ├── email.blade.php
│ │ └── reset.blade.php
│ └── register.blade.php
│ ├── categories
│ ├── create.blade.php
│ ├── edit.blade.php
│ └── index.blade.php
│ ├── clients
│ ├── create.blade.php
│ ├── edit.blade.php
│ └── index.blade.php
│ ├── errors
│ └── 503.blade.php
│ ├── home.blade.php
│ ├── layouts
│ ├── app.blade.php
│ └── partials
│ │ ├── navbar.blade.php
│ │ ├── page_header.blade.php
│ │ └── validation.blade.php
│ ├── partials
│ └── _occurrences_table.blade.php
│ ├── report.blade.php
│ ├── services
│ ├── create.blade.php
│ ├── edit.blade.php
│ └── index.blade.php
│ ├── settings
│ └── edit.blade.php
│ └── vendor
│ ├── .gitkeep
│ └── flash
│ ├── message.blade.php
│ └── modal.blade.php
├── server.php
├── storage
├── app
│ ├── .gitignore
│ └── public
│ │ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
└── tests
├── TestCase.php
├── functional
├── CategoryTest.php
├── ClientTest.php
├── OverviewTest.php
├── ReportTest.php
├── ServiceTest.php
└── SettingsTest.php
├── models
├── OccurrenceTest.php
└── ServiceTest.php
└── unit
└── OccurrenceCreatorTest.php
/.env.example:
--------------------------------------------------------------------------------
1 | APP_ENV=local
2 | APP_KEY=SomeRandomString
3 | APP_DEBUG=true
4 | APP_LOG_LEVEL=debug
5 | APP_URL=http://localhost
6 |
7 | DB_CONNECTION=mysql
8 | DB_HOST=192.168.10.10
9 | DB_PORT=3306
10 | DB_DATABASE=kyle
11 | DB_USERNAME=homestead
12 | DB_PASSWORD=secret
13 |
14 | CACHE_DRIVER=file
15 | SESSION_DRIVER=file
16 | QUEUE_DRIVER=sync
17 |
18 | REDIS_HOST=127.0.0.1
19 | REDIS_PASSWORD=null
20 | REDIS_PORT=6379
21 |
22 | MAIL_DRIVER=smtp
23 | MAIL_HOST=mailtrap.io
24 | MAIL_PORT=2525
25 | MAIL_USERNAME=null
26 | MAIL_PASSWORD=null
27 | MAIL_ENCRYPTION=null
28 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | /node_modules
3 | /public/storage
4 | Homestead.yaml
5 | Homestead.json
6 | .env
7 | .idea
8 | deploy/
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - '7.0'
5 |
6 | services:
7 | - mysql
8 |
9 | install:
10 | - composer install --prefer-source --no-interaction
11 |
12 | before_script:
13 | - mysql -e 'create database kyle_test;'
14 | - php artisan migrate --force
15 |
16 | script:
17 | - vendor/bin/phpunit
18 |
19 | env:
20 | - DB_DATABASE=kyle_test DB_USERNAME=root APP_KEY="SdklvfdkJY46KvNmnihYLfspA4xOLeub"
--------------------------------------------------------------------------------
/app/Category.php:
--------------------------------------------------------------------------------
1 | hasMany(Service::class);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Client.php:
--------------------------------------------------------------------------------
1 | hasMany(Service::class);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Console/Commands/CreateUser.php:
--------------------------------------------------------------------------------
1 | argument('name');
45 | $email = $this->argument('email');
46 | $password = $this->secret('User password:');
47 |
48 | $data = compact('name', 'email', 'password');
49 | $validator = Validator::make($data, [
50 | 'name' => 'required|max:255',
51 | 'email' => 'required|email|max:255|unique:users',
52 | 'password' => 'required|min:6',
53 | ]);
54 | if($validator->fails()) {
55 | foreach($validator->errors()->all() as $error) {
56 | $this->error($error);
57 | return 0;
58 | }
59 | }
60 |
61 | User::create([
62 | 'name' => $data['name'],
63 | 'email' => $data['email'],
64 | 'password' => bcrypt($data['password']),
65 | 'api_token' => bin2hex(openssl_random_pseudo_bytes(16)),
66 | 'email_notifications' => true,
67 | 'preferred_currency' => 'usd'
68 | ]);
69 |
70 | $this->info('User has been created.');
71 | $this->comment('You can now login using the email and password entered here.');
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/Console/Commands/Inspire.php:
--------------------------------------------------------------------------------
1 | comment(PHP_EOL.Inspiring::quote().PHP_EOL);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Console/Commands/SpawnOccurrences.php:
--------------------------------------------------------------------------------
1 | occurrenceCreator = $occurrenceCreator;
40 | $this->services = $services;
41 | $this->carbon = $carbon;
42 | }
43 |
44 | /**
45 | * Execute the console command.
46 | *
47 | * @return mixed
48 | */
49 | public function handle()
50 | {
51 | foreach($this->services->all() as $service) {
52 | $date = $this->carbon->createFromDate(
53 | date('Y'),
54 | $service->month,
55 | $service->day
56 | );
57 | $this->occurrenceCreator->create($date, $service);
58 | }
59 |
60 | $this->info($this->services->count() . ' occurrences have been spawned');
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('occurrences:spawn')
30 | // every year at january 1st
31 | ->yearly();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Events/Event.php:
--------------------------------------------------------------------------------
1 | service = $service;
23 | }
24 |
25 | /**
26 | * Get the channels the event should be broadcast on.
27 | *
28 | * @return array
29 | */
30 | public function broadcastOn()
31 | {
32 | return [];
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Events/ServiceWasUpdated.php:
--------------------------------------------------------------------------------
1 | service = $service;
23 | }
24 |
25 | /**
26 | * Get the channels the event should be broadcast on.
27 | *
28 | * @return array
29 | */
30 | public function broadcastOn()
31 | {
32 | return [];
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | validate($request, [
16 | 'name' => 'required|string|max:255'
17 | ]);
18 |
19 | $category = Category::create([
20 | 'name' => $request->get('name')
21 | ]);
22 |
23 | return $category->toArray();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/ClientController.php:
--------------------------------------------------------------------------------
1 | validate($request, [
16 | 'name' => 'required|string|max:255'
17 | ]);
18 |
19 | $client = Client::create([
20 | 'name' => $request->get('name')
21 | ]);
22 |
23 | return $client->toArray();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/OccurrenceController.php:
--------------------------------------------------------------------------------
1 | validate($request, [
15 | 'state' => 'required|boolean'
16 | ]);
17 |
18 | $occurrence->offer_sent = $request->get('state');
19 | $occurrence->save();
20 |
21 | return $occurrence->offer_sent;
22 | }
23 |
24 | public function togglePayment(Occurrence $occurrence, Request $request)
25 | {
26 | $this->validate($request, [
27 | 'state' => 'required|boolean'
28 | ]);
29 |
30 | var_dump($occurrence->occurs_at);
31 |
32 | $occurrence->payment_received = $request->get('state');
33 | $occurrence->save();
34 |
35 | var_dump($occurrence->occurs_at);
36 |
37 | return $occurrence->payment_received;
38 | }
39 |
40 | public function toggleReceipt(Occurrence $occurrence, Request $request)
41 | {
42 | $this->validate($request, [
43 | 'state' => 'required|boolean'
44 | ]);
45 |
46 | $occurrence->receipt_sent = $request->get('state');
47 | $occurrence->save();
48 |
49 | return $occurrence->receipt_sent;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/AuthController.php:
--------------------------------------------------------------------------------
1 | middleware($this->guestMiddleware(), ['except' => 'logout']);
41 | }
42 |
43 | /**
44 | * Get a validator for an incoming registration request.
45 | *
46 | * @param array $data
47 | * @return \Illuminate\Contracts\Validation\Validator
48 | */
49 | protected function validator(array $data)
50 | {
51 | return Validator::make($data, [
52 | 'name' => 'required|max:255',
53 | 'email' => 'required|email|max:255|unique:users',
54 | 'password' => 'required|min:6|confirmed',
55 | ]);
56 | }
57 |
58 | /**
59 | * Create a new user instance after a valid registration.
60 | *
61 | * @param array $data
62 | * @return User
63 | */
64 | protected function create(array $data)
65 | {
66 | return User::create([
67 | 'name' => $data['name'],
68 | 'email' => $data['email'],
69 | 'password' => bcrypt($data['password']),
70 | 'api_token' => bin2hex(openssl_random_pseudo_bytes(16))
71 | ]);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/PasswordController.php:
--------------------------------------------------------------------------------
1 | middleware($this->guestMiddleware());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Http/Controllers/CategoryController.php:
--------------------------------------------------------------------------------
1 | with(['services'])
20 | ->get();
21 |
22 | return view('categories.index')->with(compact('categories'));
23 | }
24 |
25 | /**
26 | * Show the form for creating a new resource.
27 | *
28 | * @return \Illuminate\Http\Response
29 | */
30 | public function create()
31 | {
32 | return view('categories.create');
33 | }
34 |
35 | /**
36 | * Store a newly created resource in storage.
37 | *
38 | * @param \Illuminate\Http\Request $request
39 | * @return \Illuminate\Http\Response
40 | */
41 | public function store(Request $request)
42 | {
43 | $this->validate($request, [
44 | 'name' => 'required|string|max:255',
45 | ]);
46 |
47 | $category = Category::create([
48 | 'name' => $request->get('name'),
49 | ]);
50 |
51 | flash()->success('Category created!');
52 |
53 | return redirect()->route('categories.index');
54 | }
55 |
56 | /**
57 | * Show the form for editing the specified resource.
58 | *
59 | * @param int $id
60 | * @return \Illuminate\Http\Response
61 | */
62 | public function edit($id)
63 | {
64 | $category = Category::findOrFail($id);
65 |
66 | return view('categories.edit')->with(compact('category'));
67 | }
68 |
69 | /**
70 | * Update the specified resource in storage.
71 | *
72 | * @param \Illuminate\Http\Request $request
73 | * @param int $id
74 | * @return \Illuminate\Http\Response
75 | */
76 | public function update(Request $request, $id)
77 | {
78 | $category = Category::findOrFail($id);
79 |
80 | $this->validate($request, [
81 | 'name' => 'required|string|max:255',
82 | ]);
83 |
84 | $category->update([
85 | 'name' => $request->get('name'),
86 | ]);
87 |
88 | flash()->success('Category Updated!');
89 |
90 | return redirect()->route('categories.edit', $category->id);
91 | }
92 |
93 | /**
94 | * Remove the specified resource from storage.
95 | *
96 | * @param int $id
97 | * @return \Illuminate\Http\Response
98 | */
99 | public function destroy($id)
100 | {
101 | $category = Category::findOrFail($id);
102 | $category->delete();
103 |
104 | flash()->success('Category Deleted!');
105 |
106 | return redirect()->route('categories.index');
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ClientController.php:
--------------------------------------------------------------------------------
1 | get();
19 |
20 | return view('clients.index')->with(compact('clients'));
21 | }
22 |
23 | /**
24 | * Show the form for creating a new resource.
25 | *
26 | * @return \Illuminate\Http\Response
27 | */
28 | public function create()
29 | {
30 | return view('clients.create');
31 | }
32 |
33 | /**
34 | * Store a newly created resource in storage.
35 | *
36 | * @param \Illuminate\Http\Request $request
37 | * @return \Illuminate\Http\Response
38 | */
39 | public function store(Request $request)
40 | {
41 | $this->validate($request, [
42 | 'name' => 'required|string|max:255',
43 | 'tax_number' => 'string|max:255|unique:clients',
44 | 'street' => 'string|max:255',
45 | 'city' => 'string|max:255',
46 | 'postal_code' => 'integer',
47 | ]);
48 |
49 | $client = Client::create([
50 | 'name' => $request->get('name'),
51 | 'tax_number' => $request->get('tax_number'),
52 | 'street' => $request->get('street'),
53 | 'city' => $request->get('city'),
54 | 'postal_code' => $request->get('postal_code'),
55 | ]);
56 |
57 | flash()->success('Client created!');
58 |
59 | return redirect()->route('clients.index');
60 | }
61 |
62 | /**
63 | * Show the form for editing the specified resource.
64 | *
65 | * @param int $id
66 | * @return \Illuminate\Http\Response
67 | */
68 | public function edit($id)
69 | {
70 | $client = Client::findOrFail($id);
71 |
72 | return view('clients.edit')->with(compact('client'));
73 | }
74 |
75 | /**
76 | * Update the specified resource in storage.
77 | *
78 | * @param \Illuminate\Http\Request $request
79 | * @param int $id
80 | * @return \Illuminate\Http\Response
81 | */
82 | public function update(Request $request, $id)
83 | {
84 | $client = Client::findOrFail($id);
85 |
86 | $this->validate($request, [
87 | 'name' => 'required|string|max:255',
88 | 'tax_number' => 'string|max:255|unique:clients,tax_number,' . $client->id,
89 | 'street' => 'string|max:255',
90 | 'city' => 'string|max:255',
91 | 'postal_code' => 'integer',
92 | ]);
93 |
94 | $client->update([
95 | 'name' => $request->get('name'),
96 | 'tax_number' => $request->get('tax_number'),
97 | 'street' => $request->get('street'),
98 | 'city' => $request->get('city'),
99 | 'postal_code' => $request->get('postal_code'),
100 | ]);
101 |
102 | flash()->success('Client Updated!');
103 |
104 | return redirect()->route('clients.edit', $client->id);
105 | }
106 |
107 | /**
108 | * Remove the specified resource from storage.
109 | *
110 | * @param int $id
111 | * @return \Illuminate\Http\Response
112 | */
113 | public function destroy($id)
114 | {
115 | $client = Client::findOrFail($id);
116 | $client->delete();
117 |
118 | flash()->success('Client Deleted!');
119 |
120 | return redirect()->route('clients.index');
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | getOccurrencesForCurrentMonth();
20 | $occurrencesNextMonth = $occurrenceRepository->getOccurrencesForNextMonth();
21 | $previousUnpaidOccurrences = $occurrenceRepository->getPreviousUnpaidOccurrences();
22 |
23 | return view('home')->with(compact(
24 | 'occurrencesThisMonth',
25 | 'occurrencesNextMonth',
26 | 'previousUnpaidOccurrences'
27 | ));
28 | }
29 |
30 | /**
31 | * Show the report for all things.
32 | *
33 | * @return [type]
34 | */
35 | public function report()
36 | {
37 | $services = Service::orderBy('month')
38 | ->orderBy('day')
39 | ->where('active', 1)
40 | ->with(['client', 'category'])
41 | ->get();
42 |
43 | $clients = Client::orderBy('name')
44 | ->whereHas('services', function ($query) {
45 | $query->where('active', 1);
46 | })
47 | ->with(['services' => function ($query) {
48 | $query->where('active', 1);
49 | }])
50 | ->get();
51 |
52 | $categories = Category::orderBy('name')
53 | ->whereHas('services', function ($query) {
54 | $query->where('active', 1);
55 | })
56 | ->with(['services' => function ($query) {
57 | $query->where('active', 1);
58 | }])
59 | ->get();
60 |
61 | return view('report')->with(compact('services', 'clients', 'categories'));
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ServiceController.php:
--------------------------------------------------------------------------------
1 | orderBy('day')
24 | ->with(['client', 'category'])
25 | ->get();
26 |
27 | return view('services.index')->with(compact('services'));
28 | }
29 |
30 | /**
31 | * Show the form for creating a new resource.
32 | *
33 | * @return \Illuminate\Http\Response
34 | */
35 | public function create()
36 | {
37 | $currencies = [
38 | 'hrk' => 'HRK',
39 | 'usd' => 'USD',
40 | 'eur' => 'EUR',
41 | ];
42 | $clients = Client::orderBy('name')->pluck('name', 'id')->toArray();
43 | $categories = Category::orderBy('name')->pluck('name', 'id')->toArray();
44 |
45 | return view('services.create')->with(compact('currencies', 'clients', 'categories'));
46 | }
47 |
48 | /**
49 | * Store a newly created resource in storage.
50 | *
51 | * @param \Illuminate\Http\Request $request
52 | * @return \Illuminate\Http\Response
53 | */
54 | public function store(Request $request)
55 | {
56 | $this->validate($request, [
57 | 'title' => 'required|max:255',
58 | 'note' => 'string',
59 | 'month' => 'required|integer|min:1|max:12',
60 | 'day' => 'required|integer|min:1|max:31',
61 | 'cost' => 'required|regex:/([0-9],)+[0-9]{2,}/|min:0',
62 | 'currency' => 'required|in:hrk,usd,eur',
63 | 'exchange_rate' => 'required|numeric|min:0',
64 | 'active' => 'boolean',
65 | 'client_id' => 'required|exists:clients,id',
66 | 'category_id' => 'required|exists:categories,id'
67 | ]);
68 |
69 | $client = Client::find($request->get('client_id'));
70 | $category = Category::find($request->get('category_id'));
71 |
72 | $service = new Service;
73 | $service->title = $request->get('title');
74 | $service->note = $request->get('note');
75 | $service->month = $request->get('month');
76 | $service->day = $request->get('day');
77 | $service->cost = convert_integer($request->get('cost'));
78 | $service->currency = $request->get('currency');
79 | $service->exchange_rate = $request->get('exchange_rate');
80 | $service->active = $request->get('active', false);
81 | $service->client()->associate($client);
82 | $service->category()->associate($category);
83 | $service->save();
84 |
85 | event(new ServiceWasCreated($service));
86 |
87 | flash()->success('Service created!');
88 |
89 | return redirect()->route('services.index');
90 | }
91 |
92 | /**
93 | * Show the form for editing the specified resource.
94 | *
95 | * @param int $id
96 | * @return \Illuminate\Http\Response
97 | */
98 | public function edit($id)
99 | {
100 | $service = Service::findOrFail($id);
101 | $currencies = [
102 | 'hrk' => 'HRK',
103 | 'usd' => 'USD',
104 | 'eur' => 'EUR',
105 | ];
106 | $clients = Client::orderBy('name')->pluck('name', 'id')->toArray();
107 | $categories = Category::orderBy('name')->pluck('name', 'id')->toArray();
108 |
109 | return view('services.edit')->with(compact('service', 'currencies', 'clients', 'categories'));
110 | }
111 |
112 | /**
113 | * Update the specified resource in storage.
114 | *
115 | * @param \Illuminate\Http\Request $request
116 | * @param int $id
117 | * @return \Illuminate\Http\Response
118 | */
119 | public function update(Request $request, $id)
120 | {
121 | $service = Service::findOrFail($id);
122 |
123 | $this->validate($request, [
124 | 'title' => 'required|max:255',
125 | 'note' => 'string',
126 | 'month' => 'required|integer|min:1|max:12',
127 | 'day' => 'required|integer|min:1|max:31',
128 | 'cost' => 'required|regex:/([0-9],)+[0-9]{2,}/|min:0',
129 | 'currency' => 'required|in:hrk,usd,eur',
130 | 'exchange_rate' => 'required|numeric|min:0',
131 | 'active' => 'boolean',
132 | 'client_id' => 'required|exists:clients,id',
133 | 'category_id' => 'required|exists:categories,id'
134 | ]);
135 |
136 | $service->update([
137 | 'title' => $request->get('title'),
138 | 'note' => $request->get('note'),
139 | 'month' => $request->get('month'),
140 | 'day' => $request->get('day'),
141 | 'cost' => convert_integer($request->get('cost')),
142 | 'currency' => $request->get('currency'),
143 | 'exchange_rate' => $request->get('exchange_rate'),
144 | 'active' => $request->get('active', false),
145 | ]);
146 |
147 | $client = Client::find($request->get('client_id'));
148 | $service->client()->associate($client);
149 | $category = Category::find($request->get('category_id'));
150 | $service->category()->associate($category);
151 | $service->save();
152 |
153 | event(new ServiceWasUpdated($service));
154 |
155 | flash()->success('Service Updated!');
156 |
157 | return redirect()->route('services.edit', $service->id);
158 | }
159 |
160 | /**
161 | * Remove the specified resource from storage.
162 | *
163 | * @param int $id
164 | * @return \Illuminate\Http\Response
165 | */
166 | public function destroy($id)
167 | {
168 | $service = Service::findOrFail($id);
169 | $service->delete();
170 |
171 | flash()->success('Service Deleted!');
172 |
173 | return redirect()->route('services.index');
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/app/Http/Controllers/SettingsController.php:
--------------------------------------------------------------------------------
1 | user();
19 | $currencies = [
20 | 'hrk' => 'HRK',
21 | 'usd' => 'USD',
22 | 'eur' => 'EUR'
23 | ];
24 |
25 | return view('settings.edit')->with(compact('user', 'currencies'));
26 | }
27 |
28 | /**
29 | * Update the specified resource in storage.
30 | *
31 | * @param \Illuminate\Http\Request $request
32 | * @return \Illuminate\Http\Response
33 | */
34 | public function update(Request $request)
35 | {
36 | $this->validate($request, [
37 | 'name' => 'required|max:255',
38 | 'email' => 'required|email|max:255|unique:users,email,' . auth()->user()->id,
39 | 'password' => 'min:6|confirmed',
40 | 'preferred_currency' => 'required|in:hrk,usd,eur',
41 | 'email_notifications' => 'boolean'
42 | ]);
43 |
44 | auth()->user()->update([
45 | 'name' => $request->get('name'),
46 | 'email' => $request->get('email'),
47 | 'preferred_currency' => $request->get('preferred_currency'),
48 | 'email_notifications' => $request->get('email_notifications', false)
49 | ]);
50 |
51 | if($request->get('password', "") != "") {
52 | auth()->user()->password = bcrypt($request->get('password'));
53 | auth()->user()->save();
54 | }
55 |
56 | flash()->success('Settings updated!');
57 |
58 | return redirect('/settings');
59 | }
60 |
61 | /**
62 | * Remove the specified resource from storage.
63 | *
64 | * @param int $id
65 | * @return \Illuminate\Http\Response
66 | */
67 | public function destroy($id)
68 | {
69 | //
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
27 | \App\Http\Middleware\EncryptCookies::class,
28 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
29 | \Illuminate\Session\Middleware\StartSession::class,
30 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
31 | \App\Http\Middleware\VerifyCsrfToken::class,
32 | ],
33 |
34 | 'api' => [
35 | 'throttle:60,1',
36 | ],
37 | ];
38 |
39 | /**
40 | * The application's route middleware.
41 | *
42 | * These middleware may be assigned to groups or used individually.
43 | *
44 | * @var array
45 | */
46 | protected $routeMiddleware = [
47 | 'auth' => \App\Http\Middleware\Authenticate::class,
48 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
49 | 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
50 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
51 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
52 | ];
53 | }
54 |
--------------------------------------------------------------------------------
/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | guest()) {
21 | if ($request->ajax() || $request->wantsJson()) {
22 | return response('Unauthorized.', 401);
23 | }
24 |
25 | return redirect()->guest('login');
26 | }
27 |
28 | return $next($request);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/VerifyCsrfToken.php:
--------------------------------------------------------------------------------
1 | 'api/v1', 'middleware' => 'auth:api'], function () {
4 |
5 | Route::post('categories', 'CategoryController@store');
6 |
7 | Route::post('clients', 'ClientController@store');
8 |
9 | Route::get('occurrences/{occurrence}/offer', 'OccurrenceController@toggleOffer');
10 | Route::get('occurrences/{occurrence}/payment', 'OccurrenceController@togglePayment');
11 | Route::get('occurrences/{occurrence}/receipt', 'OccurrenceController@toggleReceipt');
12 | });
--------------------------------------------------------------------------------
/app/Http/routes.php:
--------------------------------------------------------------------------------
1 | 'auth'], function () {
15 | Route::get('/', 'HomeController@index');
16 |
17 | Route::get('settings', 'SettingsController@edit');
18 | Route::put('settings', 'SettingsController@update');
19 |
20 | Route::get('report', 'HomeController@report');
21 |
22 | Route::resource('clients', 'ClientController');
23 |
24 | Route::resource('categories', 'CategoryController');
25 |
26 | Route::resource('services', 'ServiceController');
27 | });
28 |
29 | // Authentication Routes...
30 | $this->get('login', 'Auth\AuthController@showLoginForm');
31 | $this->post('login', 'Auth\AuthController@login');
32 | $this->get('logout', 'Auth\AuthController@logout');
33 |
34 | // Registration Routes...
35 | // $this->get('register', 'Auth\AuthController@showRegistrationForm');
36 | // $this->post('register', 'Auth\AuthController@register');
37 |
38 | // Password Reset Routes...
39 | $this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
40 | $this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
41 | $this->post('password/reset', 'Auth\PasswordController@reset');
42 |
--------------------------------------------------------------------------------
/app/Jobs/Job.php:
--------------------------------------------------------------------------------
1 | occurrenceCreator = $occurrenceCreator;
23 | }
24 |
25 | /**
26 | * Handle the event.
27 | *
28 | * @param ServiceWasCreated $event
29 | * @return void
30 | */
31 | public function handle(ServiceWasCreated $event)
32 | {
33 | $date = \Carbon\Carbon::createFromDate(
34 | date('Y'),
35 | $event->service->month,
36 | $event->service->day
37 | );
38 |
39 | $this->occurrenceCreator->create($date, $event->service);
40 |
41 | /**
42 | * TODO: Maybe do a check here if the occurrence for this service
43 | * already exists ???
44 | */
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/Listeners/UpdateServiceOccurrences.php:
--------------------------------------------------------------------------------
1 | service->occurrences()->get() as $occurence)
30 | {
31 | $date = \Carbon\Carbon::createFromDate(
32 | $occurence->occurs_at->year,
33 | $event->service->month,
34 | $event->service->day
35 | );
36 |
37 | $occurence->occurs_at = $date->timestamp;
38 | $occurence->save();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/Occurrence.php:
--------------------------------------------------------------------------------
1 | belongsTo(Service::class);
32 | }
33 |
34 | /**
35 | * If the offer_sent is set to true, this
36 | * returns false.
37 | *
38 | * @return [type]
39 | */
40 | public function getFutureOfferState()
41 | {
42 | return $this->offer_sent ? 0 : 1;
43 | }
44 |
45 | /**
46 | * If the payment_received is set to true
47 | * this returns false.
48 | *
49 | * @return [type]
50 | */
51 | public function getFuturePaymentState()
52 | {
53 | return $this->payment_received ? 0 : 1;
54 | }
55 |
56 | /**
57 | * If the receipt_sent is set to true
58 | * this returns false.
59 | *
60 | * @return [type]
61 | */
62 | public function getFutureReceiptState()
63 | {
64 | return $this->receipt_sent ? 0 : 1;
65 | }
66 |
67 | /**
68 | * Check if the occurrence is paid.
69 | * "Has the payment been received."
70 | *
71 | * @return boolean
72 | */
73 | public function isPaid()
74 | {
75 | return (bool) $this->payment_received;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/Occurrences/OccurrenceCreator.php:
--------------------------------------------------------------------------------
1 | occurs_at = $date->timestamp;
23 | $occurrence->offer_sent = false;
24 | $occurrence->payment_received = false;
25 | $occurrence->receipt_sent = false;
26 | $occurrence->service()->associate($service);
27 | $occurrence->save();
28 |
29 | return $occurrence;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/Occurrences/OccurrenceRepository.php:
--------------------------------------------------------------------------------
1 | occurrences = $occurrences;
21 | }
22 |
23 | /**
24 | * It gets occurrences for specified month in current year
25 | * but only occurrences that belong to a service that is
26 | * active and eager loads service.client nested relationship.
27 | *
28 | * @param int $month
29 | * @return [type]
30 | */
31 | public function getOccurrencesForMonth(int $month)
32 | {
33 | // Change (int 9) to (string '09')
34 | if ($month < 10) {
35 | $month = '0' . $month;
36 | }
37 |
38 | $year = Carbon::now()->year;
39 |
40 | return $this->occurrences
41 | ->orderBy('occurs_at')
42 | ->where(function ($query) use ($month, $year) {
43 | // $date = 2016-07-%
44 | $date = $year . '-' . $month . '-%';
45 | $query->where('occurs_at', 'like', $date);
46 | })
47 | ->whereHas('service', function ($query) {
48 | $query->where('active', 1);
49 | })
50 | ->with(['service.client'])
51 | ->get();
52 | }
53 |
54 | /**
55 | * It gets active occurrences for current month.
56 | *
57 | * @return [type]
58 | */
59 | public function getOccurrencesForCurrentMonth()
60 | {
61 | $month = Carbon::now()->month;
62 |
63 | return $this->getOccurrencesForMonth($month);
64 | }
65 |
66 | /**
67 | * It gets active occurrences for the upcoming month.
68 | *
69 | * @return [type]
70 | */
71 | public function getOccurrencesForNextMonth()
72 | {
73 | $month = Carbon::now()->month;
74 | $occurrences = [];
75 |
76 | if (++$month <= 12) {
77 | $occurrences = $this->getOccurrencesForMonth($month);
78 | }
79 |
80 | return $occurrences;
81 | }
82 |
83 | /**
84 | * It gets all active occurrences that are not paid
85 | * for this year up to the current month.
86 | *
87 | * @return [type]
88 | */
89 | public function getPreviousUnpaidOccurrences()
90 | {
91 | $date = Carbon::now();
92 | $date->day = 1;
93 | $date->hour = 0;
94 | $date->minute = 0;
95 | $date->second = 0;
96 |
97 | return $this->occurrences
98 | ->orderBy('occurs_at')
99 | ->where(function ($query) use ($date) {
100 | $query->where('occurs_at', '<', $date);
101 | })
102 | ->where('payment_received', 0)
103 | ->whereHas('service', function ($query) {
104 | $query->where('active', 1);
105 | })
106 | ->with(['service.client'])
107 | ->get();
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/app/Policies/.gitkeep:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
17 | ];
18 |
19 | /**
20 | * Register any application authentication / authorization services.
21 | *
22 | * @param \Illuminate\Contracts\Auth\Access\Gate $gate
23 | * @return void
24 | */
25 | public function boot(GateContract $gate)
26 | {
27 | $this->registerPolicies($gate);
28 |
29 | //
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Providers/EventServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
17 | 'App\Listeners\CreateServiceOccurrence',
18 | ],
19 | 'App\Events\ServiceWasUpdated' => [
20 | 'App\Listeners\UpdateServiceOccurrences',
21 | ],
22 | ];
23 |
24 | /**
25 | * Register any other events for your application.
26 | *
27 | * @param \Illuminate\Contracts\Events\Dispatcher $events
28 | * @return void
29 | */
30 | public function boot(DispatcherContract $events)
31 | {
32 | parent::boot($events);
33 |
34 | //
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapWebRoutes($router);
41 |
42 | //
43 | }
44 |
45 | /**
46 | * Define the "web" routes for the application.
47 | *
48 | * These routes all receive session state, CSRF protection, etc.
49 | *
50 | * @param \Illuminate\Routing\Router $router
51 | * @return void
52 | */
53 | protected function mapWebRoutes(Router $router)
54 | {
55 | $router->group([
56 | 'namespace' => $this->namespace, 'middleware' => 'web',
57 | ], function ($router) {
58 | require app_path('Http/routes.php');
59 | });
60 |
61 | $router->group([
62 | 'namespace' => $this->namespace . '\Api', 'middleware' => 'api',
63 | ], function ($router) {
64 | require app_path('Http/api_routes.php');
65 | });
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/Service.php:
--------------------------------------------------------------------------------
1 | belongsTo(Client::class);
31 | }
32 |
33 | /**
34 | * To which category does this service belong.
35 | *
36 | * @return [type]
37 | */
38 | public function category()
39 | {
40 | return $this->belongsTo(Category::class);
41 | }
42 |
43 | /**
44 | * One per year would be perfect. :)
45 | *
46 | * @return [type]
47 | */
48 | public function occurrences()
49 | {
50 | return $this->hasMany(Occurrence::class);
51 | }
52 |
53 | /**
54 | * Converts 112345 to 1123,45.
55 | * For forms only.
56 | *
57 | * @return string
58 | */
59 | public function formCostAttribute()
60 | {
61 | return number_format($this->cost / 100, 2, ',', '');
62 | }
63 |
64 | /**
65 | * Returns formatted cost with currency.
66 | * Converts `112345 usd` to `1.123,45 USD`.
67 | *
68 | * @return string
69 | */
70 | public function getFormattedCostAttribute()
71 | {
72 | return number_format($this->cost / 100, 2, ',', '.') . ' ' . strtoupper($this->currency);
73 | }
74 |
75 | /**
76 | * Gets the sum of all services, converted to user's
77 | * preferred currency with current exchange rate.
78 | *
79 | * It is possible to pass a collection of services to this method,
80 | * and it will return the sum of that collection.
81 | *
82 | * @param Collection|null $services
83 | * @return [type]
84 | */
85 | public function getSum(Collection $services = null)
86 | {
87 | if(!($services instanceof Collection)) {
88 | $services = $this->all();
89 | }
90 |
91 | $sum = 0;
92 | foreach($services as $service) {
93 | $currentCurrency = strtoupper($service->currency);
94 | $sum+= ($service->cost / 100);
95 | }
96 |
97 | return number_format($sum, 2, ',', '.') . ' ' . $currentCurrency;
98 | }
99 |
100 | /**
101 | * Gets the sum of all services, converted to user's
102 | * preferred currency with current exchange rate for the entered month.
103 | *
104 | * By default, all services are included (active and non active).
105 | *
106 | * @param $month
107 | * @param boolean $onlyActive
108 | * @return [type]
109 | */
110 | public function getSumForMonth($month, $onlyActive = false)
111 | {
112 | $services = $this->where('month', $month);
113 | if($onlyActive) {
114 | $services->where('active', 1);
115 | }
116 | $services = $services->get();
117 |
118 | return $this->getSum($services);
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/app/User.php:
--------------------------------------------------------------------------------
1 | make(Illuminate\Contracts\Console\Kernel::class);
32 |
33 | $status = $kernel->handle(
34 | $input = new Symfony\Component\Console\Input\ArgvInput,
35 | new Symfony\Component\Console\Output\ConsoleOutput
36 | );
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Shutdown The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once Artisan has finished running. We will fire off the shutdown events
44 | | so that any final work may be done by the application before we shut
45 | | down the process. This is the last thing to happen to the request.
46 | |
47 | */
48 |
49 | $kernel->terminate($input, $status);
50 |
51 | exit($status);
52 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/bootstrap/autoload.php:
--------------------------------------------------------------------------------
1 | =7.0.0",
19 | "laravel/framework": "5.2.*",
20 | "laravelcollective/html": "^5.2",
21 | "laravelista/ekko": "^1.2",
22 | "laracasts/flash": "^2.0",
23 | "doctrine/dbal": "^2.5"
24 | },
25 | "require-dev": {
26 | "fzaninotto/faker": "~1.4",
27 | "mockery/mockery": "0.9.*",
28 | "phpunit/phpunit": "~4.0",
29 | "symfony/css-selector": "2.8.*|3.0.*",
30 | "symfony/dom-crawler": "2.8.*|3.0.*"
31 | },
32 | "autoload": {
33 | "classmap": [
34 | "database"
35 | ],
36 | "psr-4": {
37 | "App\\": "app/"
38 | },
39 | "files": [
40 | "app/helpers.php"
41 | ]
42 | },
43 | "autoload-dev": {
44 | "classmap": [
45 | "tests/TestCase.php"
46 | ]
47 | },
48 | "scripts": {
49 | "post-root-package-install": [
50 | "php -r \"copy('.env.example', '.env');\""
51 | ],
52 | "post-create-project-cmd": [
53 | "php artisan key:generate"
54 | ],
55 | "post-install-cmd": [
56 | "Illuminate\\Foundation\\ComposerScripts::postInstall",
57 | "php artisan optimize"
58 | ],
59 | "post-update-cmd": [
60 | "Illuminate\\Foundation\\ComposerScripts::postUpdate",
61 | "php artisan optimize"
62 | ]
63 | },
64 | "config": {
65 | "preferred-install": "dist"
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'token',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | User Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'eloquent',
70 | 'model' => App\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | Here you may set the options for resetting passwords including the view
85 | | that is your password reset e-mail. You may also set the name of the
86 | | table that maintains all of the reset tokens for your application.
87 | |
88 | | You may specify multiple password reset configurations if you have more
89 | | than one user table or model in the application and you want to have
90 | | separate password reset settings based on the specific user types.
91 | |
92 | | The expire time is the number of minutes that the reset token should be
93 | | considered valid. This security feature keeps tokens short-lived so
94 | | they have less time to be guessed. You may change this as needed.
95 | |
96 | */
97 |
98 | 'passwords' => [
99 | 'users' => [
100 | 'provider' => 'users',
101 | 'email' => 'auth.emails.password',
102 | 'table' => 'password_resets',
103 | 'expire' => 60,
104 | ],
105 | ],
106 |
107 | ];
108 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'pusher'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_KEY'),
36 | 'secret' => env('PUSHER_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | //
40 | ],
41 | ],
42 |
43 | 'redis' => [
44 | 'driver' => 'redis',
45 | 'connection' => 'default',
46 | ],
47 |
48 | 'log' => [
49 | 'driver' => 'log',
50 | ],
51 |
52 | ],
53 |
54 | ];
55 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | */
30 |
31 | 'stores' => [
32 |
33 | 'apc' => [
34 | 'driver' => 'apc',
35 | ],
36 |
37 | 'array' => [
38 | 'driver' => 'array',
39 | ],
40 |
41 | 'database' => [
42 | 'driver' => 'database',
43 | 'table' => 'cache',
44 | 'connection' => null,
45 | ],
46 |
47 | 'file' => [
48 | 'driver' => 'file',
49 | 'path' => storage_path('framework/cache'),
50 | ],
51 |
52 | 'memcached' => [
53 | 'driver' => 'memcached',
54 | 'servers' => [
55 | [
56 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
57 | 'port' => env('MEMCACHED_PORT', 11211),
58 | 'weight' => 100,
59 | ],
60 | ],
61 | ],
62 |
63 | 'redis' => [
64 | 'driver' => 'redis',
65 | 'connection' => 'default',
66 | ],
67 |
68 | ],
69 |
70 | /*
71 | |--------------------------------------------------------------------------
72 | | Cache Key Prefix
73 | |--------------------------------------------------------------------------
74 | |
75 | | When utilizing a RAM based store such as APC or Memcached, there might
76 | | be other applications utilizing the same cache. So, we'll specify a
77 | | value to get prefixed to all our keys so we can avoid collisions.
78 | |
79 | */
80 |
81 | 'prefix' => 'kyle',
82 |
83 | ];
84 |
--------------------------------------------------------------------------------
/config/compile.php:
--------------------------------------------------------------------------------
1 | [
17 | //
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled File Providers
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may list service providers which define a "compiles" function
26 | | that returns additional files that should be compiled, providing an
27 | | easy way to get common files from any packages you are utilizing.
28 | |
29 | */
30 |
31 | 'providers' => [
32 | //
33 | ],
34 |
35 | ];
36 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | PDO::FETCH_CLASS,
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Database Connection Name
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may specify which of the database connections below you wish
24 | | to use as your default connection for all database work. Of course
25 | | you may use many connections at once using the Database library.
26 | |
27 | */
28 |
29 | 'default' => env('DB_CONNECTION', 'mysql'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Database Connections
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here are each of the database connections setup for your application.
37 | | Of course, examples of configuring each database platform that is
38 | | supported by Laravel is shown below to make development simple.
39 | |
40 | |
41 | | All database work in Laravel is done through the PHP PDO facilities
42 | | so make sure you have the driver for your particular database of
43 | | choice installed on your machine before you begin development.
44 | |
45 | */
46 |
47 | 'connections' => [
48 |
49 | 'sqlite' => [
50 | 'driver' => 'sqlite',
51 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
52 | 'prefix' => '',
53 | ],
54 |
55 | 'mysql' => [
56 | 'driver' => 'mysql',
57 | 'host' => env('DB_HOST', 'localhost'),
58 | 'port' => env('DB_PORT', '3306'),
59 | 'database' => env('DB_DATABASE', 'forge'),
60 | 'username' => env('DB_USERNAME', 'forge'),
61 | 'password' => env('DB_PASSWORD', ''),
62 | 'charset' => 'utf8',
63 | 'collation' => 'utf8_unicode_ci',
64 | 'prefix' => '',
65 | 'strict' => false,
66 | 'engine' => null,
67 | ],
68 |
69 | /**
70 | * Used for seeding the database for testing.
71 | */
72 | 'mysql_testing' => [
73 | 'driver' => 'mysql',
74 | 'host' => env('DB_HOST', 'localhost'),
75 | 'port' => env('DB_PORT', '3306'),
76 | 'database' => env('DB_TEST_DATABASE', 'kyle_testing'),
77 | 'username' => env('DB_USERNAME', 'forge'),
78 | 'password' => env('DB_PASSWORD', ''),
79 | 'charset' => 'utf8',
80 | 'collation' => 'utf8_unicode_ci',
81 | 'prefix' => '',
82 | 'strict' => false,
83 | 'engine' => null,
84 | ],
85 |
86 | 'pgsql' => [
87 | 'driver' => 'pgsql',
88 | 'host' => env('DB_HOST', 'localhost'),
89 | 'port' => env('DB_PORT', '5432'),
90 | 'database' => env('DB_DATABASE', 'forge'),
91 | 'username' => env('DB_USERNAME', 'forge'),
92 | 'password' => env('DB_PASSWORD', ''),
93 | 'charset' => 'utf8',
94 | 'prefix' => '',
95 | 'schema' => 'public',
96 | ],
97 |
98 | ],
99 |
100 | /*
101 | |--------------------------------------------------------------------------
102 | | Migration Repository Table
103 | |--------------------------------------------------------------------------
104 | |
105 | | This table keeps track of all the migrations that have already run for
106 | | your application. Using this information, we can determine which of
107 | | the migrations on disk haven't actually been run in the database.
108 | |
109 | */
110 |
111 | 'migrations' => 'migrations',
112 |
113 | /*
114 | |--------------------------------------------------------------------------
115 | | Redis Databases
116 | |--------------------------------------------------------------------------
117 | |
118 | | Redis is an open source, fast, and advanced key-value store that also
119 | | provides a richer set of commands than a typical key-value systems
120 | | such as APC or Memcached. Laravel makes it easy to dig right in.
121 | |
122 | */
123 |
124 | 'redis' => [
125 |
126 | 'cluster' => false,
127 |
128 | 'default' => [
129 | 'host' => env('REDIS_HOST', 'localhost'),
130 | 'password' => env('REDIS_PASSWORD', null),
131 | 'port' => env('REDIS_PORT', 6379),
132 | 'database' => 0,
133 | ],
134 |
135 | ],
136 |
137 | ];
138 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | 'local',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Default Cloud Filesystem Disk
23 | |--------------------------------------------------------------------------
24 | |
25 | | Many applications store files both locally and in the cloud. For this
26 | | reason, you may specify a default "cloud" driver here. This driver
27 | | will be bound as the Cloud disk implementation in the container.
28 | |
29 | */
30 |
31 | 'cloud' => 's3',
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Filesystem Disks
36 | |--------------------------------------------------------------------------
37 | |
38 | | Here you may configure as many filesystem "disks" as you wish, and you
39 | | may even configure multiple disks of the same driver. Defaults have
40 | | been setup for each driver as an example of the required options.
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'visibility' => 'public',
55 | ],
56 |
57 | 's3' => [
58 | 'driver' => 's3',
59 | 'key' => 'your-key',
60 | 'secret' => 'your-secret',
61 | 'region' => 'your-region',
62 | 'bucket' => 'your-bucket',
63 | ],
64 |
65 | ],
66 |
67 | ];
68 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | SMTP Host Address
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may provide the host address of the SMTP server used by your
27 | | applications. A default option is provided that is compatible with
28 | | the Mailgun mail service which will provide reliable deliveries.
29 | |
30 | */
31 |
32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | SMTP Host Port
37 | |--------------------------------------------------------------------------
38 | |
39 | | This is the SMTP port used by your application to deliver e-mails to
40 | | users of the application. Like the host we have set this value to
41 | | stay compatible with the Mailgun e-mail application by default.
42 | |
43 | */
44 |
45 | 'port' => env('MAIL_PORT', 587),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Global "From" Address
50 | |--------------------------------------------------------------------------
51 | |
52 | | You may wish for all e-mails sent by your application to be sent from
53 | | the same address. Here, you may specify a name and address that is
54 | | used globally for all e-mails that are sent by your application.
55 | |
56 | */
57 |
58 | 'from' => ['address' => null, 'name' => null],
59 |
60 | /*
61 | |--------------------------------------------------------------------------
62 | | E-Mail Encryption Protocol
63 | |--------------------------------------------------------------------------
64 | |
65 | | Here you may specify the encryption protocol that should be used when
66 | | the application send e-mail messages. A sensible default using the
67 | | transport layer security protocol should provide great security.
68 | |
69 | */
70 |
71 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
72 |
73 | /*
74 | |--------------------------------------------------------------------------
75 | | SMTP Server Username
76 | |--------------------------------------------------------------------------
77 | |
78 | | If your SMTP server requires a username for authentication, you should
79 | | set it here. This will get used to authenticate with your server on
80 | | connection. You may also set the "password" value below this one.
81 | |
82 | */
83 |
84 | 'username' => env('MAIL_USERNAME'),
85 |
86 | /*
87 | |--------------------------------------------------------------------------
88 | | SMTP Server Password
89 | |--------------------------------------------------------------------------
90 | |
91 | | Here you may set the password required by your SMTP server to send out
92 | | messages from your application. This will be given to the server on
93 | | connection so that the application will be able to send messages.
94 | |
95 | */
96 |
97 | 'password' => env('MAIL_PASSWORD'),
98 |
99 | /*
100 | |--------------------------------------------------------------------------
101 | | Sendmail System Path
102 | |--------------------------------------------------------------------------
103 | |
104 | | When using the "sendmail" driver to send e-mails, we will need to know
105 | | the path to where Sendmail lives on this server. A default path has
106 | | been provided here, which will work well on most of your systems.
107 | |
108 | */
109 |
110 | 'sendmail' => '/usr/sbin/sendmail -bs',
111 |
112 | ];
113 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_DRIVER', 'sync'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the connection information for each server that
26 | | is used by your application. A default configuration has been added
27 | | for each back-end shipped with Laravel. You are free to add more.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'expire' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'ttr' => 90,
49 | ],
50 |
51 | 'sqs' => [
52 | 'driver' => 'sqs',
53 | 'key' => 'your-public-key',
54 | 'secret' => 'your-secret-key',
55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
56 | 'queue' => 'your-queue-name',
57 | 'region' => 'us-east-1',
58 | ],
59 |
60 | 'redis' => [
61 | 'driver' => 'redis',
62 | 'connection' => 'default',
63 | 'queue' => 'default',
64 | 'expire' => 90,
65 | ],
66 |
67 | ],
68 |
69 | /*
70 | |--------------------------------------------------------------------------
71 | | Failed Queue Jobs
72 | |--------------------------------------------------------------------------
73 | |
74 | | These options configure the behavior of failed queue job logging so you
75 | | can control which database and table are used to store the jobs that
76 | | have failed. You may change them to any database / table you wish.
77 | |
78 | */
79 |
80 | 'failed' => [
81 | 'database' => env('DB_CONNECTION', 'mysql'),
82 | 'table' => 'failed_jobs',
83 | ],
84 |
85 | ];
86 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | ],
21 |
22 | 'mandrill' => [
23 | 'secret' => env('MANDRILL_SECRET'),
24 | ],
25 |
26 | 'ses' => [
27 | 'key' => env('SES_KEY'),
28 | 'secret' => env('SES_SECRET'),
29 | 'region' => 'us-east-1',
30 | ],
31 |
32 | 'sparkpost' => [
33 | 'secret' => env('SPARKPOST_SECRET'),
34 | ],
35 |
36 | 'stripe' => [
37 | 'model' => App\User::class,
38 | 'key' => env('STRIPE_KEY'),
39 | 'secret' => env('STRIPE_SECRET'),
40 | ],
41 |
42 | ];
43 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Session Lifetime
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may specify the number of minutes that you wish the session
27 | | to be allowed to remain idle before it expires. If you want them
28 | | to immediately expire on the browser closing, set that option.
29 | |
30 | */
31 |
32 | 'lifetime' => 120,
33 |
34 | 'expire_on_close' => false,
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Session Encryption
39 | |--------------------------------------------------------------------------
40 | |
41 | | This option allows you to easily specify that all of your session data
42 | | should be encrypted before it is stored. All encryption will be run
43 | | automatically by Laravel and you can use the Session like normal.
44 | |
45 | */
46 |
47 | 'encrypt' => false,
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Session File Location
52 | |--------------------------------------------------------------------------
53 | |
54 | | When using the native session driver, we need a location where session
55 | | files may be stored. A default has been set for you but a different
56 | | location may be specified. This is only needed for file sessions.
57 | |
58 | */
59 |
60 | 'files' => storage_path('framework/sessions'),
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Session Database Connection
65 | |--------------------------------------------------------------------------
66 | |
67 | | When using the "database" or "redis" session drivers, you may specify a
68 | | connection that should be used to manage these sessions. This should
69 | | correspond to a connection in your database configuration options.
70 | |
71 | */
72 |
73 | 'connection' => null,
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Session Database Table
78 | |--------------------------------------------------------------------------
79 | |
80 | | When using the "database" session driver, you may specify the table we
81 | | should use to manage the sessions. Of course, a sensible default is
82 | | provided for you; however, you are free to change this as needed.
83 | |
84 | */
85 |
86 | 'table' => 'sessions',
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Session Sweeping Lottery
91 | |--------------------------------------------------------------------------
92 | |
93 | | Some session drivers must manually sweep their storage location to get
94 | | rid of old sessions from storage. Here are the chances that it will
95 | | happen on a given request. By default, the odds are 2 out of 100.
96 | |
97 | */
98 |
99 | 'lottery' => [2, 100],
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Session Cookie Name
104 | |--------------------------------------------------------------------------
105 | |
106 | | Here you may change the name of the cookie used to identify a session
107 | | instance by ID. The name specified here will get used every time a
108 | | new session cookie is created by the framework for every driver.
109 | |
110 | */
111 |
112 | 'cookie' => 'kyle_session',
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Session Cookie Path
117 | |--------------------------------------------------------------------------
118 | |
119 | | The session cookie path determines the path for which the cookie will
120 | | be regarded as available. Typically, this will be the root path of
121 | | your application but you are free to change this when necessary.
122 | |
123 | */
124 |
125 | 'path' => '/',
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Session Cookie Domain
130 | |--------------------------------------------------------------------------
131 | |
132 | | Here you may change the domain of the cookie used to identify a session
133 | | in your application. This will determine which domains the cookie is
134 | | available to in your application. A sensible default has been set.
135 | |
136 | */
137 |
138 | 'domain' => env('SESSION_DOMAIN', null),
139 |
140 | /*
141 | |--------------------------------------------------------------------------
142 | | HTTPS Only Cookies
143 | |--------------------------------------------------------------------------
144 | |
145 | | By setting this option to true, session cookies will only be sent back
146 | | to the server if the browser has a HTTPS connection. This will keep
147 | | the cookie from being sent to you if it can not be done securely.
148 | |
149 | */
150 |
151 | 'secure' => false,
152 |
153 | /*
154 | |--------------------------------------------------------------------------
155 | | HTTP Access Only
156 | |--------------------------------------------------------------------------
157 | |
158 | | Setting this value to true will prevent JavaScript from accessing the
159 | | value of the cookie and the cookie will only be accessible through
160 | | the HTTP protocol. You are free to modify this option if needed.
161 | |
162 | */
163 |
164 | 'http_only' => true,
165 |
166 | ];
167 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | realpath(base_path('resources/views')),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => realpath(storage_path('framework/views')),
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/database/factories/ModelFactory.php:
--------------------------------------------------------------------------------
1 | define(App\User::class, function (Faker\Generator $faker) {
15 | return [
16 | 'name' => $faker->name,
17 | 'email' => $faker->safeEmail,
18 | 'password' => bcrypt(str_random(10)),
19 | 'remember_token' => str_random(10),
20 | 'api_token' => bin2hex(openssl_random_pseudo_bytes(16)),
21 | 'email_notifications' => false, //$faker->boolean
22 | 'preferred_currency' => $faker->randomElement(['hrk', 'usd', 'eur'])
23 | ];
24 | });
25 |
26 | $factory->define(App\Category::class, function (Faker\Generator $faker) {
27 | return [
28 | 'name' => $faker->randomElement(['Hosting', 'Maintenance', 'Domain', 'SSL Certificate']),
29 | ];
30 | });
31 |
32 | $factory->define(App\Client::class, function (Faker\Generator $faker) {
33 | return [
34 | 'name' => $faker->name,
35 | 'tax_number' => $faker->randomNumber,
36 | 'street' => $faker->streetAddress,
37 | 'city' => $faker->city,
38 | 'postal_code' => $faker->postcode
39 | ];
40 | });
41 |
42 | $factory->define(App\Service::class, function (Faker\Generator $faker) {
43 | return [
44 | 'title' => $faker->sentence(3),
45 | 'note' => $faker->text(200),
46 | 'month' => (int) $faker->month,
47 | 'day' => (int) $faker->dayOfMonth,
48 | 'cost' => $faker->randomNumber(5),
49 | 'currency' => $faker->randomElement(['hrk', 'eur', 'usd']),
50 | 'active' => $faker->boolean,
51 | 'exchange_rate' => $faker->randomFloat(4, 1, 11),
52 | 'client_id' => factory(App\Client::class)->create()->id,
53 | 'category_id' => factory(App\Category::class)->create()->id,
54 | ];
55 | });
56 |
57 | $factory->define(App\Occurrence::class, function (Faker\Generator $faker) {
58 | return [
59 | 'occurs_at' => $faker->dateTimeThisYear,
60 | 'offer_sent' => $faker->boolean,
61 | 'payment_received' => $faker->boolean,
62 | 'receipt_sent' => $faker->boolean,
63 | 'service_id' => factory(App\Service::class)->create()->id
64 | ];
65 | });
66 |
--------------------------------------------------------------------------------
/database/migrations/.gitkeep:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
17 | $table->string('name');
18 | $table->string('email')->unique();
19 | $table->string('api_token', 60)->unique();
20 | $table->string('password');
21 | $table->rememberToken();
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::drop('users');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
17 | $table->string('token')->index();
18 | $table->timestamp('created_at')->nullable();
19 | });
20 | }
21 |
22 | /**
23 | * Reverse the migrations.
24 | *
25 | * @return void
26 | */
27 | public function down()
28 | {
29 | Schema::drop('password_resets');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/database/migrations/2016_07_14_092017_create_clients_table.php:
--------------------------------------------------------------------------------
1 | string('name');
17 | $table->string('tax_number')->unique();
18 | $table->string('street')->nullable();
19 | $table->string('city')->nullable();
20 | $table->string('postal_code')->nullable();
21 | $table->increments('id');
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::drop('clients');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/database/migrations/2016_07_14_092024_create_services_table.php:
--------------------------------------------------------------------------------
1 | string('title');
17 | $table->text('note')->nullable();
18 | $table->integer('month')->unsigned();
19 | $table->integer('day')->unsigned();
20 | $table->integer('cost')->unsigned();
21 | $table->string('currency'); // HRK, USD, EUR
22 | $table->double('exchange_rate')->default(1); // Default to USD currency
23 | $table->boolean('active');
24 | $table->integer('client_id')->unsigned();
25 | $table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
26 | $table->increments('id');
27 | $table->timestamps();
28 | });
29 | }
30 |
31 | /**
32 | * Reverse the migrations.
33 | *
34 | * @return void
35 | */
36 | public function down()
37 | {
38 | Schema::drop('services');
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/database/migrations/2016_07_14_125816_create_occurrences_table.php:
--------------------------------------------------------------------------------
1 | timestamp('occurs_at');
17 | $table->boolean('offer_sent')->nullable();
18 | $table->boolean('payment_received')->nullable();
19 | $table->boolean('receipt_sent')->nullable();
20 | $table->integer('service_id')->unsigned();
21 | $table->foreign('service_id')->references('id')->on('services')->onDelete('cascade');
22 | $table->increments('id');
23 | $table->timestamps();
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::drop('occurrences');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/migrations/2016_07_16_212605_create_categories_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
17 | $table->string('name');
18 | $table->timestamps();
19 | });
20 |
21 | Schema::table('services', function(Blueprint $table) {
22 | $table->integer('category_id')->unsigned()->nullable();
23 | $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::table('services', function(Blueprint $table) {
35 | $table->dropForeign(['category_id']);
36 | $table->dropColumn('category_id');
37 | });
38 |
39 | Schema::drop('categories');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/database/migrations/2016_07_17_085858_add_preferred_currency_and_email_notifications_to_users_table.php:
--------------------------------------------------------------------------------
1 | string('preferred_currency')->default('usd');
17 | $table->boolean('email_notifications')->default(true);
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | *
24 | * @return void
25 | */
26 | public function down()
27 | {
28 | Schema::table('users', function (Blueprint $table) {
29 | $table->dropColumn('preferred_currency');
30 | $table->dropColumn('email_notifications');
31 | });
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2016_07_17_095203_create_cache_table.php:
--------------------------------------------------------------------------------
1 | string('key')->unique();
17 | $table->text('value');
18 | $table->integer('expiration');
19 | });
20 | }
21 |
22 | /**
23 | * Reverse the migrations.
24 | *
25 | * @return void
26 | */
27 | public function down()
28 | {
29 | Schema::drop('cache');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/database/migrations/2016_07_18_123554_drop_unique_index_for_tax_number_from_clients_table.php:
--------------------------------------------------------------------------------
1 | dropUnique(['tax_number']);
17 | $table->string('tax_number')->nullable()->change();
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | *
24 | * @return void
25 | */
26 | public function down()
27 | {
28 | Schema::table('clients', function (Blueprint $table) {
29 | // $table->unique('tax_number'); // can cause problems when refreshing db.
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2016_07_31_180730_fix_occurrences_occurs_at_column_by_dropping_table.php:
--------------------------------------------------------------------------------
1 | dateTime('occurs_at');
19 | $table->boolean('offer_sent')->nullable();
20 | $table->boolean('payment_received')->nullable();
21 | $table->boolean('receipt_sent')->nullable();
22 | $table->integer('service_id')->unsigned();
23 | $table->foreign('service_id')->references('id')->on('services')->onDelete('cascade');
24 | $table->increments('id');
25 | $table->timestamps();
26 | });
27 | }
28 |
29 | /**
30 | * Reverse the migrations.
31 | *
32 | * @return void
33 | */
34 | public function down()
35 | {
36 | Schema::drop('occurrences');
37 |
38 | Schema::create('occurrences', function (Blueprint $table) {
39 | $table->timestamp('occurs_at');
40 | $table->boolean('offer_sent')->nullable();
41 | $table->boolean('payment_received')->nullable();
42 | $table->boolean('receipt_sent')->nullable();
43 | $table->integer('service_id')->unsigned();
44 | $table->foreign('service_id')->references('id')->on('services')->onDelete('cascade');
45 | $table->increments('id');
46 | $table->timestamps();
47 | });
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/database/seeds/.gitkeep:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(SampleDataSeeder::class);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/database/seeds/SampleDataSeeder.php:
--------------------------------------------------------------------------------
1 | create([
36 | 'name' => $category
37 | ]);
38 | }, $categories);
39 |
40 | $clients = factory(App\Client::class, 10)->create();
41 |
42 | foreach($clients as $client) {
43 | $services = factory(App\Service::class, 10)->create([
44 | 'client_id' => $client->id,
45 | 'category_id' => rand(1, count($categories))
46 | ]);
47 | }
48 |
49 | /**
50 | * Sample User for testing purposes:
51 | *
52 | * email: sample.user@email.com
53 | * password: password
54 | *
55 | */
56 | factory(App\User::class)->create([
57 | 'name' => 'Sample User',
58 | 'email' => 'sample@user.dev',
59 | 'password' => bcrypt('password'),
60 | 'preferred_currency' => 'usd'
61 | ]);
62 |
63 | /**
64 | * Cleanup
65 | *
66 | * Because there is a long standing bug in Laravel
67 | * with model factories, I need to manually remove extra
68 | * records created.
69 | */
70 | App\Category::has('services', '=', 0)->delete();
71 | App\Client::has('services', '=', 0)->delete();
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var elixir = require('laravel-elixir');
2 |
3 | /*
4 | |--------------------------------------------------------------------------
5 | | Elixir Asset Management
6 | |--------------------------------------------------------------------------
7 | |
8 | | Elixir provides a clean, fluent API for defining some basic Gulp tasks
9 | | for your Laravel application. By default, we are compiling the Sass
10 | | file for our application, as well as publishing vendor resources.
11 | |
12 | */
13 |
14 | elixir(function(mix) {
15 | mix
16 | .copy('node_modules/bootstrap-less/fonts', 'public/build/fonts')
17 | .copy('node_modules/font-awesome/fonts', 'public/build/fonts')
18 | .less('app.less')
19 | .browserify('app.js')
20 | .version(['css/app.css', 'js/app.js']);
21 | });
22 |
--------------------------------------------------------------------------------
/license.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016-2017 Mario Bašić
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/laravelista/kyle/ad08e66ed34218f03a776d211dadff94072a16cd/overview.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "prod": "gulp --production",
5 | "dev": "gulp watch"
6 | },
7 | "devDependencies": {
8 | "gulp": "^3.9.1",
9 | "laravel-elixir": "^5.0.0",
10 | "bootbox": "^4.4.0",
11 | "bootstrap": "^3.3.6",
12 | "bootstrap-less": "^3.3.8",
13 | "font-awesome": "^4.6.3",
14 | "jquery": "^3.1.0",
15 | "selectize": "^0.12.2"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 | Add Category 20 |
21 |Name | 26 |Services | 27 |28 | |
---|---|---|
{{ $category->name }} | 33 |{{ $category->services->count() }} | 34 |35 | {{ Form::open(['route' => ['categories.destroy', $category->id], 'method' => 'DELETE', 'class' => 'confirm']) }} 36 | 37 | Edit 38 | 39 | 42 | {{ Form::close() }} 43 | | 44 |
19 | Add Client 20 |
21 |Name | 26 |Tax Number | 27 |Street | 28 |City | 29 |Postal Code | 30 |31 | |
---|---|---|---|---|---|
{{ $client->name }} | 36 |{{ $client->tax_number }} | 37 |{{ $client->street }} | 38 |{{ $client->city }} | 39 |{{ $client->postal_code }} | 40 |41 | {{ Form::open(['route' => ['clients.destroy', $client->id], 'method' => 'DELETE', 'class' => 'confirm']) }} 42 | 43 | Edit 44 | 45 | 48 | {{ Form::close() }} 49 | | 50 |
Date | 16 |Service | 17 |Client | 18 |Category | 19 |Cost | 20 |Offer sent | 21 |Payment received | 22 |Receipt sent | 23 |
---|---|---|---|---|---|---|---|
{{ $occurrence->occurs_at->format('d.m.Y') }} | 27 |{{ $occurrence->service->title }} | 28 |{{ $occurrence->service->client->name }} | 29 |{{ $occurrence->service->category->name or 'n/a' }} | 30 |{{ $occurrence->service->formatted_cost }} | 31 |34 | {{ $occurrence->offer_sent }} 35 | | 36 |39 | {{ $occurrence->payment_received }} 40 | | 41 |44 | {{ $occurrence->receipt_sent }} 45 | | 46 |
1 = January, 2 = February...
50 |1, 2, 3...
56 |Eg. 1050,00
62 |If the currency is USD leave this blank or set to "1".
76 |1 = January, 2 = February...
50 |1, 2, 3...
56 |Eg. 1050,00
62 |If the currency is USD leave this blank or set to "1".
76 |20 | Add Service 21 |
22 |Repeats on | 39 |Title | 40 |Client | 41 |Category | 42 |Active | 43 |Cost | 44 |45 | |
---|---|---|---|---|---|---|
{{ $service->day }}.{{ $service->month }} | 50 |{{ $service->title }} | 51 |{{ $service->client->name }} | 52 |{{ $service->category->name or 'n/a' }} | 53 |54 | @if($service->active) 55 | 56 | @else 57 | 58 | @endif 59 | | 60 |{{ $service->formatted_cost }} | 61 |62 | {{ Form::open(['route' => ['services.destroy', $service->id], 'method' => 'DELETE', 'class' => 'confirm']) }} 63 | 64 | Edit 65 | 66 | 69 | {{ Form::close() }} 70 | | 71 |