Skip to content

Commit

Permalink
Merge pull request #33 from jobapis/removing-premium
Browse files Browse the repository at this point in the history
Removing premium tier for v.1 release
  • Loading branch information
karllhughes authored Dec 31, 2016
2 parents 5b4da18 + 5da6c8c commit 54c8891
Show file tree
Hide file tree
Showing 41 changed files with 92 additions and 640 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ APP_DEBUG=true
APP_URL=http://localhost/
ADMIN_EMAIL=
ADMIN_NAME=
MAX_SEARCHES=
TIMEZONE=

## Database config
Expand Down
5 changes: 1 addition & 4 deletions app/Console/Commands/EmailJobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
use JobApis\JobsToMail\Jobs\CollectJobsForUser;
use JobApis\JobsToMail\Jobs\SearchAndNotifyUser;
use JobApis\JobsToMail\Jobs\Collections\SearchAndNotifyUser;
use JobApis\JobsToMail\Repositories\Contracts\SearchRepositoryInterface;
use JobApis\JobsToMail\Repositories\SearchRepository;
use JobApis\JobsToMail\Repositories\UserRepository;

class EmailJobs extends Command
{
Expand Down
12 changes: 0 additions & 12 deletions app/Http/Controllers/ApiController.php

This file was deleted.

2 changes: 0 additions & 2 deletions app/Http/Controllers/CollectionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public function download(Request $request, $id)
{
$path = $this->dispatchNow(new GenerateCsv($id));

// sleep(2);

return response()->download($path, null, ['Content-Type: text/csv']);
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/SearchesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Support\Facades\URL;
use JobApis\JobsToMail\Jobs\DeleteSearch;
use JobApis\JobsToMail\Jobs\GetUserSearches;
use JobApis\JobsToMail\Jobs\Searches\Delete;
use JobApis\JobsToMail\Jobs\Searches\GetUserSearches;

class SearchesController extends BaseController
{
Expand Down Expand Up @@ -38,7 +38,7 @@ public function index(Request $request, $userId = null)
*/
public function unsubscribe(Request $request, $searchId)
{
$message = $this->dispatchNow(new DeleteSearch($searchId));
$message = $this->dispatchNow(new Delete($searchId));

$request->session()->flash($message->type, $message->message);

Expand Down
30 changes: 3 additions & 27 deletions app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use JobApis\JobsToMail\Http\Requests\CreateUser;
use JobApis\JobsToMail\Http\Requests\PremiumUser;
use JobApis\JobsToMail\Jobs\CreateUserAndSearch;
use JobApis\JobsToMail\Jobs\DeleteUser;
use JobApis\JobsToMail\Jobs\Users\PremiumUserSignup;
use JobApis\JobsToMail\Jobs\Users\CreateUserAndSearch;
use JobApis\JobsToMail\Jobs\Users\Delete;

class UsersController extends BaseController
{
Expand All @@ -33,32 +31,10 @@ public function create(CreateUser $request)
*/
public function delete(Request $request, $userId)
{
$message = $this->dispatchNow(new DeleteUser($userId));
$message = $this->dispatchNow(new Delete($userId));

$request->session()->flash($message->type, $message->message);

return redirect('/');
}

/**
* Show premium signup form
*/
public function premium()
{
return view('users.premium');
}

/**
* Post premium signup form
*/
public function postPremium(PremiumUser $request)
{
$data = $request->only(array_keys($request->rules()));

$message = $this->dispatchNow(new PremiumUserSignup($data));

$request->session()->flash($message->type, $message->message);

return redirect('/premium');
}
}
4 changes: 1 addition & 3 deletions app/Http/Requests/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public function messages()
return [
'regex' =>'The location should be formatted
"City, ST". Currently only works for US locations.',
'premium' =>'Only premium users can use this feature.
Contact upgrade@jobstomail.com to get access.',
];
}

Expand All @@ -40,7 +38,7 @@ public function rules()
'email' => 'required|email',
'keyword' => 'required',
'location' => 'required|regex:/([^,]+), \s*(\w{2})/',
'no_recruiters' => 'required|premium',
'no_recruiters' => 'required',
];
}
}
41 changes: 0 additions & 41 deletions app/Http/Requests/PremiumUser.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace JobApis\JobsToMail\Jobs;
<?php namespace JobApis\JobsToMail\Jobs\Collections;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
Expand Down
4 changes: 2 additions & 2 deletions app/Jobs/DeleteSearch.php → app/Jobs/Searches/Delete.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php namespace JobApis\JobsToMail\Jobs;
<?php namespace JobApis\JobsToMail\Jobs\Searches;

