BrownieCoffee

BrownieCoffee

Member Since 1 Year Ago

Experience Points
7,970
Total
Experience

2,030 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
7,970 XP
Oct
18
2 days ago
Activity icon

Replied to Get Value Multiple Radio

@sinnbeck Yes That inside POST form. I'm not using ajax/js

Activity icon

Replied to Font Awesome, And Images Not Displaying In My Online Project

@sinnbeck sure

<IfModule mod_rewrite.c>
   <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>



Activity icon

Replied to Get Value Multiple Radio

@sinnbeck yes ( I posted the wrong code )

Activity icon

Started a new Conversation Get Value Multiple Radio

Hi there,

I'm trying to build a quiz and there are 5 questions. Each question has 3 choices and 1 choice is correct. 1 selection is possible.

I'm trying to get the selected choices but my request()->all(); return empty array ....

Can you help me please?

Thank you

my html

     <div class="quiz-box__questions-list">
                @foreach($quiz->questions as $key => $question)

                <div class="quiz-box__question-box">
                    <span class="quiz-box__question-number">Question {{$question->question_identifier .' / '. $quiz->questions->count() }}</span>
                    <p class="quiz-box__question">{{$question->question}}</p>
                    @if(!empty($question->illustration))
                    <figure>
                        <img class="quiz-box__question-illustration" src="{{$question->illustration}}" alt="">
                    </figure>
                    @endif
                    <div class="quiz-box__choices-list">

                        @php
                        $choices = App\Models\Choice::where('question_identifier', $question->question_identifier)->where('quiz_id', $quiz->id)->get();
                        @endphp

                        @foreach($choices->shuffle()->all() as $choice)

                        <label class="quiz-box__choice uk-card uk-card-default">
                            <input class="quiz-box__radio" type="radio" name="question_{{$question->question_identifier}}_choice" value="{{$choice->id}}">
                            <div class="quiz-box__choice-description">
                                <div class="quiz-box__choice-letter-box">
                                    A
                                </div>
                                <div class="quiz-box__choice-answer-box">
                                    <p class="quiz-box__choice-answer">{{$choice->choice}}</p>
                                </div>
                            </div>
                        </label>
                        @endforeach
                    </div>
                    <div class="uk-alert-danger" uk-alert>
                        <a class="uk-alert-close"></a>
                        <p>lorem ipsum</p>
                    </div>
                </div>
                <hr class="quiz-box__divider">
                @endforeach
            </div>

Activity icon

Replied to Font Awesome, And Images Not Displaying In My Online Project

@sinnbeck the home page doesn't works and I don't know why. I tryed your piece of code on my .htaccess and it fails too.

Oct
17
3 days ago
Activity icon

Replied to Font Awesome, And Images Not Displaying In My Online Project

@sinnbeck sure ! http://www.goshr.go.yo.fr/goshr/

@jlrdw my folder structure on shared hosting

- /
	- goshr-core/ (all folder and files exept public/ from my app)

	- public_html/
		- goshr ( content of the public/ from my app)
Oct
16
4 days ago
Activity icon

Replied to Font Awesome, And Images Not Displaying In My Online Project

@marianomoreyra Hi. I have no ssl with my free hosting I did deployment via FTP

Activity icon

Started a new Conversation Font Awesome, And Images Not Displaying In My Online Project

Hi there,

It's me again, my problem is in the title... Do you have any suggestion please?

I ran npm run production and optimized too

Thank you in advance.

Activity icon

Awarded Best Reply on There Is No Existing Directory At "/var/www/html/Goshr/storage/logs" And It Could Not Be Created: Permission Denied

Since this forum : https://www.tfzx.net/article/2728991.html

php artisan optimize:clear And

Delete bootstrap/cache/config.php Delete all log files in storage/logs.

Activity icon

Replied to There Is No Existing Directory At "/var/www/html/Goshr/storage/logs" And It Could Not Be Created: Permission Denied

Since this forum : https://www.tfzx.net/article/2728991.html

php artisan optimize:clear And

Delete bootstrap/cache/config.php Delete all log files in storage/logs.

Activity icon

Started a new Conversation There Is No Existing Directory At "/var/www/html/Goshr/storage/logs" And It Could Not Be Created: Permission Denied

Hi there,

I'm deploying my project on shared hosting.

here it's my folder

