public function setUp() { parent::setUp(); // init the $this->projects = $this->app->make($this->projectClass); // create a project for testing purposes $this->project = $this->projects->create(["name" => "testing", "human_name" => "Only a test Project"]); }
public function setUp() { parent::setUp(); $this->projects = $this->app->make($this->projectClass); $this->mailStatistics = $this->app->make($this->mailStatisticsClass); $this->categories = $this->app->make($this->categoryClass); $this->project = $this->projects->create(['name' => 'testing', 'human_name' => "Only for testing"]); }
/** * Determine the Project from a given Request * * @param Request $request * @return Project * @throws ProjectNotSupported */ private static function fetchProjectFromRequest(Request $request) { $project_name = self::fetchTagFromRequest($request); // retrieve the project from the request bag if it's available // load the project by its name $project = Project::where('name', $project_name)->first(); if ($project instanceof Model) { return $project; } throw new ProjectNotSupported("The project: {$project_name} could not be found in our records."); }
/** * Show a list of entries per project * * @param Project $project * @return \Illuminate\Http\Response */ public function indexPerProject(Project $project) { // @todo: add repo? $mailStatistics = $project->mailStatistics()->newestGrouped()->paginate($this->perPage); return view('mail-stats::mail-statistics.index-per-project', compact('project', 'mailStatistics')); }
<?php Route::bind('projectSlug', function ($projectSlug) { $project = \BitsOfLove\MailStats\Entities\Project::where('name', $projectSlug)->first(); if ($project instanceof \BitsOfLove\MailStats\Entities\Project) { return $project; } throw new \Illuminate\Database\Eloquent\ModelNotFoundException(); }); Route::group(['middleware' => ['web', 'auth']], function () { // for testing purposes only Route::get('mail-statistics/test-entry-point', "BitsOfLove\\MailStats\\Http\\Controllers\\MailStatisticsController@testEntryPoint"); Route::get("mail-statistics", "BitsOfLove\\MailStats\\Http\\Controllers\\MailStatisticsController@index"); Route::get("mail-statistics/{projectSlug}", ['as' => "mail-stats-per-project", 'uses' => "BitsOfLove\\MailStats\\Http\\Controllers\\MailStatisticsController@indexPerProject"]); Route::get("mail-statistics/{projectSlug}/charts", ['as' => "mail-stats-per-project-cart", 'uses' => "BitsOfLove\\MailStats\\Http\\Controllers\\MailStatisticsController@charts"]); Route::get("mail-statistics/{projectSlug}/{messageId}", ['as' => "mail-stats-per-message-id", 'uses' => "BitsOfLove\\MailStats\\Http\\Controllers\\MailStatisticsController@indexPerMessageId"]); Route::get('projects/{projects}/delete', ['as' => "projects.delete", 'uses' => "BitsOfLove\\MailStats\\Http\\Controllers\\ProjectsController@delete"]); Route::resource('projects', "BitsOfLove\\MailStats\\Http\\Controllers\\ProjectsController", ['except' => ['show']]); }); Route::group(['middleware' => ['api']], function () { // route to receive a response from mailgun Route::post('mail-statistics', "BitsOfLove\\MailStats\\Http\\Controllers\\MailsController@log"); // route to send an email Route::post('mail-send', "BitsOfLove\\MailStats\\Http\\Controllers\\MailsController@mail"); });