use JobApis\JobsToMail\Http\Messages\FlashMessage;
use JobApis\JobsToMail\Repositories\Contracts\SearchRepositoryInterface;

class DeleteSearch
class Delete
{
/**
* @var string $searchId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace JobApis\JobsToMail\Jobs;
<?php namespace JobApis\JobsToMail\Jobs\Searches;

use JobApis\JobsToMail\Repositories\Contracts\SearchRepositoryInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace JobApis\JobsToMail\Jobs;
<?php namespace JobApis\JobsToMail\Jobs\Users;

use Illuminate\Support\Facades\Log;
use JobApis\JobsToMail\Http\Messages\FlashMessage;
Expand Down Expand Up @@ -36,15 +36,15 @@ public function handle(
$user = $users->firstOrCreate($this->data);

// Make sure the user isn't over their maximum
$maxSearches = config('app.user_tier_permissions.'.$user->tier.'.max_search_count');
$maxSearches = config('app.max_searches');
$adminEmail = env('ADMIN_EMAIL');

if ($user->existed === true && $user->searches()->count() >= $maxSearches) {
return new FlashMessage(
'alert-danger',
"You have reached your maximum number of job searches. As a
{$user->tier} user you can create {$maxSearches} searches.
Unsubscribe from a search or contact upgrade@jobstomail.com
to upgrade your account."
"You have reached your maximum number of {$maxSearches}
job searches. Unsubscribe from a search or contact
{$adminEmail} to upgrade your account."
);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Jobs/DeleteUser.php → app/Jobs/Users/Delete.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php namespace JobApis\JobsToMail\Jobs;
<?php namespace JobApis\JobsToMail\Jobs\Users;

use JobApis\JobsToMail\Http\Messages\FlashMessage;
use JobApis\JobsToMail\Repositories\Contracts\UserRepositoryInterface;

class DeleteUser
class Delete
{
/**
* @var string $userId
Expand Down
44 changes: 0 additions & 44 deletions app/Jobs/Users/PremiumUserSignup.php

This file was deleted.

10 changes: 0 additions & 10 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ protected static function boot()
});
}

/**
* Checks whether the user is premium
*
* @return boolean
*/
public function isPremium()
{
return $this->tier == config('app.user_tiers.premium');
}

/**
* Defines the relationship to Search model
*
Expand Down
10 changes: 4 additions & 6 deletions app/Notifications/JobsCollected.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ public function toMail($notifiable)
}

// Add a link to download the collection
if ($notifiable->isPremium()) {
$message->action(
'Download CSV',
url('/collections/' . $this->id . '/download')
);
}
$message->action(
'Download CSV',
url('/collections/' . $this->id . '/download')
);

return $message;
}
Expand Down
55 changes: 0 additions & 55 deletions app/Notifications/PremiumUserSignup.php

This file was deleted.

8 changes: 1 addition & 7 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
// Only premium users can set this value to true
Validator::extend('premium', function ($attribute, $value, $parameters, $validator) {
if ($value == 1) {
return config('app.user_tiers.premium') === session()->get('user.tier');
}
return true;
});
//
}

/**
Expand Down
Loading

0 comments on commit 54c8891

Please sign in to comment.