- /
	- myapp-core ( content of my app folder except "public" )

	-public_html
		-myapp (content of my app public folder)
		

I have this Symfony Exception There is no existing directory at "/var/www/html/Goshr/storage/logs" and it could not be created: Permission denied

my folders are in 755 (my storage too) permission and my files, 655. the permission are given to www-data www-data:www-data .

I optimized my app but I have still this exception.

Can you help me please ? Thank you and S.U.+

Activity icon

Replied to HTTP ERROR 500 Laravel Shared Hosting (planet Hoster )

@snapey @laracoft @jlrdw Okay I did a fresh reinstall. Now I have Symphony error : There is no existing directory at "/var/www/html/Goshr/storage/logs" and it could not be created: Permission denied

EDIT: I did : php artisan route:clear

php artisan config:clear

php artisan cache:clear

Oct
10
1 week ago
Activity icon

Replied to HTTP ERROR 500 Laravel Shared Hosting (planet Hoster )

@jlrdw @laracoft hi both of you. I had problem with my deployment. I'll retry later.

Oct
06
2 weeks ago
Activity icon

Replied to HTTP ERROR 500 Laravel Shared Hosting (planet Hoster )

@snapey my storage is writable.

@laracoft Ok I'll attempt

Activity icon

Replied to HTTP ERROR 500 Laravel Shared Hosting (planet Hoster )

@laracoft ok thank you.

My steps are the same on the video.... I did the good things.

Activity icon

Replied to HTTP ERROR 500 Laravel Shared Hosting (planet Hoster )

@laracoft I follow many threads on stackoverflow and medium about deployment in shared hosting. This steps recommended to move folders and files inside 'public' in 'public_html' and the others folders and files on project root inside a created folder in host.

So I edited my public for the paths.

@snapey It's not an error from laravel. This error in given by chrome.

Activity icon

Replied to HTTP ERROR 500 Laravel Shared Hosting (planet Hoster )

@snapey and ... the problem is in the title.

Activity icon

Started a new Conversation HTTP ERROR 500 Laravel Shared Hosting (planet Hoster )

Hi there,

I trying to deploy my project to shared hosting ( planethoster ). I use Filezilla and actually my structure is that

- goshr
- public_html
	- index.php
	-.htacess 
	- .....

I replace

__DIR__ . '/../bootstrap/autoload.php'

to that

__DIR__ . '/../app_folder/bootstrap/autoload.php'

and same for the other declaration on index.php

here my htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    #RewriteRule ^(.*)/$public / [L,R=301]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]


</IfModule>

Before deployment, I optimized my project and I added permissions.

Can you help me please?

Sep
29
3 weeks ago
Activity icon

Replied to Steps To Configure And Secure Laravel App Before Deployment

@jlrdw thank's but I would to insist about the folder permission, organization for example.

Activity icon

Started a new Conversation Steps To Configure And Secure Laravel App Before Deployment

Hi there,

Do you have steps to configure and secure the laravel app before deployment like folder permissions, .htaccess, changing folder location, path in the index.php ... ?

Thank you in advance.

S.U.+

Sep
22
4 weeks ago
Activity icon

Replied to Fails Get The Sender Mail (Gmail)

@automica I have still nothing no sender mail to the gmail header...

Activity icon

Replied to Fails Get The Sender Mail (Gmail)

@automica Sure

Now in my email header, I have sender name, but still not his email...

ContactCnotroller.php

 public function store(StoreContact $request)
    {

        // l'email est envoyé à l'adresse mail de l'équipe du site

        Mail::to($request->email)->send(new ContactConfirmationMail());

        $message = [
            'complete_name' => $request->complete_name,
            'email'         => $request->email,
            'subject'       => $request->subject,
            'message'       => purifier($request->message)
        ];

        // dd($message['subject']);

        Mail::to('[email protected]')->send(new ContactMail($message));

Mails/ContactMail.php

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ContactMail extends Mailable
{
    use Queueable, SerializesModels;

    public $message;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->from($this->message['email'], $this->message['complete_name'])
        ->subject('Un message a été envoyé par un utilisateur')
            ->markdown('mails.message-received');
    }
}

my .env

MAIL_USERNAME= my_username
MAIL_PASSWORD= my_password
MAIL_FROM_ADDRESS= my_mail_adress
MAIL_FROM_NAME= App Name

my config/mail.php

