Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions app/Helpers/MediaHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* @copyright Copyright (c) 2018. MckenzieArts
* @author Mckenziearts <contact@mckenziearts.design>
* @link https://www.camer-freelancer.com
* @since 7.1
* @version 1.0
* @package CF/Helpers
*/

namespace App\Helpers;

use Intervention\Image\Facades\Image;

class MediaHelper
{
/**
* @protected
*
* @var string $dir, the file uploaded path
*/
protected static $dir = 'app/public';

/**
* @return string
*/
public static function getUploadsFolder()
{
return self::$dir;
}

/**
* @return string
*/
public static function getStoragePath()
{
return storage_path(self::$dir);
}

/**
* Return the size of an image
*
* @param string $file
* @param string $folder
* @return array $width and $height of the file give in parameter
*/
public static function getFileSizes(string $file, string $folder = null)
{
if ($folder) {
list($width, $height, $type, $attr) = getimagesize(storage_path(self::$dir.'/'. $folder .'/'. date('FY') .'/'.$file));
}
list($width, $height, $type, $attr) = getimagesize(storage_path(self::$dir.'/'. date('FY') .'/'.$file));

return [
'width' => $width,
'height' => $height
];
}

/**
* resize, To rezise and image
*
* @param string $file, l'image à redimmensionner
* @param int $width, la largeur à laquelle on doit redimensionner l'image
* @param int $height, la hateur à laquelle on doit redimensionner l'image
* @param string $filepath, le chemin ou est garder le fichier redimensionner
*/
public static function resize($file, $width, $height, $filepath)
{
Image::make($file)->resize($width, $height)->save($filepath);
}

/**
* getImageWeight, permet de retourner le poids d'une image
*
* @param $octets
* @return string
*/
public static function getImageWeight($octets) {
$resultat = $octets;
for ($i = 0; $i < 8 && $resultat >= 1024; $i++) {
$resultat = $resultat / 1024;
}
if ($i > 0) {
return preg_replace('/,00$/', '', number_format($resultat, 2, ',', ''))
. ' ' . substr('KMGTPEZY', $i-1, 1) . 'o';
} else {
return $resultat . ' o';
}
}
}
11 changes: 11 additions & 0 deletions app/Http/Controllers/Admin/ChatterCategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use TCG\Voyager\Http\Controllers\VoyagerBaseController as BaseVoyagerBaseController;

class ChatterCategoryController extends BaseVoyagerBaseController
{
//
}
11 changes: 11 additions & 0 deletions app/Http/Controllers/Admin/ChatterDiscussionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ChatterDiscussionController extends Controller
{
//
}
3 changes: 2 additions & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Carbon;
use Socialite;
use Illuminate\Support\Facades\Auth;

Expand Down Expand Up @@ -72,7 +73,7 @@ public function handleProviderCallback($provider)
}

$user = User::where($provider.'_id', '=', $providerUser->getId())
->Where('email', '=', $providerUser->getEmail())
->orWhere('email', '=', $providerUser->getEmail())
->first();

if (is_null($user)) {
Expand Down
58 changes: 58 additions & 0 deletions app/Http/Controllers/SlackInvitationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Http\Controllers;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Http\Request;

class SlackInvitationController extends Controller
{
/**
* @var \GuzzleHttp\Client
*/
protected $client;

/**
* Slack Team name
*
* @var string
*/
protected $team;

/**
* SlackInvitationController constructor.
*/
public function __construct()
{
$this->client = new Client();
$this->team = env('SLACK_TEAM_NAME', 'Laravel Cameroon');
}

/**
* Slack Invitation
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function sendInvitation(Request $request)
{
$rules = ['email' => 'required|string|email'];
$validator = validator($request->all(), $rules);
$email = $request->input('email');

if ($validator->fails()) {
return redirect(route('slack.result'))->with('error', 'You must enter your email to proceed.');
} else {
try {
$this->client->request('POST',
env('SLACK_TEAM_URL').'/api/users.admin.invite?t='
.time().'&email='.$email.'&token='.env('SLACK_API_TOKEN')
.'&set_active=true&_attempts=1');
return redirect(route('slack.result'))->with('success', "An invitation to your mail to join {$this->team} workspace.");
} catch (GuzzleException $e) {
return redirect(route('slack.result'))->with('error', 'An error occured while sending invitation, please try again.');
}
}
}
}
62 changes: 60 additions & 2 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@

namespace App\Http\Controllers;

use App\Repositories\UserRepository;
use Illuminate\Http\Request;

class UserController extends Controller
{
public function __construct()
/**
* @var UserRepository
*/
private $repository;

/**
* UserController constructor.
*
* @param UserRepository $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}

/**
Expand All @@ -20,13 +32,59 @@ public function account()
return view('frontend.users.account');
}

/**
* Update User account
*
* @param Request $request
* @param int $id
* @return \Illuminate\Http\RedirectResponse
*/
public function updateAccount(Request $request, int $id)
{
$request->validate($this->rules());

$this->repository->update($request->except(['_token', '_method']), $id);

return redirect(route('users.account'))->with('success', __("Votre profil a été mis à jour avec succès !"));
}

/**
* User update password
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function updatePassword()
public function password()
{
return view('frontend.users.password');
}

/**
* User password Update
*
* @param Request $request
* @param int $id
* @return \Illuminate\Http\RedirectResponse
*/
public function updatePassword(Request $request, int $id)
{
$request->validate(['password' => 'required|confirmed|min:6']);

$this->repository->passwordUpdate($request->except(['_token', '_method']), $id);

return redirect(route('users.password'))->with('success', __("Votre mot de passe a été mis à jour avec succès !"));
}

/**
* Validation Rules
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'email' => 'required',
'avatar' => 'image|mimes:jpeg,png,jpg',
];
}
}
10 changes: 10 additions & 0 deletions app/Models/ChatterCategory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ChatterCategory extends Model
{
//
}
52 changes: 52 additions & 0 deletions app/Observers/PackageObserver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace App\Observers;

use App\Models\Package;

class PackageObserver
{
/**
* Handle to the package "creating" event.
*
* @param Package $package
* @return void
*/
public function creating(Package $package)
{
$package->user_id = auth()->user()->id;
}

/**
* Handle to the package "created" event.
*
* @param \App\Models\Package $package
* @return void
*/
public function created(Package $package)
{
//
}

/**
* Handle the package "updated" event.
*
* @param \App\Models\Package $package
* @return void
*/
public function updated(Package $package)
{
//
}

/**
* Handle the package "deleted" event.
*
* @param \App\Models\Package $package
* @return void
*/
public function deleted(Package $package)
{
//
}
}
52 changes: 52 additions & 0 deletions app/Observers/TutorialObserver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace App\Observers;

use App\Models\Tutorial;

class TutorialObserver
{
/**
* Handle to the tutorial "creating" event.
*
* @param \App\Models\Tutorial $tutorial
* @return void
*/
public function creating(Tutorial $tutorial)
{
$tutorial->user_id = auth()->user()->id;
}

/**
* Handle to the tutorial "created" event.
*
* @param \App\Models\Tutorial $tutorial
* @return void
*/
public function created(Tutorial $tutorial)
{
//
}

/**
* Handle the tutorial "updated" event.
*
* @param \App\Models\Tutorial $tutorial
* @return void
*/
public function updated(Tutorial $tutorial)
{
//
}

/**
* Handle the tutorial "deleted" event.
*
* @param \App\Models\Tutorial $tutorial
* @return void
*/
public function deleted(Tutorial $tutorial)
{
//
}
}
Loading