BrownieCoffee

BrownieCoffee

Member Since 3 Weeks Ago

Experience Points 630
Experience Level 1

4,370 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 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

22 Jul
7 hours ago

BrownieCoffee started a new conversation Best Practices To Stock Image From User Post

Hello guys, I have doubt about the save posts structure and I would your advices for the best pratices to have to save image of user's posts.

Do I stock in file "image/uploads/posts/[post_number]", with dynamic manner ?

and for the database, Do I create a table for attachments ( images / videos / file ) ?

Thank you by advance ( and sorry for bad english). Good bye !

BrownieCoffee left a reply on Install Fail CKEditor 5 With NPM

It's okay for me. Finally, I used "Froala editor " :)

19 Jul
3 days ago

BrownieCoffee started a new conversation Install Fail CKEditor 5 With NPM

Hello, guys!

Someone can help me to install CKEditor on Laravel with NPM ? I tryed this solution but I have errors in the console. But It seems to be correct.

on my app.js

window.ckeditor = require('@ckeditor/ckeditor5-build-classic');

import ClassicEditor from '@ckeditor/ckeditor5-build-classic';


ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
    window.editor = editor;
} )
.catch( err => {
    console.error( err.stack );
} );

on my blade.php

<textarea name="content" id="editor">
    &lt;p&gt;Here goes the initial content of the editor.&lt;/p&gt;
</textarea>
<script src="./node_modules/@ckeditor/ckeditor5-build-classic/build/ckeditor.js"></script>

the error message

GET http://localhost:3000/node_modules/@ckeditor/ckeditor5-build-classic/build/ckeditor.js net::ERR_ABORTED 404 (Not Found)
app.js:12458 Uncaught TypeError: Cannot read property 'appendChild' of null
    at app.js:12458
    at insertNodes (app.js:12479)
    at append (app.js:12458)
    at UIkitComponent.created (app.js:21629)
    at app.js:14375
    at Array.forEach (<anonymous>)
    at UIkitComponent.UIkit._callHook (app.js:14375)
    at UIkitComponent.UIkit._init (app.js:14492)
    at new UIkitComponent (app.js:14308)
    at Function.UIkit.<computed> [as notification] (app.js:14087)
(anonymous) @ app.js:12458
insertNodes @ app.js:12479
append @ app.js:12458
created @ app.js:21629
(anonymous) @ app.js:14375
UIkit._callHook @ app.js:14375
UIkit._init @ app.js:14492
UIkitComponent @ app.js:14308
UIkit.<computed> @ app.js:14087
./resources/js/app.js @ app.js:35679
__webpack_require__ @ app.js:20
0 @ app.js:35776
__webpack_require__ @ app.js:20
(anonymous) @ app.js:84
(anonymous) @ app.js:87
nouvelle-article:48 GET http://localhost:3000/node_modules/@ckeditor/ckeditor5-build-classic/build/ckeditor.js net::ERR_ABORTED 404 (Not Found)

Thank you by avance for you help !

See you soon!

11 Jul
1 week ago

BrownieCoffee left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Object Given

@johnbraun Hello, I thank for your reply.

It my fault, I find the solution:

<select class="form-control" id="needed-service" name="needed-service">
         <option hidden disabled selected value="">Selectionner un service</option>
                 @foreach ($services as $neededService)
          <option value="{{$neededService->id}}">{{$neededService->name}}</option>
          @endforeach
  </select>

BrownieCoffee started a new conversation Htmlspecialchars() Expects Parameter 1 To Be String, Object Given

Hello there,

I have a problem to fix this error.

I want to use my datas from the "services" table. I did this in my controller to get all datas:

use Illuminate\Support\Facades\DB;



    public function create(){


        $services = DB::table('services')->get([
            'id', 'name'
        ]);

        dump($services);

        return view ('request.create', compact('services'));

    }

I'm trying to do a foreach for get id and name

<select class="form-control" id="needed-service" name="needed-service">
       <option hidden disabled selected value="">Selectionner un service</option>
             @foreach ($services as $keyService => $service)
                    <option value="{{$keyService}}">{{$service}}</option>
             @endforeach
       <option>Cours de conduite</option>
</select>

but I have this error but I can not fix this problem...

htmlspecialchars() expects parameter 1 to be string, object given (View: /var/www/html/ourSwapServices/resources/views/request/create.blade.php)

Can you help me please ?

Thank you in advance and see you soon!