'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.gmail.com'),
            'port' => env('MAIL_PORT', 587),
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
            'username' => env('MAIL_USERNAME', 'my_mail_adress'),
            'password' => env('MAIL_PASSWORD', 'my_password'),
            'timeout' => null,
            'auth_mode' => null,
        ],


....



  'from' => [
        'address' => env('MAIL_FROM_ADDRESS', ''),
        'name' => env('MAIL_FROM_NAME', ''),
    ],

Activity icon

Started a new Conversation Fails Get The Sender Mail (Gmail)

Hi there,

I use form to permit to users to send mail to administrators.

I mail is sended on my gmail but I cannot retrieve the sender mail on the From. I have administrator mail unstead.

I don't know if i'm clear.

Can you help me please?

Thank you.

Sep
21
4 weeks ago
Activity icon

Replied to What Is Equivalent To Mail Later() Helper For Notification

@laracoft ok thank you I'll try to correct that.

Activity icon

Started a new Conversation What Is Equivalent To Mail Later() Helper For Notification

Hi there,

I have this error to Expected response code 354 but got code "550", with message "550 5.7.0 Requested action not taken: too many emails per second" when I send mail notification to my users.

I would like to use an equivalent to later() helper but for notification. I attempted to use delay()

$when = Carbon::now()->addSeconds(60);

$user->notify((new SendMailToUserReferingToCreatingCategory($category, $user))->delay($when));

But I have still my error on the top.

Can I have your help please ?

Thank in advance. S.U.+

Sep
07
1 month ago
Activity icon

Started a new Conversation Problem With My Modal: Same Route For Differents Contents.

Hi there,

I use @include to repeat report modal for project, topic and comment.

modal template

<!-- * Modal * -->
<div class="modal">
    <!-- * Modal Background * -->
    <div class="modal-background"></div>

    <!-- * Card * -->
    <div class="modal-card">

        <!-- * Header * -->
        <header class="modal-card-head">
            <h1 class="modal-card-title">{{$modalTitle}}</h1>
        </header>

        <!-- * Body * -->
        <div class="modal-body">
            @yield('modal-body')

            <!-- * Content * -->
            <section class="modal-card-body">
                @yield('modal-content')
            </section>

            <!-- * Footer * -->
            @yield('modal-footer')
        </div>
    </div>
    <button class="modal-close is-large is-active" aria-label="close"></button>
</div>

my report modal

@extends('templates.modals.modal-layout')

@section('modal-body')
<form action="{{$route}}" method="POST">
    @csrf
    @endsection

    @section('modal-content')
    <div style="margin-top:1rem;">
        <p class="modal-error help is-danger"></p>

        @foreach($motives as $motive)
        <label class="checkbox" style="display: block;line-height:2.5rem;">
            <input type="checkbox" name="motives[]" value="{{$motive->id}}">
            {{$motive->name}}
        </label>
        @endforeach
    </div>
    @endsection

    @section('modal-footer')
    <footer class="modal-card-foot">
        <button type="submit" class="modal-submit-button button is-rounded is-success">{{$confirmChoice}}</button>
        <button type="button" class="modal-close-button button is-rounded">Annuler</button>
    </footer>
</form>
@endsection

my comments.blade.php file

@include('templates.modals.report-modal', [
                            'modalId' => $comment->id,
                            'modalTitle' => 'Signaler ce commentaire',
                            'modalText' => 'Coche les raisons de ton signalement',
                            'route' => route('reports.storeCommentReport', ['comment' => $comment, 'user' => auth()->user()]),
                            'confirmChoice' => 'Je signale'
                            ])

my projects.blade.php file

@include('templates.modals.deletion-modal', [
                'modalTitle' => 'Supprimer ce projet',
                'question' => 'Souhaites-tu vraiment supprimer ce projet ?',
                'complementaryText' => '',
                'route' => route('projects.delete', [$project, $slug]),
                'confirmChoice' => 'Supprimer le projet'
                ])

my topics.blade.php

@include('templates.modals.report-modal', [
                            'modalId' => $topic->id,
                            'modalTitle' => 'Signaler cette question',
                            'modalText' => 'Coche les raisons de ton signalement',
                            'route' => route('reports.storeTopicReport', ['topic' => $topic, 'user' => auth()->user()]),
                            'confirmChoice' => 'Je signale'
                            ])

I have problem. Changes are ok for titleModal and others parameters except for the route...

