-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from andela-sachungo/develop
testing
- Loading branch information
Showing
95 changed files
with
6,006 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
APP_ENV=local | ||
APP_DEBUG=true | ||
APP_KEY=SomeRandomString | ||
|
||
DB_HOST=localhost | ||
DB_DATABASE=homestead | ||
DB_USERNAME=homestead | ||
DB_PASSWORD=secret | ||
|
||
CACHE_DRIVER=file | ||
SESSION_DRIVER=file | ||
QUEUE_DRIVER=sync | ||
|
||
REDIS_HOST=localhost | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_DRIVER=smtp | ||
MAIL_HOST=mailtrap.io | ||
MAIL_PORT=2525 | ||
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* text=auto | ||
*.css linguist-vendored | ||
*.less linguist-vendored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/vendor | ||
/node_modules | ||
Homestead.yaml | ||
Homestead.json | ||
.env | ||
*.log | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
preset: laravel | ||
|
||
linting: true | ||
|
||
finder: | ||
exclude: | ||
- "tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: vendor/bin/heroku-php-apache2 public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Soma; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Categories extends Model | ||
{ | ||
/** | ||
* The database table used by the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'categories'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'user_id', | ||
'title', | ||
]; | ||
|
||
/** | ||
* A category belongs to a user. | ||
* | ||
* @return Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function user() | ||
{ | ||
return $this->belongsTo('Soma\User'); | ||
} | ||
|
||
/** | ||
* A category has many videos. | ||
* | ||
* @return Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function videos() | ||
{ | ||
return $this->hasMany('Soma\Videos', 'category_id'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
namespace Soma\Events; | ||
|
||
abstract class Event | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Soma\Http\Controllers\Auth; | ||
|
||
use Auth; | ||
use Socialite; | ||
use Soma\User; | ||
use Soma\Http\Controllers\Controller; | ||
|
||
class SocialAuthController extends Controller | ||
{ | ||
/** | ||
* Redirect the user to the provider authentication page. | ||
* | ||
* @return Response | ||
*/ | ||
public function redirectToProvider($provider) | ||
{ | ||
return Socialite::driver($provider)->redirect(); | ||
} | ||
|
||
/** | ||
* Obtain the user information from the provider. | ||
* | ||
* Specify true as the second parameter to "Auth::login()" | ||
* " to set the "remember me" cookie. | ||
* | ||
* @return Response | ||
*/ | ||
public function handleProviderCallback($provider) | ||
{ | ||
try { | ||
$user = Socialite::driver($provider)->user(); | ||
} catch (\Exception $e) { | ||
return redirect()->route('register'); | ||
} | ||
|
||
$authUser = $this->findOrCreateUser($user); | ||
Auth::login($authUser, true); | ||
|
||
return redirect()->route('dashboard'); | ||
} | ||
|
||
/** | ||
* Return user if exists; create and return if doesn't. | ||
* | ||
* @param $socialUser | ||
* @return User | ||
*/ | ||
private function findOrCreateUser($socialUser) | ||
{ | ||
if ($authUser = User::where('email', $socialUser->getEmail())->first()) { | ||
return $authUser; | ||
} | ||
|
||
return User::create([ | ||
'name' => $socialUser->getName(), | ||
'email' => $socialUser->getEmail(), | ||
'provider_id' => $socialUser->getAvatar(), | ||
'avatar' => $socialUser->getAvatar(), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
|
||
namespace Soma\Http\Controllers; | ||
|
||
use Soma\User; | ||
use Soma\Categories; | ||
use Soma\Http\Requests\CategoriesRequest; | ||
|
||
class CategoryController extends Controller | ||
{ | ||
/** | ||
* A constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('auth', [ | ||
'except' => [ | ||
'getVideosByCategory', | ||
], | ||
]); | ||
} | ||
|
||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
/*public function index() | ||
{ | ||
$categories = Categories::all(); | ||
return view('categories.index')->with('categories', $categories); | ||
}*/ | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function create() | ||
{ | ||
return view('categories.create'); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function store(CategoriesRequest $request) | ||
{ | ||
$user = User::authorizedUser($request->email)->first(); | ||
$user->categories()->create([ | ||
'title' => $request->title, | ||
]); | ||
|
||
// FLASH MESSAGE | ||
|
||
return redirect()->back(); | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function edit($id) | ||
{ | ||
$category = Categories::find($id); | ||
|
||
return view('categories.edit')->with('category', $category); | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(CategoriesRequest $request, $id) | ||
{ | ||
$category = Categories::find($id); | ||
$category->update([ | ||
'title' => $request->title, | ||
]); | ||
|
||
// FLASH MESSAGE | ||
return redirect()->route('own.categories'); | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy($id) | ||
{ | ||
$category = Categories::find($id); | ||
if ($category) { | ||
Categories::destroy($id); | ||
|
||
return redirect()->back(); | ||
} | ||
|
||
// REDIRECT WITH MESSAGE CATEGORY NOT FOUND | ||
return redirect()->route('dashboard'); | ||
} | ||
|
||
/** | ||
* Get the categories of a particular user. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function getCategories() | ||
{ | ||
$categories = Categories::where('user_id', auth()->user()->id)->get(); | ||
|
||
return view('categories.own')->with('categories', $categories); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.