BrownieCoffee left a reply on Specific Validations For Dates Selects

@bobbybouwmann hello !

Thank for your reply. I tryed this code but it didn't work.

I discorevred the custom rules validations which seem to work.

I find the solution!

Thank for you reply again :D

10 Jul
1 week ago

BrownieCoffee started a new conversation Specific Validations For Dates Selects

Hi everyone.

Can you help me to fix my validations problems please ? I'm stuck.

I use selects for start day and end day ( day, month and year).

I would create some conditions around those.

If the start day or the end day are less than the current day ( today), it gerenates error.

If the end day is less than start day, it generates error too.

But with my configuration, I have some difficulties.

Can you help please?

Thank you a lot in advance and good bye !

my actual code on my ServiceRequestController.php

   public function store(Request $request){


        $requestDatas = $request->validate([

            'needed-service' => 'required',

            'address' => '',
            'zip-code' => 'required|numeric|digits:5',
            'city' => 'required|string|max:300',

            'startDay' => 'required',
            'startMonth' => 'required',
            'startYear' => 'required',

            'endDay' => 'required',
            'endMonth' => 'required',
            'endYear' => 'required',

            'provided-service' => 'required',

            'complementaries-informations' => 'nullable'
        ]);



        ServiceRequest::create($requestDatas);

        

        $currentDay = Carbon::now()->day;
        $currentMonth = Carbon::now()->locale('fr')->monthName;
        $currentYear = Carbon::now()->year;

        $currentDate = Carbon::today();
        // dump($currentDay);
        // dump($currentMonth);
        // dump($currentYear);
        dump($currentDate);


        $theStartDate = Carbon::create(Input::get('startYear'), Input::get('startMonth'), Input::get('startDay'));
        $theEndDate = Carbon::create(Input::get('endYear'), Input::get('endMonth'), Input::get('endDay'));

        // dump($theStartDate);
        // dump($theEndDate);

    
//test pour savoir si la date de debut ou de fin sont inférieurs à la date courrante
        if($theStartDate < $currentDate  || $theEndDate < $currentDate ){
            dump('not ok');
        }else{
            dump('ok');
        }

//test pour savoir si la date de fin de mission est plus petit que la date de debut de mission
        if($theEndDate < $theStartDate){
            dump('impossible to have the enddate smallest than the startdate');
        } else{
            dump('perfect ! ');
        }
        

// test pour savoir la date de debut et de fin sont la meme
        if(!($theEndDate == $theStartDate)){
            dump('is not same date');
        }
        else{
            dump('');
        }

    dump($request);
        
    }

09 Jul
1 week ago

BrownieCoffee started a new conversation Retrieve Only The Values Option With PHP

Hi, there.

I need to your explainations for a problem what i'm trying to fix.

I did a post which noticed that I use select for days, months and years instead of input "date".

Is it possible to get the value of the select options ?

For example I want to get the value "2" and not the string option "Green".

<select id="select">

    <option value="1">Yellow</option>
    <option value="2">Green</option>    

</select>

Thank you by advance.

See you soon.

BrownieCoffee left a reply on Bad Incrementation Of Select Dropdown

Thank for your precisions. I use your code and the problem is that the values 30 and 31 not reappear. I stay with 1 to 29 values.

BrownieCoffee left a reply on Bad Incrementation Of Select Dropdown

thank you a lot. It's works . But I have another problem because If a selected another month after February, the dates stop to 30 value ... I don't know why. :/

BrownieCoffee started a new conversation Bad Incrementation Of Select Dropdown

Hello, there !

I want to create two select date with each a day, a month and a year select. I did my conditions with jquery like this when the selected month is "February" for one select, jquery remove in the date select 30 and 31 values of this select.

But it dosn't work properly because If , for example, a select April month on the first select and the December month of the last select, I have a clone of the values 30 and 31 in each select...

Can you help me please?

Thank you by advance And I hope my explaination is clear for you.

my jquery code

$(document).ready(function() {


    $("#startMonths").change(function(){

        if ($('#startMonths  option:selected').val() =="Fév."){
            $('#startDays option[value="30"], option[value="31"]').detach();
        }else{
            // $('#startDays option[value="30"], option[value="31"]').append();
            $('#startDays').append('<option value="30">30</option><option value="31">31</option>')
     
        }

    });
   

    $("#endMonths").change(function(){

        if ($('#endMonths  option:selected').val() =="Fév."){
            $('#endDays option[value="30"], option[value="31"]').detach();
        }else{
            $('#endDays').append('<option value="30">30</option><option value="31">31</option>')
        }

    });
});