If I click on the report-comment-btn. I have the project report route instead of comment report route.

I checked my route and there're ok.

I don't know why the route don't change .... Do you have any idea ?

Sep
06
1 month ago
Activity icon

Started a new Conversation My Topic's Report Call The Project's Report Page

Hello there,

I have a problem. I have topic report, project report and comment report. I loop around my reports.

@forelse($reports as $report)
    <div class="card" style="max-width: 70rem;margin:1rem;border-radius:15px;">
        <a href="{{$report->reportRoute()}}">
            <div class="card-content">

                <div style="display:grid;grid-template-columns:40px 1fr;column-gap:1rem;align-items:flex-start;">

                    <figure class="project-card__image image is-40x40">
                        <img class="is-rounded" src="{{$report->reportAuthorAvatar()}}" alt="Placeholder image">
                    </figure>

                    {!! $report->content() !!}
                </div>

                <div style="margin-top:1rem;">
                    @foreach($report->motives as $motive)
                    <span class="tag is-rounded is-info is-light" style="margin:0.4rem;white-space:normal;height:fit-content;padding:0.2rem 1rem;">{{$motive->name}}</span>
                    @endforeach
                </div>
            </div>
        </a>
    </div>

    @empty
    <p>aucun contenu signalé</p>

    @endforelse


my reportcontroller

public function index()
    {
        if (request()->motive) {

            $reports = Report::with('user', 'reportable', 'motives')
                ->where('read_at', NULL)
                ->whereHas('motives', function ($query) {
                    //si le slug correpond à celui selectionné
                    $query->where('slug', request()->motive);
                    //je les récupère
                })
                ->orderBy('created_at', 'DESC')
                ->get();

            // je récupère les catégories
            $motives = Motive::all();
            //je récupère le nom de la catégorie qui correspond à celle sélectionnée.
            $motiveName = $motives->where('slug', request()->motive)->first()->name;
            //si aucune catégorie n'est sélectionnée
        } else {
            //je récupère toutes les catégories
            $motives = Motive::get();
            //le nom de catégorie sera null
            $motiveName = '';
            //je récupères tous les projets.

            $reports = Report::with('user', 'reportable', 'motives')
                ->where('read_at', NULL)
                ->orderBy('created_at', 'DESC')
                ->get();
        }


        return view('reports.admin-index', [
            'motives' => $motives,
            'motiveName' => $motiveName,
            'reports' => $reports
        ]);
    }

my report model


    //je vais récupérer grâce à cette fonction la route du signalement selon son type
    public function reportRoute()
    {
        if ($this->reportable_type === 'App\Comment') {
            $route = route('admin.showCommentReport', ['admin' => auth()->user(), 'report' => $this->id, 'comment' => $this->reportable->id]);
        }

        else if ($this->reportable_type === 'App\Topic') {
            $route = route('admin.showTopicReport', ['admin' => auth()->user(), 'report' => $this->id, 'topic' => $this->reportable->id]);
        }

        else{
            $route = route('admin.showProjectReport', ['admin' => auth()->user(), 'report' => $this->id, 'project' => $this->reportable->slug]);
        }


        return $route;
    }

    //je vais récupérer grâce à cette fonction l'avatar de l'auteur du signalement
    public function reportAuthorAvatar()
    {
        $reportAuthorAvatar =  $this->user->getImage($this->user);

        return $reportAuthorAvatar;
    }

    //je vais récupérer grâce à cette fonction le contenu custom du signalement
    public function content()
    {
        if ($this->reportable_type === 'App\Comment') {

            $contentType = 'commentaire ' . '"' . $this->reportable->content . '"';
        } elseif ($this->reportable_type === 'App\Topic') {

            $contentType = 'topic ' . '"' . $this->reportable->content . '"';
        } else {

            $contentType = 'projet ' . '"' . $this->reportable->title . '"';
        }

        $notificationDate = \Carbon\Carbon::parse($this->created_at)->locale('fr');
        $transformNotificationDate = $notificationDate->isoFormat('D MMM YYYY à HH:mm');

        $reportAuthor = $this->user->username;

        $html = '<p style="margin: auto 0;color:gray;">';
        $html .= '<span style="color:black;">' . $reportAuthor . '</span>';
        $html .= ' a signalé le ' . $contentType . ' le ' . $transformNotificationDate . ' pour les motifs suivants';
        $html .= '</p>';

        return $html;
    }

