Compare commits
No commits in common. "master" and "e2e" have entirely different histories.
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Exceptions\WrongHourException;
|
||||
use App\Mail\DailyNotification;
|
||||
use App\Services\HourService;
|
||||
use App\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendDailyNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:daily';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send daily notification to write a post';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @param HourService $hour_service
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(HourService $hour_service)
|
||||
{
|
||||
try {
|
||||
$notification_id = $hour_service->getCurrentNotificationId();
|
||||
$this->info(sprintf('Notification id = %s', $notification_id));
|
||||
} catch (WrongHourException $e) {
|
||||
$this->error($e->getMessage());
|
||||
exit;
|
||||
}
|
||||
$users = User::where('notification_hour', '=', $notification_id)
|
||||
->where('email_verified_at', '!=', null)
|
||||
->whereNotExists(function($query) {
|
||||
$query->select()
|
||||
->from('posts')
|
||||
->whereRaw('posts.user_id = users.id')
|
||||
->whereDate('date_post', date('Y-m-d'));
|
||||
})
|
||||
->get();
|
||||
foreach ($users as $user) {
|
||||
Mail::to($user)->queue(new DailyNotification($user));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Console\Commands\SendDailyNotification;
|
||||
use App\Jobs\SendReminderEmail;
|
||||
use App\Jobs\SendWelcomeEmail;
|
||||
use App\User;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
|
@ -16,7 +17,7 @@ class Kernel extends ConsoleKernel
|
|||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
SendDailyNotification::class,
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -27,17 +28,17 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule
|
||||
->command('send:daily')
|
||||
->cron('0 */6 * * *');
|
||||
|
||||
$schedule->call(function() {
|
||||
$users = User::where('email_verified_at', '=', null)
|
||||
$users = User::where('email_verified_at', '!=', null)
|
||||
->where('notification_hour', '!=', null)
|
||||
->get();
|
||||
var_dump(count($users));
|
||||
foreach ($users as $user) {
|
||||
dispatch((new SendReminderEmail($user)));
|
||||
}
|
||||
})->daily();
|
||||
})->everyMinute();
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
|
||||
class WrongHourException extends \Exception
|
||||
{
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\AddPost;
|
||||
use App\Post;
|
||||
use App\PostsTag;
|
||||
use App\Services\ImageService;
|
||||
|
@ -12,9 +11,6 @@ use DateTime;
|
|||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\DiskDoesNotExist;
|
||||
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileDoesNotExist;
|
||||
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileIsTooBig;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
|
@ -48,11 +44,7 @@ class DashboardController extends Controller
|
|||
$image_counts = Post::where('user_id', Auth::user()->getAuthIdentifier())
|
||||
->where('image', '!=', 'null')
|
||||
->count();
|
||||
$posts = Post::where('user_id', $user_id)
|
||||
->when(request('search', false), static function ($post, $search) {
|
||||
return $post->where('content', 'like', '%'.$search.'%');
|
||||
})
|
||||
->orderBy('date_post', 'DESC')->paginate(9);
|
||||
$posts = Post::where('user_id', $user_id)->orderBy('date_post', 'DESC')->limit(9)->get();
|
||||
$today_post = Post::whereDate('date_post', '=', $today->format('Y-m-d'))
|
||||
->where('user_id', $user_id)
|
||||
->count();
|
||||
|
@ -76,34 +68,38 @@ class DashboardController extends Controller
|
|||
|
||||
/**
|
||||
* Edit today's entry
|
||||
* @param AddPost $request
|
||||
* @param TagDetectorService $tag_detector
|
||||
* @return
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function edit(AddPost $request, TagDetectorService $tag_detector)
|
||||
public function edit(TagDetectorService $tag_detector)
|
||||
{
|
||||
/** @var Post $today_post */
|
||||
$today_post = Post::whereDate('date_post', '=', (new DateTime())->format('Y-m-d'))
|
||||
->where('user_id', Auth::user()->getAuthIdentifier())
|
||||
->firstOrFail();
|
||||
|
||||
$data = $request->validated();
|
||||
|
||||
if (!empty($validated_data['file'])) {
|
||||
try {
|
||||
$today_post->addMediaFromRequest('file')->toMediaCollection('post_image');
|
||||
} catch (DiskDoesNotExist $e) {
|
||||
} catch (FileDoesNotExist $e) {
|
||||
} catch (FileIsTooBig $e) {
|
||||
}
|
||||
}
|
||||
$data = request()->validate([
|
||||
'message' => 'required'
|
||||
]);
|
||||
|
||||
$today_post->deleteTags();
|
||||
|
||||
$tags = $tag_detector->detectFrom($data['message']);
|
||||
|
||||
$today_post->content = $data['message'];
|
||||
$today_post->save();
|
||||
$all_tags = Tag::all();
|
||||
$all_tags_names = [];
|
||||
foreach ($all_tags as $tag) {
|
||||
$all_tags_names[$tag->id] = $tag->name;
|
||||
}
|
||||
|
||||
$this->setPostsTagsForPost($today_post, $tag_detector->detectFrom($data['message']));
|
||||
foreach ($tags as $tag) {
|
||||
if (in_array($tag, $all_tags_names)) {
|
||||
PostsTag::create([
|
||||
'post_id' => $today_post->id,
|
||||
'tag_id' => array_search($tag, $all_tags_names),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect::to('home')->withSuccess('Great! Form successfully submit with validation.');
|
||||
}
|
||||
|
@ -119,6 +115,7 @@ class DashboardController extends Controller
|
|||
->where('user_id', Auth::user()->getAuthIdentifier())
|
||||
->firstOrFail();
|
||||
/** @var Post $today_post */
|
||||
$today_post->deleteTags();
|
||||
$today_post->delete();
|
||||
return Redirect::to('home')->withSuccess('Great! Your today\'s post is now deleted. You can make a new one!');
|
||||
} catch (\ErrorException $e) {
|
||||
|
@ -127,42 +124,37 @@ class DashboardController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* @param AddPost $request
|
||||
* @param TagDetectorService $tag_detector
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function store(AddPost $request, TagDetectorService $tag_detector)
|
||||
public function store(TagDetectorService $tag_detector, ImageService $image_service)
|
||||
{
|
||||
$validated_data = $request->validated();
|
||||
$user_id = Auth::user()->getAuthIdentifier();
|
||||
|
||||
/** @var Post $post */
|
||||
$post = Post::create([
|
||||
'user_id' => Auth::user()->getAuthIdentifier(),
|
||||
'date_post' => new DateTime(),
|
||||
'content' => $validated_data['message'],
|
||||
$validated_data = request()->validate([
|
||||
'message' => 'required',
|
||||
'file' => 'file|mimes:jpeg,png,jpg,gif,svg',
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'date_post' => new DateTime(),
|
||||
'content' => $validated_data['message'],
|
||||
];
|
||||
|
||||
if (!empty($validated_data['file'])) {
|
||||
try {
|
||||
$post->addMediaFromRequest('file')->toMediaCollection('post_image');
|
||||
} catch (DiskDoesNotExist $e) {
|
||||
} catch (FileDoesNotExist $e) {
|
||||
} catch (FileIsTooBig $e) {
|
||||
}
|
||||
/** @var UploadedFile $uploaded_document */
|
||||
$uploaded_document = $validated_data['file'];
|
||||
$file_name = $uploaded_document->getClientOriginalName();
|
||||
$uploaded_document->storeAs(Auth::user()->getFolder(), $file_name);
|
||||
$image_service->makeThumbnail($uploaded_document->getRealPath(), ['width' => 300]);
|
||||
$data['image'] = $file_name;
|
||||
}
|
||||
|
||||
$this->setPostsTagsForPost($post, $tag_detector->detectFrom($validated_data['message']));
|
||||
$tags = $tag_detector->detectFrom($data['content']);
|
||||
|
||||
return Redirect::to('home')->withSuccess('Great! Form successfully submit with validation.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Post $post
|
||||
* @param $tags
|
||||
*/
|
||||
private function setPostsTagsForPost(Post $post, $tags)
|
||||
{
|
||||
$check = Post::create($data);
|
||||
$all_tags = Tag::all();
|
||||
$all_tags_names = [];
|
||||
foreach ($all_tags as $tag) {
|
||||
|
@ -170,12 +162,14 @@ class DashboardController extends Controller
|
|||
}
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if (in_array($tag, $all_tags_names, true)) {
|
||||
if (in_array($tag, $all_tags_names)) {
|
||||
PostsTag::create([
|
||||
'post_id' => $post->id,
|
||||
'post_id' => $check->id,
|
||||
'tag_id' => array_search($tag, $all_tags_names),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect::to('home')->withSuccess('Great! Form successfully submit with validation.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,10 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Post;
|
||||
use App\Services\ImageService;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Spatie\MediaLibrary\Models\Media;
|
||||
use Intervention\Image\Constraint;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||
|
||||
|
@ -16,40 +15,32 @@ class ImageController extends Controller
|
|||
{
|
||||
/**
|
||||
* @param int $post_id
|
||||
* @param string $alias
|
||||
* @param string|array $options
|
||||
* @param string $image
|
||||
* @param ImageService $image_service
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function display($post_id, $alias = '')
|
||||
public function display($post_id, $options = 'o:full', $image, ImageService $image_service)
|
||||
{
|
||||
/** @var Post $post */
|
||||
if (Auth::guest()) {
|
||||
throw new UnauthorizedHttpException('Vous devez être connecté pour voir cette image.');
|
||||
}
|
||||
|
||||
$post = Post::find($post_id);
|
||||
|
||||
if (Auth::user()->getAuthIdentifier() !== (int)$post->user_id) {
|
||||
throw new UnauthorizedHttpException('Cette image ne vous appartient pas.');
|
||||
}
|
||||
|
||||
$first_media = $post->getFirstMedia('post_image');
|
||||
if (!$first_media instanceof Media) {
|
||||
throw new NotFoundHttpException('Média non trouvé en base.');
|
||||
$original = sprintf('%s/%s/%s', storage_path('app'), Auth::user()->getFolder(), $image);
|
||||
if ('o:full' === $options) {
|
||||
$img = $image_service->makeThumbnail($original);
|
||||
} else {
|
||||
$img = $image_service->makeThumbnail($original, ['width' => 300]);
|
||||
}
|
||||
|
||||
return Image::make($first_media->getPath($alias))->response($first_media->mime_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $alias
|
||||
* @return mixed
|
||||
*/
|
||||
public function avatar($alias = '')
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = User::find(Auth::user()->getAuthIdentifier());
|
||||
|
||||
readfile($user->getFirstMediaPath('avatars', $alias));
|
||||
exit;
|
||||
return $img->response(File::extension($original));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +51,7 @@ class ImageController extends Controller
|
|||
$posts_with_image = Post::where('user_id', Auth::user()->getAuthIdentifier())
|
||||
->where('image', '!=', 'null')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(9);
|
||||
->paginate(30);
|
||||
|
||||
return view('gallery.my', [
|
||||
'posts' => $posts_with_image,
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Calendar\Month;
|
||||
use App\Post;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StatsController extends Controller
|
||||
{
|
||||
|
@ -13,22 +11,4 @@ class StatsController extends Controller
|
|||
// TODO
|
||||
exit;
|
||||
}
|
||||
|
||||
public function calendar($type, $year = null, $month = null)
|
||||
{
|
||||
if (null === $month) {
|
||||
$month = date('m');
|
||||
}
|
||||
|
||||
if (null === $year) {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$posts = Post::getUserPostForMonth(Auth::user()->getAuthIdentifier(), $year, $month);
|
||||
|
||||
if ('month' === $type) {
|
||||
$month_calendar = new Month($year, $month, $posts);
|
||||
return view('stats.calendar', ['month' => $month_calendar, 'type' => $type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\UpdateUser;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\DiskDoesNotExist;
|
||||
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileDoesNotExist;
|
||||
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileIsTooBig;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('user.index', ['user' => Auth::user()]);
|
||||
}
|
||||
|
||||
public function update(UpdateUser $request)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user_id = Auth::user()->getAuthIdentifier();
|
||||
$user = User::find($user_id);
|
||||
$validated = $request->validated();
|
||||
if (isset($validated['avatar'])) {
|
||||
try {
|
||||
$user->clearMediaCollection('avatars');
|
||||
$user->addMediaFromRequest('avatar')->toMediaCollection('avatars');
|
||||
} catch (DiskDoesNotExist $e) {
|
||||
} catch (FileDoesNotExist $e) {
|
||||
} catch (FileIsTooBig $e) {
|
||||
}
|
||||
unset($validated['avatar']);
|
||||
}
|
||||
|
||||
if (!array_key_exists('encrypt_messages', $validated)) {
|
||||
$validated['encrypt_messages'] = 0;
|
||||
}
|
||||
|
||||
$user->update($validated);
|
||||
|
||||
return redirect(route('user.index'))->withSuccess('Data saved!');
|
||||
}
|
||||
}
|
|
@ -24,15 +24,10 @@ class GenerateMenus
|
|||
$accueil->prepend('<i class="fe fe-home"></i> ');
|
||||
$accueil->checkActivationStatus();
|
||||
|
||||
// $stats = $menu->add('Mes statistiques', ['route' => 'stats', 'class' => 'nav-item'])->nickname('stats');
|
||||
// $stats->link->attr(['class' => 'nav-link']);
|
||||
// $stats->prepend('<i class="fe fe-trending-up"></i> ');
|
||||
// $stats->checkActivationStatus();
|
||||
|
||||
$calendar = $menu->add('Mon calendrier', ['route' => ['calendar', 'month'], 'class' => 'nav-item'])->nickname('calendar');
|
||||
$calendar->link->attr(['class' => 'nav-link']);
|
||||
$calendar->prepend('<i class="fe fe-calendar"></i> ');
|
||||
$calendar->checkActivationStatus();
|
||||
$stats = $menu->add('Mes statistiques', ['route' => 'stats', 'class' => 'nav-item'])->nickname('stats');
|
||||
$stats->link->attr(['class' => 'nav-link']);
|
||||
$stats->prepend('<i class="fe fe-trending-up"></i> ');
|
||||
$stats->checkActivationStatus();
|
||||
|
||||
$gallery = $menu->add('Ma gallerie', ['route' => 'gallery', 'class' => 'nav-item'])->nickname('gallery');
|
||||
$gallery->link->attr(['class' => 'nav-link']);
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AddPost extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return !Auth::guest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'message' => 'required',
|
||||
'file' => 'file|mimes:jpeg,png,jpg,gif,svg',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UpdateUser extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return !Auth::guest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|min:4|max:255',
|
||||
'email' => 'required|email:rfc|unique:users,email,'.Auth::user()->getAuthIdentifier(),
|
||||
'encrypt_messages' => 'boolean',
|
||||
'notification_hour' => 'in:0,1,2,3,4',
|
||||
'avatar' => 'file|dimensions:max_width=200,max_height=200,ratio=1'
|
||||
];
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ namespace App\Jobs;
|
|||
|
||||
use App\Mail\ReminderMail;
|
||||
use App\Mail\WelcomeMail;
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
@ -16,9 +15,8 @@ class SendReminderEmail implements ShouldQueue
|
|||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class DailyNotification extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->view('emails.daily');
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Calendar;
|
||||
|
||||
use App\Post;
|
||||
use DateTime;
|
||||
|
||||
class Day
|
||||
{
|
||||
/** @var DateTime */
|
||||
protected $date;
|
||||
/** @var Post|null */
|
||||
protected $post;
|
||||
|
||||
/**
|
||||
* Day constructor.
|
||||
* @param DateTime $date
|
||||
* @param Post $post
|
||||
*/
|
||||
public function __construct(DateTime $date, Post $post = null)
|
||||
{
|
||||
$this->date = $date;
|
||||
$this->post = $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getDate(): DateTime
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Post
|
||||
*/
|
||||
public function getPost(): ?Post
|
||||
{
|
||||
return $this->post;
|
||||
}
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Calendar;
|
||||
|
||||
use App\Post;
|
||||
use DateInterval;
|
||||
use DatePeriod;
|
||||
use DateTime;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class Month
|
||||
{
|
||||
/** @var int|string */
|
||||
protected $year;
|
||||
|
||||
/** @var int|string */
|
||||
protected $month;
|
||||
|
||||
/** @var Day[] */
|
||||
protected $days = [];
|
||||
|
||||
/**
|
||||
* Month constructor.
|
||||
* @param int|string $year
|
||||
* @param int|string $month
|
||||
* @param array $posts
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($year, $month, $posts = [])
|
||||
{
|
||||
$this->year = $year;
|
||||
$this->month = $month;
|
||||
$this->fillDays($posts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $posts
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function fillDays($posts)
|
||||
{
|
||||
$start = DateTime::createFromFormat('Y-m-d', sprintf('%s-%s-01', $this->year, str_pad($this->month, '0', 2)));
|
||||
$interval = new DateInterval('P1D');
|
||||
$end = clone $start;
|
||||
$end->add(new DateInterval('P1M'));
|
||||
$period = new DatePeriod($start, $interval, $end);
|
||||
|
||||
foreach ($period as $dt) {
|
||||
$post = null;
|
||||
if (count($posts) > 0 && $posts->first()->date_post->format('Ymd') === $dt->format('Ymd')) {
|
||||
$post = $posts->shift();
|
||||
}
|
||||
|
||||
$this->days[] = new Day($dt, $post);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return DateTime::createFromFormat('Y-m-d', sprintf('%s-%s-01', $this->year, str_pad($this->month, '0', 2)))
|
||||
->format('F Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Day[]
|
||||
*/
|
||||
public function getDays(): array
|
||||
{
|
||||
return $this->days;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime|false
|
||||
*/
|
||||
public function getPrevious()
|
||||
{
|
||||
return DateTime::createFromFormat('Y-m-d', sprintf('%s-%s-01', $this->year, str_pad($this->month, '0', 2)))
|
||||
->modify('-1 month');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime|false
|
||||
*/
|
||||
public function getNext()
|
||||
{
|
||||
return DateTime::createFromFormat('Y-m-d', sprintf('%s-%s-01', $this->year, str_pad($this->month, '0', 2)))
|
||||
->modify('+1 month');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
$content = '<ul class="dates">';
|
||||
|
||||
$first_day_of_month = DateTime::createFromFormat('Y-m-d', sprintf('%s-%s-01', $this->year, $this->month))->format('N');
|
||||
for ($i = 1; $i < $first_day_of_month; $i++) {
|
||||
$content .= '<li></li>';
|
||||
}
|
||||
foreach ($this->days as $day) {
|
||||
$content .= $this->_showDay($day);
|
||||
}
|
||||
$content .= '</ul>';
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Day $day
|
||||
* @return string
|
||||
*/
|
||||
private function _showDay(Day $day): string
|
||||
{
|
||||
$currentDate = $day->getDate()->format('Ymd');
|
||||
$day_of_week = $day->getDate()->format('N');
|
||||
$day_number = $day->getDate()->format('d');
|
||||
$post = $day->getPost();
|
||||
$classes = ['day'];
|
||||
if ($currentDate === date('Ymd')) {
|
||||
$classes[] = 'today';
|
||||
}
|
||||
if ($day_of_week % 7 === 1) {
|
||||
$classes[] = 'start';
|
||||
}
|
||||
if ($day_of_week % 7 === 0) {
|
||||
$classes[] = 'end';
|
||||
}
|
||||
if ($post instanceof Post) {
|
||||
$classes[] = 'has-post';
|
||||
}
|
||||
|
||||
return '<li id="li-' . $currentDate . '" class="' . implode(' ', $classes) .'">' . $day_number . '</li>';
|
||||
}
|
||||
}
|
31
app/Post.php
31
app/Post.php
|
@ -3,15 +3,9 @@
|
|||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Spatie\Image\Exceptions\InvalidManipulation;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
||||
use Spatie\MediaLibrary\Models\Media;
|
||||
|
||||
class Post extends Model implements HasMedia
|
||||
class Post extends Model
|
||||
{
|
||||
use HasMediaTrait;
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
@ -49,27 +43,4 @@ class Post extends Model implements HasMedia
|
|||
$tag_to_delete->delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getUserPostForMonth($user_id, $year, $month)
|
||||
{
|
||||
return self::whereMonth('date_post', $month)
|
||||
->whereYear('date_post', $year)
|
||||
->where('user_id', $user_id)
|
||||
->orderBy('date_post')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Media|null $media
|
||||
*/
|
||||
public function registerMediaConversions(Media $media = null)
|
||||
{
|
||||
try {
|
||||
$this->addMediaConversion('list')
|
||||
->width(300)
|
||||
->optimize();
|
||||
} catch (InvalidManipulation $e) {
|
||||
Log::alert(sprintf('Error while manipulating Post Image for %s (%s)', $this->id, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Exceptions\WrongHourException;
|
||||
use App\User;
|
||||
|
||||
class HourService
|
||||
{
|
||||
const NO_NOTIFICATION = 0;
|
||||
const MIDNIGHT_NOTIFICATION = 1;
|
||||
const MORNING_NOTIFICATION = 2;
|
||||
const NOON_NOTIFICATION = 3;
|
||||
const EVENING_NOTIFICATION = 4;
|
||||
|
||||
public static $notifications_classes = [
|
||||
self::NO_NOTIFICATION => 'slash',
|
||||
self::MIDNIGHT_NOTIFICATION => 'moon',
|
||||
self::MORNING_NOTIFICATION => 'sunrise',
|
||||
self::NOON_NOTIFICATION => 'sun',
|
||||
self::EVENING_NOTIFICATION => 'sunset',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return array
|
||||
*/
|
||||
public function getHoursBracket(User $user)
|
||||
{
|
||||
switch ((int)$user->notification_hour) {
|
||||
case self::MIDNIGHT_NOTIFICATION:
|
||||
return ['2100-2359', '0000-0600'];
|
||||
break;
|
||||
case self::MORNING_NOTIFICATION:
|
||||
return ['0601-1100'];
|
||||
break;
|
||||
case self::NOON_NOTIFICATION:
|
||||
return ['1101-1530'];
|
||||
break;
|
||||
case self::EVENING_NOTIFICATION:
|
||||
return ['1531-2059'];
|
||||
break;
|
||||
case self::NO_NOTIFICATION:
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|int|string $current_hour the hour and minute we want to find the id to. Formatted like `date('Hi')`
|
||||
* @return int
|
||||
* @throws WrongHourException
|
||||
*/
|
||||
public function getCurrentNotificationId($current_hour = null)
|
||||
{
|
||||
if (null === $current_hour) {
|
||||
$current_hour = date('Hi');
|
||||
}
|
||||
|
||||
$current_hour = (int) $current_hour;
|
||||
if (
|
||||
($current_hour >= 2100 && $current_hour < 2359) ||
|
||||
($current_hour >= 0 && $current_hour < 600)
|
||||
) {
|
||||
return self::MIDNIGHT_NOTIFICATION;
|
||||
}
|
||||
|
||||
if ($current_hour >= 600 && $current_hour < 1100) {
|
||||
return self::MORNING_NOTIFICATION;
|
||||
}
|
||||
|
||||
if ($current_hour >= 1100 && $current_hour < 1530) {
|
||||
return self::NOON_NOTIFICATION;
|
||||
}
|
||||
|
||||
if ($current_hour >= 1530 && $current_hour < 2100) {
|
||||
return self::EVENING_NOTIFICATION;
|
||||
}
|
||||
|
||||
throw new WrongHourException(sprintf('Given Time « %s » is not compatible', $current_hour));
|
||||
}
|
||||
}
|
50
app/User.php
50
app/User.php
|
@ -5,15 +5,10 @@ namespace App;
|
|||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Spatie\Image\Exceptions\InvalidManipulation;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
||||
use Spatie\MediaLibrary\Models\Media;
|
||||
|
||||
class User extends Authenticatable implements HasMedia
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable, HasMediaTrait;
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
@ -21,7 +16,7 @@ class User extends Authenticatable implements HasMedia
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password', 'notification_hour', 'encrypt_messages',
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -33,43 +28,18 @@ class User extends Authenticatable implements HasMedia
|
|||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'created_at', 'updated_at', 'email_verified_at',
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFolder()
|
||||
{
|
||||
$arrayHash = str_split(strtolower(md5($this->id)));
|
||||
return sprintf('%s/%s', $arrayHash[0], $arrayHash[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isE2E()
|
||||
{
|
||||
return (bool) $this->encrypt_messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Media|null $media
|
||||
*/
|
||||
public function registerMediaConversions(Media $media = null)
|
||||
{
|
||||
try {
|
||||
$this->addMediaConversion('thumb')
|
||||
->width(100)
|
||||
->height(100)
|
||||
->optimize();
|
||||
$this->addMediaConversion('icon')
|
||||
->width(32)
|
||||
->height(32)
|
||||
->optimize();
|
||||
} catch (InvalidManipulation $e) {
|
||||
Log::alert(sprintf('Error while manipulating Avatar for %s (%s)', $this->email, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
"intervention/image": "^2.5",
|
||||
"laravel/framework": "^6.0",
|
||||
"laravel/tinker": "^1.0",
|
||||
"lavary/laravel-menu": "^1.7",
|
||||
"spatie/laravel-medialibrary": "^7.0.0"
|
||||
"lavary/laravel-menu": "^1.7"
|
||||
},
|
||||
"require-dev": {
|
||||
"facade/ignition": "^1.4",
|
||||
|
|
454
composer.lock
generated
454
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "e3145fece6314548c650ce97ed16de32",
|
||||
"content-hash": "a8999b4d9f518e7a9608ff59c6ba40e9",
|
||||
"packages": [
|
||||
{
|
||||
"name": "dnoegel/php-xdg-base-dir",
|
||||
|
@ -953,128 +953,6 @@
|
|||
],
|
||||
"time": "2019-08-24T11:17:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/glide",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/glide.git",
|
||||
"reference": "a5477e9e822ed57b39861a17092b92553634932d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/glide/zipball/a5477e9e822ed57b39861a17092b92553634932d",
|
||||
"reference": "a5477e9e822ed57b39861a17092b92553634932d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"intervention/image": "^2.4",
|
||||
"league/flysystem": "^1.0",
|
||||
"php": "^5.5 | ^7.0",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9",
|
||||
"phpunit/php-token-stream": "^1.4",
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"League\\Glide\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jonathan Reinink",
|
||||
"email": "jonathan@reinink.ca",
|
||||
"homepage": "http://reinink.ca"
|
||||
}
|
||||
],
|
||||
"description": "Wonderfully easy on-demand image manipulation library with an HTTP based API.",
|
||||
"homepage": "http://glide.thephpleague.com",
|
||||
"keywords": [
|
||||
"ImageMagick",
|
||||
"editing",
|
||||
"gd",
|
||||
"image",
|
||||
"imagick",
|
||||
"league",
|
||||
"manipulation",
|
||||
"processing"
|
||||
],
|
||||
"time": "2019-04-03T23:46:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "maennchen/zipstream-php",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/maennchen/ZipStream-PHP.git",
|
||||
"reference": "6373eefe0b3274d7b702d81f2c99aa977ff97dc2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/6373eefe0b3274d7b702d81f2c99aa977ff97dc2",
|
||||
"reference": "6373eefe0b3274d7b702d81f2c99aa977ff97dc2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"myclabs/php-enum": "^1.5",
|
||||
"php": ">= 7.1",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-zip": "*",
|
||||
"guzzlehttp/guzzle": ">= 6.3",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"phpunit/phpunit": ">= 7.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ZipStream\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paul Duncan",
|
||||
"email": "pabs@pablotron.org"
|
||||
},
|
||||
{
|
||||
"name": "Jesse Donat",
|
||||
"email": "donatj@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonatan Männchen",
|
||||
"email": "jonatan@maennchen.ch"
|
||||
},
|
||||
{
|
||||
"name": "András Kolesár",
|
||||
"email": "kolesar@kolesar.hu"
|
||||
}
|
||||
],
|
||||
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
|
||||
"keywords": [
|
||||
"stream",
|
||||
"zip"
|
||||
],
|
||||
"time": "2019-07-17T11:01:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "2.0.0",
|
||||
|
@ -1156,52 +1034,6 @@
|
|||
],
|
||||
"time": "2019-08-30T09:56:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "myclabs/php-enum",
|
||||
"version": "1.7.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/php-enum.git",
|
||||
"reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/5f36467c7a87e20fbdc51e524fd8f9d1de80187c",
|
||||
"reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7",
|
||||
"squizlabs/php_codesniffer": "1.*",
|
||||
"vimeo/psalm": "^3.8"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"MyCLabs\\Enum\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP Enum contributors",
|
||||
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "PHP Enum implementation",
|
||||
"homepage": "http://github.com/myclabs/php-enum",
|
||||
"keywords": [
|
||||
"enum"
|
||||
],
|
||||
"time": "2020-02-14T08:15:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "2.24.0",
|
||||
|
@ -1866,290 +1698,6 @@
|
|||
],
|
||||
"time": "2018-07-19T23:38:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/image",
|
||||
"version": "1.7.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/image.git",
|
||||
"reference": "74535b5fd67ace75840c00c408666660843e755e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/image/zipball/74535b5fd67ace75840c00c408666660843e755e",
|
||||
"reference": "74535b5fd67ace75840c00c408666660843e755e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-exif": "*",
|
||||
"ext-mbstring": "*",
|
||||
"league/glide": "^1.4",
|
||||
"php": "^7.0",
|
||||
"spatie/image-optimizer": "^1.0",
|
||||
"spatie/temporary-directory": "^1.0.0",
|
||||
"symfony/process": "^3.0|^4.0|^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"larapack/dd": "^1.1",
|
||||
"phpunit/phpunit": "^6.0|^7.0",
|
||||
"symfony/var-dumper": "^3.2|^5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\Image\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Manipulate images with an expressive API",
|
||||
"homepage": "https://github.com/spatie/image",
|
||||
"keywords": [
|
||||
"image",
|
||||
"spatie"
|
||||
],
|
||||
"time": "2020-01-26T18:56:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/image-optimizer",
|
||||
"version": "1.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/image-optimizer.git",
|
||||
"reference": "9c1d470e34b28b715d25edb539dd6c899461527c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/image-optimizer/zipball/9c1d470e34b28b715d25edb539dd6c899461527c",
|
||||
"reference": "9c1d470e34b28b715d25edb539dd6c899461527c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-fileinfo": "*",
|
||||
"php": "^7.2",
|
||||
"psr/log": "^1.0",
|
||||
"symfony/process": "^4.2|^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.0",
|
||||
"symfony/var-dumper": "^4.2|^5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\ImageOptimizer\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Easily optimize images using PHP",
|
||||
"homepage": "https://github.com/spatie/image-optimizer",
|
||||
"keywords": [
|
||||
"image-optimizer",
|
||||
"spatie"
|
||||
],
|
||||
"time": "2019-11-25T12:29:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-medialibrary",
|
||||
"version": "7.18.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-medialibrary.git",
|
||||
"reference": "6461708267ca8863b351eb70f6d5eb324a3eec0b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/6461708267ca8863b351eb70f6d5eb324a3eec0b",
|
||||
"reference": "6461708267ca8863b351eb70f6d5eb324a3eec0b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-fileinfo": "*",
|
||||
"illuminate/bus": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
|
||||
"illuminate/console": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
|
||||
"illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
|
||||
"illuminate/pipeline": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
|
||||
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
|
||||
"league/flysystem": "^1.0.8",
|
||||
"maennchen/zipstream-php": "^1.0",
|
||||
"php": "^7.2",
|
||||
"spatie/image": "^1.4.0",
|
||||
"spatie/pdf-to-image": "^1.2",
|
||||
"spatie/temporary-directory": "^1.1"
|
||||
},
|
||||
"conflict": {
|
||||
"php-ffmpeg/php-ffmpeg": "<0.6.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/dbal": "^2.5.2",
|
||||
"ext-pdo_sqlite": "*",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"league/flysystem-aws-s3-v3": "^1.0.13",
|
||||
"mockery/mockery": "^1.0.0",
|
||||
"orchestra/testbench": "~3.8.0|^4.0",
|
||||
"phpunit/phpunit": "^8.0",
|
||||
"spatie/phpunit-snapshot-assertions": "^2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"league/flysystem-aws-s3-v3": "Required to use AWS S3 file storage",
|
||||
"php-ffmpeg/php-ffmpeg": "Required for generating video thumbnails"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Spatie\\MediaLibrary\\MediaLibraryServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\MediaLibrary\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://murze.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Associate files with Eloquent models",
|
||||
"homepage": "https://github.com/spatie/laravel-medialibrary",
|
||||
"keywords": [
|
||||
"cms",
|
||||
"conversion",
|
||||
"downloads",
|
||||
"images",
|
||||
"laravel",
|
||||
"laravel-medialibrary",
|
||||
"media",
|
||||
"spatie"
|
||||
],
|
||||
"time": "2020-01-05T12:27:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/pdf-to-image",
|
||||
"version": "1.8.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/pdf-to-image.git",
|
||||
"reference": "22a580e03550c95ce810ad430e3c44d2f7a1c75a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/pdf-to-image/zipball/22a580e03550c95ce810ad430e3c44d2f7a1c75a",
|
||||
"reference": "22a580e03550c95ce810ad430e3c44d2f7a1c75a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-imagick": "*",
|
||||
"php": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\PdfToImage\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Convert a pdf to an image",
|
||||
"homepage": "https://github.com/spatie/pdf-to-image",
|
||||
"keywords": [
|
||||
"convert",
|
||||
"image",
|
||||
"pdf",
|
||||
"pdf-to-image",
|
||||
"spatie"
|
||||
],
|
||||
"time": "2019-07-31T06:46:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/temporary-directory",
|
||||
"version": "1.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/temporary-directory.git",
|
||||
"reference": "fcb127e615700751dac2aefee0ea2808ff3f5bb1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/temporary-directory/zipball/fcb127e615700751dac2aefee0ea2808ff3f5bb1",
|
||||
"reference": "fcb127e615700751dac2aefee0ea2808ff3f5bb1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\TemporaryDirectory\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alex Vanderbist",
|
||||
"email": "alex@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Easily create, use and destroy temporary directories",
|
||||
"homepage": "https://github.com/spatie/temporary-directory",
|
||||
"keywords": [
|
||||
"spatie",
|
||||
"temporary-directory"
|
||||
],
|
||||
"time": "2019-12-15T18:52:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "v6.2.1",
|
||||
|
|
|
@ -1,156 +0,0 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* The disk on which to store added files and derived images by default. Choose
|
||||
* one or more of the disks you've configured in config/filesystems.php.
|
||||
*/
|
||||
'disk_name' => env('MEDIA_DISK', 'local'),
|
||||
|
||||
/*
|
||||
* The maximum file size of an item in bytes.
|
||||
* Adding a larger file will result in an exception.
|
||||
*/
|
||||
'max_file_size' => 1024 * 1024 * 10,
|
||||
|
||||
/*
|
||||
* This queue will be used to generate derived and responsive images.
|
||||
* Leave empty to use the default queue.
|
||||
*/
|
||||
'queue_name' => '',
|
||||
|
||||
/*
|
||||
* The fully qualified class name of the media model.
|
||||
*/
|
||||
'media_model' => Spatie\MediaLibrary\Models\Media::class,
|
||||
|
||||
's3' => [
|
||||
/*
|
||||
* The domain that should be prepended when generating urls.
|
||||
*/
|
||||
'domain' => 'https://'.env('AWS_BUCKET').'.s3.amazonaws.com',
|
||||
],
|
||||
|
||||
'remote' => [
|
||||
/*
|
||||
* Any extra headers that should be included when uploading media to
|
||||
* a remote disk. Even though supported headers may vary between
|
||||
* different drivers, a sensible default has been provided.
|
||||
*
|
||||
* Supported by S3: CacheControl, Expires, StorageClass,
|
||||
* ServerSideEncryption, Metadata, ACL, ContentEncoding
|
||||
*/
|
||||
'extra_headers' => [
|
||||
'CacheControl' => 'max-age=604800',
|
||||
],
|
||||
],
|
||||
|
||||
'responsive_images' => [
|
||||
|
||||
/*
|
||||
* This class is responsible for calculating the target widths of the responsive
|
||||
* images. By default we optimize for filesize and create variations that each are 20%
|
||||
* smaller than the previous one. More info in the documentation.
|
||||
*
|
||||
* https://docs.spatie.be/laravel-medialibrary/v7/advanced-usage/generating-responsive-images
|
||||
*/
|
||||
'width_calculator' => Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator::class,
|
||||
|
||||
/*
|
||||
* By default rendering media to a responsive image will add some javascript and a tiny placeholder.
|
||||
* This ensures that the browser can already determine the correct layout.
|
||||
*/
|
||||
'use_tiny_placeholders' => true,
|
||||
|
||||
/*
|
||||
* This class will generate the tiny placeholder used for progressive image loading. By default
|
||||
* the medialibrary will use a tiny blurred jpg image.
|
||||
*/
|
||||
'tiny_placeholder_generator' => Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred::class,
|
||||
],
|
||||
|
||||
/*
|
||||
* When urls to files get generated, this class will be called. Leave empty
|
||||
* if your files are stored locally above the site root or on s3.
|
||||
*/
|
||||
'url_generator' => null,
|
||||
|
||||
/*
|
||||
* Whether to activate versioning when urls to files get generated.
|
||||
* When activated, this attaches a ?v=xx query string to the URL.
|
||||
*/
|
||||
'version_urls' => false,
|
||||
|
||||
/*
|
||||
* The class that contains the strategy for determining a media file's path.
|
||||
*/
|
||||
'path_generator' => null,
|
||||
|
||||
/*
|
||||
* Medialibrary will try to optimize all converted images by removing
|
||||
* metadata and applying a little bit of compression. These are
|
||||
* the optimizers that will be used by default.
|
||||
*/
|
||||
'image_optimizers' => [
|
||||
Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [
|
||||
'--strip-all', // this strips out all text information such as comments and EXIF data
|
||||
'--all-progressive', // this will make sure the resulting image is a progressive one
|
||||
],
|
||||
Spatie\ImageOptimizer\Optimizers\Pngquant::class => [
|
||||
'--force', // required parameter for this package
|
||||
],
|
||||
Spatie\ImageOptimizer\Optimizers\Optipng::class => [
|
||||
'-i0', // this will result in a non-interlaced, progressive scanned image
|
||||
'-o2', // this set the optimization level to two (multiple IDAT compression trials)
|
||||
'-quiet', // required parameter for this package
|
||||
],
|
||||
Spatie\ImageOptimizer\Optimizers\Svgo::class => [
|
||||
'--disable=cleanupIDs', // disabling because it is known to cause troubles
|
||||
],
|
||||
Spatie\ImageOptimizer\Optimizers\Gifsicle::class => [
|
||||
'-b', // required parameter for this package
|
||||
'-O3', // this produces the slowest but best results
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
* These generators will be used to create an image of media files.
|
||||
*/
|
||||
'image_generators' => [
|
||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Image::class,
|
||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Webp::class,
|
||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Pdf::class,
|
||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Svg::class,
|
||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Video::class,
|
||||
],
|
||||
|
||||
/*
|
||||
* The engine that should perform the image conversions.
|
||||
* Should be either `gd` or `imagick`.
|
||||
*/
|
||||
'image_driver' => 'gd',
|
||||
|
||||
/*
|
||||
* FFMPEG & FFProbe binaries paths, only used if you try to generate video
|
||||
* thumbnails and have installed the php-ffmpeg/php-ffmpeg composer
|
||||
* dependency.
|
||||
*/
|
||||
'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'),
|
||||
'ffprobe_path' => env('FFPROBE_PATH', '/usr/bin/ffprobe'),
|
||||
|
||||
/*
|
||||
* The path where to store temporary files while performing image conversions.
|
||||
* If set to null, storage_path('medialibrary/temp') will be used.
|
||||
*/
|
||||
'temporary_directory_path' => null,
|
||||
|
||||
/*
|
||||
* Here you can override the class names of the jobs used by this package. Make sure
|
||||
* your custom jobs extend the ones provided by the package.
|
||||
*/
|
||||
'jobs' => [
|
||||
'perform_conversions' => Spatie\MediaLibrary\Jobs\PerformConversions::class,
|
||||
'generate_responsive_images' => Spatie\MediaLibrary\Jobs\GenerateResponsiveImages::class,
|
||||
],
|
||||
];
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddCascadeOnTags extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
Schema::table('posts_tags', function (Blueprint $table) {
|
||||
$table->dropForeign('post_id');
|
||||
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->dropForeign('tag_id');
|
||||
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
} else {
|
||||
// SQLite doesn't support drop foreign key
|
||||
Schema::rename('posts_tags', 'post_tags_bu');
|
||||
Schema::create('posts_tags', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->bigInteger('post_id');
|
||||
$table->bigInteger('tag_id');
|
||||
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade')->onUpdate('cascade');
|
||||
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
DB::insert('insert into posts_tags (id, post_id, tag_id, created_at, updated_at)
|
||||
select id, post_id, tag_id, created_at, updated_at from post_tags_bu');
|
||||
Schema::drop('post_tags_bu');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
Schema::table('posts_tags', function (Blueprint $table) {
|
||||
$table->dropForeign('post_id');
|
||||
$table->foreign('post_id')->references('id')->on('posts');
|
||||
$table->dropForeign('tag_id');
|
||||
$table->foreign('tag_id')->references('id')->on('tags');
|
||||
});
|
||||
} else {
|
||||
// SQLite doesn't support drop foreign key
|
||||
Schema::rename('posts_tags', 'post_tags_bu');
|
||||
Schema::create('posts_tags', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->timestamps();
|
||||
$table->bigInteger('post_id');
|
||||
$table->bigInteger('tag_id');
|
||||
$table->foreign('post_id')->references('id')->on('posts');
|
||||
$table->foreign('tag_id')->references('id')->on('tags');
|
||||
});
|
||||
DB::insert('insert into posts_tags (id, post_id, tag_id, created_at, updated_at)
|
||||
select id, post_id, tag_id, created_at, updated_at from post_tags_bu');
|
||||
Schema::drop('post_tags_bu');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateMediaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('media', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->morphs('model');
|
||||
$table->string('collection_name');
|
||||
$table->string('name');
|
||||
$table->string('file_name');
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->string('disk');
|
||||
$table->unsignedBigInteger('size');
|
||||
$table->json('manipulations');
|
||||
$table->json('custom_properties');
|
||||
$table->json('responsive_images');
|
||||
$table->unsignedInteger('order_column')->nullable();
|
||||
$table->nullableTimestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('media');
|
||||
}
|
||||
}
|
3
resources/sass/app.scss
vendored
3
resources/sass/app.scss
vendored
|
@ -19,6 +19,3 @@
|
|||
|
||||
// Surcharge
|
||||
@import 'general';
|
||||
|
||||
// Calendar
|
||||
@import "calendar";
|
||||
|
|
118
resources/sass/calendar.scss
vendored
118
resources/sass/calendar.scss
vendored
|
@ -1,118 +0,0 @@
|
|||
/*******************************Calendar Top Navigation*********************************/
|
||||
div#calendar {
|
||||
margin:0 auto;
|
||||
padding:0;
|
||||
width: 602px;
|
||||
font-family:special_eliteregular, "Times New Roman", Times, serif;
|
||||
}
|
||||
|
||||
div#calendar div.box {
|
||||
position:relative;
|
||||
top:0;
|
||||
left:0;
|
||||
width:100%;
|
||||
height:40px;
|
||||
background-color: #787878 ;
|
||||
}
|
||||
|
||||
div#calendar div.calendar-header {
|
||||
line-height:40px;
|
||||
vertical-align:middle;
|
||||
position:absolute;
|
||||
left:11px;
|
||||
top:0;
|
||||
width:582px;
|
||||
height:40px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
div#calendar div.calendar-header a.prev,div#calendar div.calendar-header a.next {
|
||||
position:absolute;
|
||||
top:0;
|
||||
height: 17px;
|
||||
display:block;
|
||||
cursor:pointer;
|
||||
text-decoration:none;
|
||||
color:#FFF;
|
||||
}
|
||||
|
||||
div#calendar div.calendar-header span.title{
|
||||
color:#FFF;
|
||||
font-size:18px;
|
||||
}
|
||||
|
||||
div#calendar div.calendar-header a.prev{
|
||||
left:0;
|
||||
}
|
||||
|
||||
div#calendar div.calendar-header a.next{
|
||||
right:0;
|
||||
}
|
||||
|
||||
/*******************************Calendar Content Cells*********************************/
|
||||
div#calendar div.box-content{
|
||||
border:1px solid #787878 ;
|
||||
border-top:none;
|
||||
}
|
||||
|
||||
div#calendar ul.label{
|
||||
float:left;
|
||||
padding: 0;
|
||||
margin: 5px 0 0 5px;
|
||||
}
|
||||
|
||||
div#calendar ul.label li{
|
||||
padding:0;
|
||||
margin: 0 5px 0 0;
|
||||
float:left;
|
||||
list-style-type:none;
|
||||
width:80px;
|
||||
height:40px;
|
||||
line-height:40px;
|
||||
vertical-align:middle;
|
||||
text-align:center;
|
||||
color:#000;
|
||||
font-size: 15px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
div#calendar ul.dates{
|
||||
float:left;
|
||||
padding: 0;
|
||||
margin: 0 0 5px 5px;
|
||||
}
|
||||
|
||||
/** overall width = width+padding-right**/
|
||||
div#calendar ul.dates li {
|
||||
padding:0;
|
||||
margin: 5px 5px 0 0;
|
||||
line-height:80px;
|
||||
vertical-align:middle;
|
||||
float:left;
|
||||
list-style-type:none;
|
||||
width:80px;
|
||||
height:80px;
|
||||
font-size:25px;
|
||||
color:#000;
|
||||
text-align:center;
|
||||
|
||||
&.day {
|
||||
background-color: #DDD;
|
||||
}
|
||||
|
||||
&.today {
|
||||
background-color: #0d8ddc;
|
||||
}
|
||||
|
||||
&.has-post {
|
||||
background-color: #63ad27;
|
||||
}
|
||||
}
|
||||
|
||||
:focus{
|
||||
outline:none;
|
||||
}
|
||||
|
||||
div.clear{
|
||||
clear:both;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
Merci d'Ă©crire !
|
|
@ -21,16 +21,13 @@
|
|||
<div class="card-body">
|
||||
<p>
|
||||
<a href="{{ route('display_image', ['post_id' => $post->id, 'options' => 'o:full', 'image_name' => $post->image]) }}">
|
||||
<img src="{{ route('display_image', ['post_id' => $post->id, 'alias' => 'list']) }}"/>
|
||||
<img src="{{ route('display_image', ['post_id' => $post->id, 'options' => 'w:300', 'image_name' => $post->image]) }}"/>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="col-sm-12">
|
||||
<?php echo $posts->render(); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
@ -126,7 +126,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="card-body @if($today->format('Y-m-d') === \Carbon\Carbon::instance($post->date_post)->format('Y-m-d')) already @endif ">
|
||||
@if($post->hasMedia('post_image'))<p><img src="{{ route('display_image', ['post_id' => $post->id]) }}"/></p>@endif <p data-encrypt>{!! $tag_detector->linkTagFrom($post->content) !!}</p>
|
||||
@if($post->image != '')<p><img src="{{ route('display_image', ['post_id' => $post->id, 'options' => 'w:300', 'image_name' => $post->image]) }}"/></p>@endif
|
||||
<p data-encrypt>{!! $tag_detector->linkTagFrom($post->content) !!}</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
{{ \Carbon\Carbon::instance($post->date_post)->format('d F Y') }}
|
||||
|
@ -134,7 +135,7 @@
|
|||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
<?php echo $posts->render(); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
@ -55,28 +55,19 @@
|
|||
</div>
|
||||
<div class="dropdown">
|
||||
<a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown">
|
||||
@php($avatar = Auth::user()->hasMedia('avatars'))
|
||||
@if($avatar !== '')
|
||||
<span>
|
||||
<img src="{{ route('display_avatar', ['alias' => 'icon']) }}"/>
|
||||
</span>
|
||||
@else
|
||||
<span class="avatar">
|
||||
{{ substr(Auth::user()->name, 0, 1) }}
|
||||
</span>
|
||||
@endif
|
||||
<span class="avatar">{{ substr(Auth::user()->name, 0, 1) }}</span>
|
||||
<span class="ml-2 d-none d-lg-block">
|
||||
<span class="text-default">{{ Auth::user()->name }}</span>
|
||||
<small class="text-muted d-block mt-1"></small>
|
||||
</span>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('user.index') }}">
|
||||
<i class="dropdown-icon fe fe-user"></i> {{ __('Profile') }}
|
||||
<a class="dropdown-item" href="#">
|
||||
<i class="dropdown-icon fe fe-user"></i> Profile
|
||||
</a>
|
||||
{{--<a class="dropdown-item" href="#">
|
||||
<a class="dropdown-item" href="#">
|
||||
<i class="dropdown-icon fe fe-settings"></i> Settings
|
||||
</a>--}}
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="{{ route('logout') }}"
|
||||
onclick="event.preventDefault();
|
||||
|
@ -100,16 +91,14 @@
|
|||
<div class="header collapse d-lg-flex p-0" id="headerMenuCollapse">
|
||||
<div class="container">
|
||||
<div class="row align-items-center">
|
||||
@if(!\Illuminate\Support\Facades\Auth::user()->isE2E())
|
||||
<div class="col-lg-3 ml-auto">
|
||||
<form class="input-icon my-3 my-lg-0">
|
||||
<input type="search" class="form-control header-search" name="search" placeholder="Search…" tabindex="1">
|
||||
<input type="search" class="form-control header-search" placeholder="Search…" tabindex="1">
|
||||
<div class="input-icon-addon">
|
||||
<i class="fe fe-search"></i>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endif
|
||||
<div class="col-lg order-lg-first">
|
||||
<ul class="nav nav-tabs border-0 flex-column flex-lg-row">
|
||||
@include(config('laravel-menu.views.bootstrap-items'), ['items' => $menu->roots()])
|
||||
|
@ -129,16 +118,17 @@
|
|||
<div class="row align-items-center">
|
||||
<div class="col-auto">
|
||||
<ul class="list-inline list-inline-dots mb-0">
|
||||
<li class="list-inline-item"><a href="{{ route('gallery') }}">{{ __('Gallery') }}</a></li>
|
||||
<li class="list-inline-item"><a href="./docs/index.html">Documentation</a></li>
|
||||
<li class="list-inline-item"><a href="./faq.html">FAQ</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="https://git.shikiryu.com/Shikiryu/journal-intime" class="btn btn-outline-primary btn-sm">Source code</a>
|
||||
<a href="https://github.com/tabler/tabler" class="btn btn-outline-primary btn-sm">Source code</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-auto mt-3 mt-lg-0 text-center">
|
||||
Copyright © 2019-{{ date('Y') }} <a href="{{ config('app.url') }}">{{ config('app.name') }}</a>.
|
||||
Copyright © 2019 <a href="{{ config('app.url') }}">{{ config('app.name') }}</a>. Thème par <a href="https://codecalm.net" target="_blank">codecalm.net</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
@extends('layouts.connected')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto">
|
||||
<h1 class="page-title">
|
||||
{{ $month->getDate() }}
|
||||
</h1>
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
@if (session('success'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
@if (session('errors'))
|
||||
<div class="alert alert-danger" role="alert">
|
||||
{{ session('errors') }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row flex-fill">
|
||||
<div class="col-12">
|
||||
<div id="calendar">
|
||||
<div class="box">
|
||||
<div class="calendar-header">
|
||||
@php($previous = $month->getPrevious())
|
||||
@php($next = $month->getNext())
|
||||
<a class="prev" href="{{ route('calendar', ['type' => $type, 'month' => $previous->format('m'), 'year' => $previous->format('Y')]) }}">Prev</a>
|
||||
<span class="title">{{ $month->getDate() }}</span>
|
||||
<a class="next" href="{{ route('calendar', ['type' => $type, 'month' => $next->format('m'), 'year' => $next->format('Y')]) }}">Next</a>
|
||||
</div></div><div class="box-content">
|
||||
<ul class="label">
|
||||
<li class="start title title">Mon</li>
|
||||
<li class="start title title">Tue</li>
|
||||
<li class="start title title">Wed</li>
|
||||
<li class="start title title">Thu</li>
|
||||
<li class="start title title">Fri</li>
|
||||
<li class="start title title">Sat</li>
|
||||
<li class="start title title">Sun</li>
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
{!! $month->render() !!}
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
|
@ -1,105 +0,0 @@
|
|||
@extends('layouts.connected')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto">
|
||||
<h1 class="page-title">
|
||||
{{ __('My profile') }}
|
||||
</h1>
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
@if (session('success'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
@if (session('errors'))
|
||||
<div class="alert alert-danger" role="alert">
|
||||
{{ session('errors') }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row flex-fill">
|
||||
<div class="col-12">
|
||||
<form action="{{ route('user.update') }}" method="post" class="card" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="form-group">
|
||||
<label class="form-label">{{ __('Name') }}</label>
|
||||
<input type="text" class="form-control" name="name" value="{{ $user->name }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">{{ __('Email') }}</label>
|
||||
<input type="email" class="form-control" name="email" value="{{ $user->email }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">{{ __('Password') }}</label>
|
||||
<div class="form-control-plaintext">*********</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">
|
||||
<input type="checkbox" name="encrypt_messages" value="1" class="custom-switch-input" @if($user->encrypt_messages) checked @endif>
|
||||
<span class="custom-switch-indicator"></span>
|
||||
<span class="custom-switch-description">{{ __('Encrypt my posts') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">{{ __('Notification hour') }}</label>
|
||||
<div class="selectgroup selectgroup-pills">
|
||||
<label class="selectgroup-item">
|
||||
<input type="radio" name="notification_hour" value="0" class="selectgroup-input" @if($user->notification_hour === null) checked @endif>
|
||||
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-slash"></i></span>
|
||||
</label>
|
||||
<label class="selectgroup-item">
|
||||
<input type="radio" name="notification_hour" value="1" class="selectgroup-input"@if($user->notification_hour === '1') checked @endif>
|
||||
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-moon"></i></span>
|
||||
</label>
|
||||
<label class="selectgroup-item">
|
||||
<input type="radio" name="notification_hour" value="2" class="selectgroup-input"@if($user->notification_hour === '2') checked @endif>
|
||||
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-sunrise"></i></span>
|
||||
</label>
|
||||
<label class="selectgroup-item">
|
||||
<input type="radio" name="notification_hour" value="3" class="selectgroup-input"@if($user->notification_hour === '3') checked @endif>
|
||||
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-sun"></i></span>
|
||||
</label>
|
||||
<label class="selectgroup-item">
|
||||
<input type="radio" name="notification_hour" value="4" class="selectgroup-input"@if($user->notification_hour === '4') checked @endif>
|
||||
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-sunset"></i></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="form-group">
|
||||
<div class="form-label">{{ __('Avatar') }}</div>
|
||||
@if(Auth::user()->hasMedia('avatars'))
|
||||
<img src="{{ route('display_avatar', ['alias' => 'thumb'])}}">
|
||||
@endif
|
||||
<div class="custom-file">
|
||||
<input type="file" class="custom-file-input" name="avatar">
|
||||
<label class="custom-file-label">{{ __('Choose your avatar') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer text-right">
|
||||
<div class="d-flex">
|
||||
<a href="{{ route('dashboard') }}" class="btn btn-link">{{ __('Cancel') }}</a>
|
||||
<button type="submit" class="btn btn-primary ml-auto">{{ __('Save') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
|
@ -11,32 +11,13 @@
|
|||
|
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Auth::routes();
|
||||
|
||||
// not connected
|
||||
Route::get('/', 'WelcomeController@index')->name('home');
|
||||
|
||||
// connected
|
||||
Route::group(['middleware' => ['auth']], function() {
|
||||
// posts
|
||||
Route::get('/home', 'DashboardController@index')->name('dashboard');
|
||||
Route::post('store', 'DashboardController@store')->name('store');
|
||||
Route::post('delete', 'DashboardController@delete')->name('delete');
|
||||
Route::post('edit', 'DashboardController@edit')->name('edit');
|
||||
|
||||
// stats
|
||||
Route::post('stats', 'StatsController@tag')->name('stats'); // TODO make a group for stats
|
||||
Route::get('/calendar/{type}/{year?}/{month?}', 'StatsController@calendar')->name('calendar');
|
||||
|
||||
// gallery
|
||||
Route::get('/avatar/{alias}', 'ImageController@avatar')->name('display_avatar');
|
||||
Route::get('/display/{post_id}/{alias?}', 'ImageController@display')->name('display_image');
|
||||
Route::get('/gallery', 'ImageController@gallery')->name('gallery');
|
||||
|
||||
// user
|
||||
Route::get('/user', 'UserController@index')->name('user.index');
|
||||
Route::post('/user', 'UserController@update')->name('user.update');
|
||||
});
|
||||
Route::get('/home', 'DashboardController@index')->name('dashboard');
|
||||
Route::post('store', 'DashboardController@store')->name('store');
|
||||
Route::post('delete', 'DashboardController@delete')->name('delete');
|
||||
Route::post('edit', 'DashboardController@edit')->name('edit');
|
||||
Route::post('stats', 'StatsController@tag')->name('stats'); // TODO make a group for stats
|
||||
Route::get('/display/{post_id}/{options}/{image_name}', 'ImageController@display')->name('display_image');
|
||||
Route::get('/gallery', 'ImageController@gallery')->name('gallery');
|
||||
|
|
Loading…
Reference in New Issue
Block a user