my blade code

   <div class="row">
            <div class="form-group col-md-6">
                <label for="date-order">A quel date débute votre mission?</label>
                <div class="main__ad-start-date">
                    <select class="form-control" id="startDays">
                        @for ($startDay = 1; $startDay < 32; $startDay ++)
                            <option value="{{$startDay}}">{{$startDay}}</option>
                        @endfor
                    </select>
                    <select class="form-control" id="startMonths">
                        @foreach ($startMonths as $startMonth)
                            <option value="{{$startMonth}}">{{$startMonth}}</option>  
                        @endforeach
                    </select>
                    <select class="form-control" id="year">
                        @for ($startYear; $startYear <= $futureYears; $startYear++)
                            <option value="{{$startYear}}">{{$startYear}}</option>
                        @endfor
                    </select>
                </div>
            </div>
            <div class="main__check-add-end-date form-check">
                <label class="form-check-label"><input type="checkbox" class="form-check-input">Ajouter une
                    date de fin</label>
            </div>
            <hr>
            <div class="form-group col-md-6">
                <label for="date-order">Quand prend fin la mission ?</label>
                <div class="main__ad-end-date">
                    <select class="form-control" id="endDays">
                        @for ($endDay = 1; $endDay < 32; $endDay ++)
                            <option value="{{$endDay}}">{{$endDay}}</option>
                        @endfor
                    </select>
                    <select class="form-control" id="endMonths">
                        @foreach ($endMonths as $endMonth)
                        <option value="{{$endMonth}}">{{$endMonth}}</option>  
                    @endforeach
                    </select>
                    <select class="form-control" id="endYears">
                        @for ($endYear; $endYear <= $futureYears; $endYear++)
                        <option value="{{$endYear}}">{{$endYear}}</option>
                    @endfor
                    </select>
                </div>
            </div>
        </div>

07 Jul
2 weeks ago

BrownieCoffee started a new conversation Two Foreign Keys On A Same Model For My Migration

Hello here ! I try to create relations between a service_request and the services but I have some difficulties.

In my project, a service_request has

  • a request service

  • a needed service

  • a start date

  • a end date

My request migration

 public function up()
    {
        Schema::create('service_requests', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id');
            $table->unsignedBigInteger('needed_service_id');
            $table->unsignedBigInteger('provided_service_id');
            $table->unsignedBigInteger('start_date_id');
            $table->unsignedBigInteger('end_date_id')->nullable();
            $table->unsignedBigInteger('address_id');
            $table->mediumText('additionnal_informations');
            $table->timestamps();

            $table->foreign('user_id')
            ->references('id')->on('users');

            $table->foreign('needed_service_id')
            ->references('id')->on('services');

            $table->foreign('provided_service_id')
            ->references('id')->on('services');
            
            $table->foreign('start_date_id')
            ->references('id')->on('start_dates');

            $table->foreign('end_date_id')
            ->references('id')->on('end_dates');

            $table->foreign('address_id')
            ->references('id')->on('addresses');


        });
    }

my model Request.php

use Illuminate\Database\Eloquent\Model;

class Request extends Model
{

    protected $table = 'service_requests';

    protected $fillable = [
        'requested_service_id','needed_service_id', 'start_date_id', 'end_date_id', 'address_id', 'additionnal_informations'
    ];


    public function user(){
        return $this->belongsTo(User::class);
    }

    public function needed_service(){
        return $this->hasOne(Service::class);
    }

    public function provided_service(){
        return $this->hasOne(Service::class);
    }

    public function start_date(){
        return $this->hasOne(Date::class);
    }

    public function end_date(){
        return $this->hasOne(Date::class);
    }
    public function address(){
        return $this->hasOne(Address::class);
    }
}

my model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Service extends Model
{
    public function request(){

        return $this->belongsToMany(Request::class, 'requested_service_id', 'id');

        return $this->belongsToMany(Request::class, 'provided_service_id', 'id');
    }

}

is it okay like that ?

Thank you in advance for your replies :) !

See you !

01 Jul
3 weeks ago

BrownieCoffee left a reply on Edit: Regex For Email

@NASH - Hello, thanks for your reply. I was wrong. I would to check the domain of email like ".com", ".fr" .