my web.php

 Route::get('/signalements', '[email protected]')->name('indexReports');

        Route::get('/signalements/signalement-{report}/{project}/', '[email protected]')->name('showProjectReport');


Route::get('/signalements/signalement-{report}/commentaire-{comment}/', '[email protected]')->name('showCommentReport');


        Route::get('/signalements/signalement-{report}/topic-{topic}/', '[email protected]')->name('showTopicReport');


actually, my first report concerns topic. When I click on at, my topic report call the project report page instead of topic report page ( which show the single topic report ).

Can you help me please?

Thank you by advance and S.U.+

Activity icon

Started a new Conversation Check Authenticated User + Mail Redirection Button.

Hi there,

I send mail to author's project to let him know his content has been commented. This mail contains button which redirect author's project to the comment.

I would like to know if is it possible to check the authenticated user before this redirection to the comment.

Thank you for you help.

Bye.

Sep
05
1 month ago
Activity icon

Started a new Conversation Is It Possible To Do An `@extends` Inside An `@extends` ? Other Alternative ?

Hi there,

I have a part of my html code I repeat many times: that concerned my projects list.

But this projects list can be updated accorting to differents pages ( add categories list to filter, add checkboxes...)

I would like to find a way to call one time this project list and can had modifications accorting to my needs.

I thought about template to extends to an another file and to include for my specifics pages.

It could be work, right ??

Thank by advance. S.U.+

Sep
02
1 month ago
Activity icon

Started a new Conversation Regex Allowing Letters,letters With Accents, Number, Dashes, Underscores And Spaces.

Hi there,

I'm trying to find regex which permit to allow letter, number, dashes, underscores and spaces.

I tryied that.

^[a-zA-Z0-9,.!? ]*$

also that

^[\w\s,.]+$

and PCRE

[^\p{L}\p{P}\p{N}\p{S}\p{M}]

But nothing works to me...

Can you help me please?

Thank you and S.U.+

Sep
01
1 month ago
Activity icon

Replied to My Second Button Is Not Recognized In My Form

@automica @snapey After a break moment, I figured out my error

 'category'                          => "$fieldValidation|exists:categories,id",
            'difficulty' //here                       => "$fieldValidation|exists:difficulty_levels,id",

I replace difficulty by difficulty_level ( the name of my input)

Now It works. Thank you both .

Activity icon

Replied to My Second Button Is Not Recognized In My Form

@snapey @automica All my route are writen after checking.

Route::get('/projets/{project}/{slug}/modifier-mon-brouillon/{token}', '[email protected]')->name('draft');

     
        Route::patch('/projets/{project}/{slug}/modifier-mon-brouillon', '[email protected]')->name('updateDraft');

@automica talked about my EditRequest.

I replace public function updateDraft(EditRequest $request) by public function updateDraft(Request $request) to test.

