Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit 5bf51dc

Browse files
authored
Merge pull request #1 from laravelcm/dev
Dev
2 parents d50b5c6 + 1aa3942 commit 5bf51dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+939
-261
lines changed

app/Helpers/MediaHelper.php

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2018. MckenzieArts
4+
* @author Mckenziearts <[email protected]>
5+
* @link https://www.camer-freelancer.com
6+
* @since 7.1
7+
* @version 1.0
8+
* @package CF/Helpers
9+
*/
10+
11+
namespace App\Helpers;
12+
13+
use Intervention\Image\Facades\Image;
14+
15+
class MediaHelper
16+
{
17+
/**
18+
* @protected
19+
*
20+
* @var string $dir, the file uploaded path
21+
*/
22+
protected static $dir = 'app/public';
23+
24+
/**
25+
* @return string
26+
*/
27+
public static function getUploadsFolder()
28+
{
29+
return self::$dir;
30+
}
31+
32+
/**
33+
* @return string
34+
*/
35+
public static function getStoragePath()
36+
{
37+
return storage_path(self::$dir);
38+
}
39+
40+
/**
41+
* Return the size of an image
42+
*
43+
* @param string $file
44+
* @param string $folder
45+
* @return array $width and $height of the file give in parameter
46+
*/
47+
public static function getFileSizes(string $file, string $folder = null)
48+
{
49+
if ($folder) {
50+
list($width, $height, $type, $attr) = getimagesize(storage_path(self::$dir.'/'. $folder .'/'. date('FY') .'/'.$file));
51+
}
52+
list($width, $height, $type, $attr) = getimagesize(storage_path(self::$dir.'/'. date('FY') .'/'.$file));
53+
54+
return [
55+
'width' => $width,
56+
'height' => $height
57+
];
58+
}
59+
60+
/**
61+
* resize, To rezise and image
62+
*
63+
* @param string $file, l'image à redimmensionner
64+
* @param int $width, la largeur à laquelle on doit redimensionner l'image
65+
* @param int $height, la hateur à laquelle on doit redimensionner l'image
66+
* @param string $filepath, le chemin ou est garder le fichier redimensionner
67+
*/
68+
public static function resize($file, $width, $height, $filepath)
69+
{
70+
Image::make($file)->resize($width, $height)->save($filepath);
71+
}
72+
73+
/**
74+
* getImageWeight, permet de retourner le poids d'une image
75+
*
76+
* @param $octets
77+
* @return string
78+
*/
79+
public static function getImageWeight($octets) {
80+
$resultat = $octets;
81+
for ($i = 0; $i < 8 && $resultat >= 1024; $i++) {
82+
$resultat = $resultat / 1024;
83+
}
84+
if ($i > 0) {
85+
return preg_replace('/,00$/', '', number_format($resultat, 2, ',', ''))
86+
. ' ' . substr('KMGTPEZY', $i-1, 1) . 'o';
87+
} else {
88+
return $resultat . ' o';
89+
}
90+
}
91+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Admin;
4+
5+
use Illuminate\Http\Request;
6+
use TCG\Voyager\Http\Controllers\VoyagerBaseController as BaseVoyagerBaseController;
7+
8+
class ChatterCategoryController extends BaseVoyagerBaseController
9+
{
10+
//
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Admin;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
8+
class ChatterDiscussionController extends Controller
9+
{
10+
//
11+
}

app/Http/Controllers/Auth/LoginController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Http\Controllers\Controller;
66
use App\User;
77
use Illuminate\Foundation\Auth\AuthenticatesUsers;
8+
use Illuminate\Support\Carbon;
89
use Socialite;
910
use Illuminate\Support\Facades\Auth;
1011

@@ -72,7 +73,7 @@ public function handleProviderCallback($provider)
7273
}
7374

7475
$user = User::where($provider.'_id', '=', $providerUser->getId())
75-
->Where('email', '=', $providerUser->getEmail())
76+
->orWhere('email', '=', $providerUser->getEmail())
7677
->first();
7778

7879
if (is_null($user)) {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use GuzzleHttp\Client;
6+
use GuzzleHttp\Exception\GuzzleException;
7+
use Illuminate\Http\Request;
8+
9+
class SlackInvitationController extends Controller
10+
{
11+
/**
12+
* @var \GuzzleHttp\Client
13+
*/
14+
protected $client;
15+
16+
/**
17+
* Slack Team name
18+
*
19+
* @var string
20+
*/
21+
protected $team;
22+
23+
/**
24+
* SlackInvitationController constructor.
25+
*/
26+
public function __construct()
27+
{
28+
$this->client = new Client();
29+
$this->team = env('SLACK_TEAM_NAME', 'Laravel Cameroon');
30+
}
31+
32+
/**
33+
* Slack Invitation
34+
*
35+
* @param Request $request
36+
* @return \Illuminate\Http\RedirectResponse
37+
*/
38+
public function sendInvitation(Request $request)
39+
{
40+
$rules = ['email' => 'required|string|email'];
41+
$validator = validator($request->all(), $rules);
42+
$email = $request->input('email');
43+
44+
if ($validator->fails()) {
45+
return redirect(route('slack.result'))->with('error', 'You must enter your email to proceed.');
46+
} else {
47+
try {
48+
$this->client->request('POST',
49+
env('SLACK_TEAM_URL').'/api/users.admin.invite?t='
50+
.time().'&email='.$email.'&token='.env('SLACK_API_TOKEN')
51+
.'&set_active=true&_attempts=1');
52+
return redirect(route('slack.result'))->with('success', "An invitation to your mail to join {$this->team} workspace.");
53+
} catch (GuzzleException $e) {
54+
return redirect(route('slack.result'))->with('error', 'An error occured while sending invitation, please try again.');
55+
}
56+
}
57+
}
58+
}

app/Http/Controllers/UserController.php

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22

33
namespace App\Http\Controllers;
44

5+
use App\Repositories\UserRepository;
56
use Illuminate\Http\Request;
67

78
class UserController extends Controller
89
{
9-
public function __construct()
10+
/**
11+
* @var UserRepository
12+
*/
13+
private $repository;
14+
15+
/**
16+
* UserController constructor.
17+
*
18+
* @param UserRepository $repository
19+
*/
20+
public function __construct(UserRepository $repository)
1021
{
22+
$this->repository = $repository;
1123
}
1224

1325
/**
@@ -20,13 +32,59 @@ public function account()
2032
return view('frontend.users.account');
2133
}
2234

35+
/**
36+
* Update User account
37+
*
38+
* @param Request $request
39+
* @param int $id
40+
* @return \Illuminate\Http\RedirectResponse
41+
*/
42+
public function updateAccount(Request $request, int $id)
43+
{
44+
$request->validate($this->rules());
45+
46+
$this->repository->update($request->except(['_token', '_method']), $id);
47+
48+
return redirect(route('users.account'))->with('success', __("Votre profil a été mis à jour avec succès !"));
49+
}
50+
2351
/**
2452
* User update password
2553
*
2654
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
2755
*/
28-
public function updatePassword()
56+
public function password()
2957
{
3058
return view('frontend.users.password');
3159
}
60+
61+
/**
62+
* User password Update
63+
*
64+
* @param Request $request
65+
* @param int $id
66+
* @return \Illuminate\Http\RedirectResponse
67+
*/
68+
public function updatePassword(Request $request, int $id)
69+
{
70+
$request->validate(['password' => 'required|confirmed|min:6']);
71+
72+
$this->repository->passwordUpdate($request->except(['_token', '_method']), $id);
73+
74+
return redirect(route('users.password'))->with('success', __("Votre mot de passe a été mis à jour avec succès !"));
75+
}
76+
77+
/**
78+
* Validation Rules
79+
*
80+
* @return array
81+
*/
82+
public function rules()
83+
{
84+
return [
85+
'name' => 'required',
86+
'email' => 'required',
87+
'avatar' => 'image|mimes:jpeg,png,jpg',
88+
];
89+
}
3290
}

app/Models/ChatterCategory.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class ChatterCategory extends Model
8+
{
9+
//
10+
}

app/Observers/PackageObserver.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace App\Observers;
4+
5+
use App\Models\Package;
6+
7+
class PackageObserver
8+
{
9+
/**
10+
* Handle to the package "creating" event.
11+
*
12+
* @param Package $package
13+
* @return void
14+
*/
15+
public function creating(Package $package)
16+
{
17+
$package->user_id = auth()->user()->id;
18+
}
19+
20+
/**
21+
* Handle to the package "created" event.
22+
*
23+
* @param \App\Models\Package $package
24+
* @return void
25+
*/
26+
public function created(Package $package)
27+
{
28+
//
29+
}
30+
31+
/**
32+
* Handle the package "updated" event.
33+
*
34+
* @param \App\Models\Package $package
35+
* @return void
36+
*/
37+
public function updated(Package $package)
38+
{
39+
//
40+
}
41+
42+
/**
43+
* Handle the package "deleted" event.
44+
*
45+
* @param \App\Models\Package $package
46+
* @return void
47+
*/
48+
public function deleted(Package $package)
49+
{
50+
//
51+
}
52+
}

app/Observers/TutorialObserver.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace App\Observers;
4+
5+
use App\Models\Tutorial;
6+
7+
class TutorialObserver
8+
{
9+
/**
10+
* Handle to the tutorial "creating" event.
11+
*
12+
* @param \App\Models\Tutorial $tutorial
13+
* @return void
14+
*/
15+
public function creating(Tutorial $tutorial)
16+
{
17+
$tutorial->user_id = auth()->user()->id;
18+
}
19+
20+
/**
21+
* Handle to the tutorial "created" event.
22+
*
23+
* @param \App\Models\Tutorial $tutorial
24+
* @return void
25+
*/
26+
public function created(Tutorial $tutorial)
27+
{
28+
//
29+
}
30+
31+
/**
32+
* Handle the tutorial "updated" event.
33+
*
34+
* @param \App\Models\Tutorial $tutorial
35+
* @return void
36+
*/
37+
public function updated(Tutorial $tutorial)
38+
{
39+
//
40+
}
41+
42+
/**
43+
* Handle the tutorial "deleted" event.
44+
*
45+
* @param \App\Models\Tutorial $tutorial
46+
* @return void
47+
*/
48+
public function deleted(Tutorial $tutorial)
49+
{
50+
//
51+
}
52+
}

0 commit comments

Comments
 (0)