BrownieCoffee started a new conversation FILTER_VALIDATE_EMAIL For Laravel

Hello guys!

I try to find an equivalent of " FILTER_VALIDATE_EMAIL " for Laravel to complete my validation.

  protected function validator(array $data)
    {
        return Validator::make($data, [
            'pseudo' => ['required', 'string','min:3', 'max:255', 'unique:users'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
            'password_confirmation' => ['required'],
        ]);
    }

Do you know how to do ?

Thank you a lot . Good bye !

BrownieCoffee left a reply on The Current User Is Not Authenticated PHPUnit

@mstrauss thank for your help, my auth works. I "install" laravel auth again :) .

Thank you so much!

BrownieCoffee left a reply on The Current User Is Not Authenticated PHPUnit

Thank guys for your messages but it doesn't work so I'll do anything else. Thank you for your patience ! :)

BrownieCoffee left a reply on The Current User Is Not Authenticated PHPUnit

@ROBSTAR - Hello Robstrar, I try your solution and i have this error

There was 1 error:

1) Tests\Feature\LoginTest::user_can_login_with_valid_fields
InvalidArgumentException: Unable to locate [active] state for [App\User].

/var/www/html/goshr/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:320
/var/www/html/goshr/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:278
/var/www/html/goshr/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:292
/var/www/html/goshr/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php:122
/var/www/html/goshr/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:300
/var/www/html/goshr/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:219
/var/www/html/goshr/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:178
/var/www/html/goshr/tests/Feature/LoginTest.php:44
/home/audrey/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:201
/home/audrey/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:160



BrownieCoffee left a reply on The Current User Is Not Authenticated PHPUnit

@mstrauss i did your suggestion but nothing happen.

I use own own authentification system.

BrownieCoffee left a reply on The Current User Is Not Authenticated PHPUnit

I add that here:

  public function user_can_login_with_empty_email(){

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

        
        $response = $this->post(route('connexion') , [
            'email' => '',
            'password' => $user->password,
        ]);

        $response->assertStatus(302)->assertSessionHasErrors('email');
        
        $this->withoutMiddleware()->assertGuest();
    }

But nothing :/ .

Perhaps I found the problem: in my AuthController, I added this line to have this error. Without this, email error doesn't display.

(adding of this line...)

throw ValidationException::withMessages([
            'email' => [trans('auth.failed')],
        ]);

(...in my AuthController)

public function postLogin(Request $request){
        
        /***
         * 
         * validations pour les champs.
         */
    
        $request->validate([
            'email' => 'required|email',
            'password' => 'required',
        ],
    );
        throw ValidationException::withMessages([
            'email' => [trans('auth.failed')],
        ]);

        $credentials = $request->only('email', 'password');

        if(Auth::attempt($credentials)){

            return redirect()->route('home');

        } else {
         return back();
        }
    }

If I remove the 'ValidationException', the error 'These credentials do not match our records.' doesn't show... I have a problem but I don't know that it is.

BrownieCoffee left a reply on The Current User Is Not Authenticated PHPUnit

Hello @mstrauss Yes I think

I use my own routes for authentification.

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


/*Sign-up Routes*/

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

Route::post('/inscription', '[email protected]');



/*Sign-in Routes*/



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

Route::post('/connexion', '[email protected]');



// /*Logout Route */

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

BrownieCoffee started a new conversation The Current User Is Not Authenticated PHPUnit

Hello guys, are are you?

Can you help me to fix this error please?

I try since 1 week to fix that but nothing yet.

I did test to know if a user can login

    public function user_can_login_with_valid_fields(){


        $user = factory(User::class, 1)->create([
            'password' => bcrypt('i-love-laravel'),
        ]);
    
       $response = $this->post(route('connexion'), [
            'email' => $user->email,
            'password' => 'i-love-laravel',
        ]);


        $response->assertRedirect(route('home'));

        $this->assertAuthenticatedAs($user);
     }


...but I have this error:

Time: 5.51 seconds, Memory: 24.00 MB

There was 1 failure:

1) Tests\Feature\LoginTest::user_can_login_with_valid_fields
The current user is not authenticated.
Failed asserting that null is not null.

/var/www/html/goshr/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php:89
/var/www/html/goshr/tests/Feature/LoginTest.php:53
/home/audrey/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:201
/home/audrey/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:160

I searched on the internet without find a solution. I hope you help me for that !

Thank you by advance and see you soon.

ps: sorry for my english.