Now my dd($request->submit === 'publish) works.

But I still don't know what is the problem with the EditProject request :/

<?php

namespace App\Http\Requests;

use App\Project;
use Illuminate\Foundation\Http\FormRequest;

class EditProject extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        // je retrouve le projet
        $project = Project::find($this->project);

        if (request()->input('submit') == 'draft') {
            // les champs pourront être nullable
            $fieldValidation = 'nullable';
        } else {
            //     //autrement, ils seront requis
            $fieldValidation = 'required';
        }


        //le titre devra répondre aux critères si dessous, en prenant soin d'ignorer la vérification du titre unique pour ce même projet
        $project_material = $project->materials()->first();
        //si mon projet a des materiels
        if ($project_material !== null) {
            //je récupère le premier id du materiel que je viens stocker en variable
            $first_material = $project->materials()->first();

            // dd($project->materials()->first());
            $first_material_id = $first_material->id;
            $field = 'material.' . $first_material_id;
        } else {
            //s'il n'en a pas, le premier champs matériel sera le champs 0
            $field = 'material.0';
        }


        //si ce projet a une image thumbnail
        if ($project->thumbnail !== null) {
            $thumbnailValidation = 'sometimes|image|mimes:jpg,jpeg,png|max:3000';
        }



        return [
            'title'                             =>  "$fieldValidation|string|min:6|max:80|unique:projects,title,$project->id",
            'thumbnail'                         =>  $thumbnailValidation,
            'category'                          => "$fieldValidation|exists:categories,id",
            'difficulty'                        => "$fieldValidation|exists:difficulty_levels,id",
            'material.*'                        => 'distinct|nullable|string',
            $field                              => "$fieldValidation|string|min:3",
            'duration'                          => "$fieldValidation|integer|min:1|max:24",
            'unity_of_measurement'              => "$fieldValidation|exists:unities_of_measurement,id",
            'budget'                            => "$fieldValidation|integer|min:1|max:1000",
            'content'                           => 'required|min:100'
        ];
    }


    public function messages()
    {
        return [
            'title.required'        => 'Le titre doit être inscrit.',
            'title.string'          => 'Le titre doit être une courte phrase',
            'title.min'             => 'Le titre doit contenir au minimum :min caractères.',
            'title.max'             => 'Le titre doit contenir  au maximum :max caractères.',
            'title.unique'          => 'Il semblerait que ce titre soit déjà pris.',

            'thumbnail.required'    => 'Une image thumbnail doit être présent pour illustrer votre projet',
            'thumbnail.image'       => 'Votre fichier doit être une image',
            'thumbnail.mimes'       => "L'image thumbnail doit être de type .jpg, .jpeg, .png",
            'thumbnail.max'         => "L'image semble être trop lourde",
            'thumbnail.uploaded'    => "Il y a une erreur lors du téléchargement de l'image.",

            'category.required'     => 'Une catégorie doit être choisie pour votre projet.',

            'difficulty.required'   => 'Un niveau de difficulté doit être choisie pour votre projet.',

            'material.0.required'   => 'Au moins un matériel doit être renseigné.',
            'material.0.min'        => "Le matériel doit être composé d'au moins :min caractères.",

            'duration.required'     => 'Le temps estimé du projet doit être renseigné.',
            'duration.integer'      => "Ce champs n'accepte que des chiffres",
            'duration.min'          => 'La durée ne peut pas être inférieure à :min',
            'duration.max'          => 'La durée ne peut pas être supérieur à :max',

            'budget.required'       => 'Le budget du projet doit être renseignée.',
            'budget.integer'        => "Ce champs n'accepte que des chiffres",
            'budget.min'            => 'Le budget ne peut pas être inférieur à :min €',
            'budget.max'            => 'Le budget peut pas dépasser :max €',

            'content.required'      => 'Le contenu du projet ne peut pas être vide.',
            'content.min'           => 'Le contenu du projet doit contenir au moins :min caractères.',


        ];
    }
}


Activity icon

Replied to My Second Button Is Not Recognized In My Form

@automica Yes, i did it, my dd() in not listened :/ .

Activity icon

Replied to My Second Button Is Not Recognized In My Form

@automica when I click on the published button, it's like I redirect on the form page without any changing. Only my draft button works.

Activity icon

Started a new Conversation My Second Button Is Not Recognized In My Form

Hi there,

I have problem with my form.

There are two buttons. One for draft, the other for publish

        <form action="{{route('projects.updateDraft', [$project, $slug])}}" method="POST" enctype="multipart/form-data">
...

          <!-- *  Footer * -->

            <div class="project-form__sub-footer">
                <button class="project-form__button button is-rounded" type="submit" name="submit" value="draft" style="margin-bottom: 1rem;">
                    <span>ajouter au brouillon</span>
                </button>
                <button class="project-form__button project-form__button--submit button is-rounded"  type="submit" name="submit" value="publish">
                    <span>poster mon projet !</span>
                </button>
            </div>
</form>

Before this worked but I don't know why not now.

there are that in my controller


    /**
     * Update the drafted project in database
     *
     * @param  \Illuminate\Http\Requests\EditProject  $request
     * @param int $project | id of the project
     * @param string $slug | slug of the project
     * @param string $token | token of the drafted project
     * @param  \Services\ProjectService $projectService
     * @return \Illuminate\Http\Response
     */
    public function updateDraft(EditProject $request, $project, $slug, ProjectService $projectService)
    {

...


  if ($request->submit == 'draft') {
            //si le status du projet est en publié
            if ($project->status_id == 2) {
                //je le change en brouillon
                $project->update([
                    'status_id' => 1
                ]);
            }
            //je retourne à la dernière page
            return back()->with('status', 'Projet sauvé au brouillon ! Vous pourrez le publier en cliquant sur le bouton de publication.');
        }
        //si l'utilisateur clique sur le bouton de publication
        if ($request->submit == 'publish') {
            //j'édite le status du projet en publié
            $project->update([
                'status_id' => 2
            ]);

            //je redirige l'utilisateur vers le projet qu'il vient de publié
            return redirect()->route('projects.show', [
                'project' => $project,
                'slug' => $slug
            ])->with('status', 'votre projet vient est à présent publié !');
        }

web.php

  Route::get('/projets/{project}/{slug}/modifier-mon-brouillon/{token}', '[email protected]')->name('draft');

     
        Route::patch('/projets/{project}/{slug}/modifier-mon-brouillon', '[email protected]')->name('updateDraft');

only the draft button works but publish button fails.

Can you help me please?

Thank by advance. See you.

EDIT: When I check to the network in chrome developpers tools, chrome knows what button is clicked....

I really don't understand why my form is not send so...

Aug
27
1 month ago
Activity icon

Started a new Conversation Pass $report->motives To Array Of My Notification

Hi there,

I'm trying to do notification for my report.

A report can have many motives.

I would like to retrieve this motives for my notification.

    public function toArray($notifiable)
    {

 
        return [
             //ici, je viens déclarer ce dont j'ai besoin pour le signalement dont...
            //le titre du projet concerné par le signalement
            'projectTitle' => $this->project->title,
            //l'identifiant du projet concerné par le signalement
            'projectId' => $this->project->id,
            //le pseudonyme de l'utilisateur qui a fait le signalement
            'userUsername' => $this->user->username,
            //la date du signalement
            'reportDate' => $this->report->created_at,
            //report Motive
   
            'reportMotives' => ???
  
        ];
    }

is it possible to do that ?

Thank you in advance.

See you +

Aug
20
2 months ago
Activity icon

Started a new Conversation Redirection Fails With Laravel Testing

Hi there,

I'm trying to redirect my route following

my test giving me this error

   FAIL  Tests\Feature\RegisterTest
  ✕ user is registered with good datas in fields

  Tests:  1 failed, 1 pending

  Failed asserting that two strings are equal.

  at tests/Feature/RegisterTest.php:96
     92|                 'email' => $user->email,
     93|                 'password' => $user->password,
     94|                 'password_confirmation' => $user->password
     95|             ]
  >  96|         )->assertRedirect(route('login.create'));
     97| 
     98| 
     99|         // $this->assertDatabaseHas('users', [
    100|         //     'username' => $user->username,

--- Expected
+++ Actual
@@ @@
-'http://localhost/connexion'
+'http://localhost'


 public function user_is_registered_with_good_datas_in_fields()
    {


     
        $user = factory(User::class)->create();

     
        $response  = $this->post(
            route('register.store'),
            [
                'username' => $user->username,
                'email' => $user->email,
                'password' => $user->password,
                'password_confirmation' => $user->password
            ]
        );


        $this->assertDatabaseHas('users', [
            'username' => $user->username,
            'email' => $user->email,
            'password' => $user->password,
        ]);

        $response->assertRedirect(route('login.create'));
        // $response->session()->setPreviousUrl('login');
    }

I insist on the fact that I use my own auth system.

After the user is registered, he is redirect to the signup form.

I read that it was necessary to use ->from() like precised here: https://titanwolf.org/Network/Articles/Article?AID=1110bb1e-be24-481a-b934-912c80dc0fc0#gsc.tab=0

but what route put in the ->from() ?

Aug
19
2 months ago
Activity icon

Replied to Upload Image In Specific Folder With Faker

@maverickchan thank you I'll see my code.

Aug
17
2 months ago
Activity icon

Replied to Upload Image In Specific Folder With Faker

@sinnbeck Hi yes thanks I correct that but It still fails.


  $storagePath = 'projets/' . $user->username.'/projet_' . $identifier . '/thumbnail';

        
        if (!Storage::exists($storagePath)) {
            // ... je récupère mon image que je vais stoker dans le dossier avatars/[nom-de-l'utilisateur] dans le storage local 'public/'
            Storage::makeDirectory('public/'.$storagePath);
        }
Activity icon

Replied to Upload Image In Specific Folder With Faker

@snapey this following code create project folder if it doesn't exist.

        // $storagePath = 'projets/' . $user->username.'/projet_' . $identifier . '/thumbnail/';

if (!Storage::exists($storagePath)) {
    $storagePath;
}

I already used public path and relative path and it fails for both.

Aug
16
2 months ago
Activity icon

Started a new Conversation Upload Image In Specific Folder With Faker

Hi,

I'm using faker and seeder to generates fake datas and I would like to upload image in specific folder for my users's projects.

actually my code follow is giving me error Cannot write to directory "/var/www/html/goshr/storage/projets/Kelley/projet_385093/thumbnail/"

$factory->define(Project::class, function (Faker $faker) {
  
    $user = factory(App\User::class)->create([
        'is_admin' => 0
    ]);

    $categories = App\Category::pluck('id')->toArray();
    $uOM = App\UnityOfMeasurement::pluck('id')->toArray();
    $difficulties = App\DifficultyLevel::pluck('id')->toArray();
    $status = App\Status::pluck('id')->toArray();

    session(['project_identifier' => mt_rand(100000, 999999)]);
    $identifier = session('project_identifier');

        $storagePath = 'projets/' . $user->username.'/projet_' . $identifier . '/thumbnail/';

        if (!Storage::exists($storagePath)) {
            // ... je récupère mon image que je vais stoker dans le dossier avatars/[nom-de-l'utilisateur] dans le storage local 'public/'
            $storagePath;
        }



    // $faker->image('public/storage/projets/'.$user->username.'/projet_'.$identifier.'/thumbnail/',640,480, null, false),
    return [
        'user_id' => $user->id,
        'title' => $faker->sentence($nbWords = 6, $variableNbWords = true),
        'category_id' => $faker->randomElement($categories),
        'id_number' => $identifier ,
        'duration' => mt_rand(1,24),
        'budget' => mt_rand(1,100),
        'unity_of_measurement_id' => $faker->randomElement($uOM),
        'difficulty_level_id' => $faker->randomElement($difficulties),
        'status_id' => $faker->randomElement($status),
        'thumbnail' => $faker->image(storage_path('projets/'.$user->username.'/projet_'.$identifier.'/thumbnail/'),640,480, null, false),
        'content' => $faker->text($maxNbChars = 200),
    ];
});

my folder permission is okay.

How can I do ?

Thank you by advance. S.U.+

Aug
15
2 months ago
Activity icon

Replied to Where Clause In Factories / Seeders

@alyve, hi. Thank you for your suggestion, I'll watch that ;)

Activity icon

Started a new Conversation Where Clause In Factories / Seeders

Hello there,

I would like to generate records with factories and seeder.

I would to do that:

User has (n) posts/comments if is a author.

User has reports if is a reader and not author of his post/comment/topic.

Can I do that for my factories and my seeder ?

Thank by advance and S.U.+


$faker = Factory::create('fr_FR');


$factory->define(User::class, function (Faker $faker) {
    return [
        'email' => $faker->unique()->safeEmail,
        'username' => $faker->lastName,
        'firstname' => $faker->firstName,
        'username' => $faker->unique()->firstName(),
        'avatar' => $faker->image('public/storage/images',640,480, null, false),
        'password' => bcrypt('password'),
        'rank_id' => 2
    ];
});


   $users = App\User::pluck('id')->toArray();
    $categories = App\Category::pluck('id')->toArray();
    $uOM = App\UnityOfMeasurement::pluck('id')->toArray();
    $difficulties = App\DifficultyLevel::pluck('id')->toArray();
    $status = App\Status::pluck('id')->toArray();

    return [
        'user_id' => $faker->randomElement($users),
        'title' => $faker->sentence($nbWords = 6, $variableNbWords = true),
        'category_id' => $faker->randomElement($categories),
        'id_number' => mt_rand(100000, 999999) ,
        'duration' => rand(1,24),
        'unity_of_measurement_id' => $faker->randomElement($uOM),
        'difficulty_level_id' => $faker->randomElement($difficulties),
        'status_id' => $faker->randomElement($status),
        'thumbnail' => $faker->image('public/storage/images',640,480, null, false),
        'content' => $faker->text($maxNbChars = 200),
    ];

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        factory(User::class, 10)->create();

        // Get all the roles attaching up to 3 random roles to each user
        $roles = Role::all();

        // Populate the pivot table
        App\User::all()->each(function ($user) use ($roles) {
            $user->roles()->attach(
                $roles->random(rand(1, 3))->pluck('id')->toArray()
            );
        });
    }
}

Activity icon

Replied to Update Datas If There Are Changing

@automica thank's but not at the moment. :)