Slowhand

Slowhand

Member Since 2 Years Ago

Experience Points
6,410
Total
Experience

3,590 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
57
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
6,410 XP
Sep
17
1 month ago
Activity icon

Started a new Conversation Whoops! There Were Some Problems With Your Input.

Hi.

I'm trying to upload my laravel app from Bitbucket to Laravel Forge but it keeps sending me this strange error that I don not understand.

Whoops! There were some problems with your input.

Here's a screenshot : http://ih-pr.com/error.png

I have successfully added the SSH key.

Does anyone know what that means ?

Thank you all for your help

Jul
02
3 months ago
Activity icon

Replied to How To Show Active Bootstrap Accordion In A Laravel Foreach Loop?

No my friend.

I really am the owner of the application that I made myself from scratch. The only reason why I'm here is because I'm not an expert and I can't afford paying a developer.

But thanks anyway and have a nice day !

Activity icon

Replied to How To Show Active Bootstrap Accordion In A Laravel Foreach Loop?

@bobbybouwmann

Thanks for your suggestion, but I don't know where to use it on my code exactly...

I tried it, but no luck...

Thanks anyway

Activity icon

Replied to How To Show Active Bootstrap Accordion In A Laravel Foreach Loop?

@bobbybouwmann

I know I'm on the right page or course because the title of the course is shown on the header like this :

http://ih-pr.com/Alcenes_1ere_Partie.png

Also, the videos are the right ones. But now my Vimeo subscription is dead ;)

Activity icon

Replied to How To Show Active Bootstrap Accordion In A Laravel Foreach Loop?

Thanks @bobbybouwmann ! That was quick !

But I must admit that I'm a kind of noob and I don't know how to execute what you suggested...

I tried different things with the "show" class, but nothing worked.

Where should I insert this "show" word?

By the way, you helped me a lot before so thanks again !

Activity icon

Replied to How To Show Active Bootstrap Accordion In A Laravel Foreach Loop?

Thanks @bobbybouwmann

I already tried with class="collapse show", but it opens all the accordions at the same time.

Sorry if my english is not clear enought, but what I want to do here is to open only the active accordion related to the course tue user is watching so he knows where he is.

Thanks anyway

Jul
01
3 months ago
Activity icon

Replied to Where Are You All From?

Paris, France

Activity icon

Started a new Conversation How To Show Active Bootstrap Accordion In A Laravel Foreach Loop?

Dear all,

I'm trying to show active bootstrap accordion in a laravel foreach loop, but I'm facing an issue.

https://i.stack.imgur.com/l8GgV.jpg

What I'd like to do is what you see on the top image. But when I refresh the browser, the accordion closes as you can see on the bottom image.

Here's my code :

@foreach ($formation->sections as $section) @php $increment++; @endphp

Section {{ $increment }}: {{ $section->name }} {{ $section->courses->count() }} Vidéos Durée Totale

    @foreach ($section->courses as $course) @php $increment2++; @endphp
                    <li class="course-item-link">
                        <div class="course-item-content-wrap">
                            <div class="custom-checkbox">
                                <input type="checkbox" id="chb29">
                                <label for="chb29"></label>
                            </div>
                            <div class="course-item-content">
                                <h4
                                    class="widget-title font-size-15 font-weight-medium">
                                    {{ $increment2 }}.
                                    <a href="{{ route('student.course.chapitre',  [
                                        $formation->slug,
                                        'course' => $course->slug,
                                        'id' => $section->id,
                                    ]) }}">
    
                                        {{ $course->name }}
                                    </a>
                                </h4>
                                <div class="courser-item-meta-wrap">
                                    <p class="course-item-meta"><i
                                            class="la la-play-circle"></i>Durée</p>
                                    @if ($course->document)
                                    <div class="msg-action-dot">
                                        <div class="dropdown">
                                            <a class="theme-btn theme-btn-light"
                                                href="#" data-toggle="dropdown"
                                                aria-haspopup="true"
                                                aria-expanded="false">
                                                <i class="fa fa-folder-open mr-1"></i>
                                                Document<i
                                                    class="fa fa-angle-down ml-1"></i>
                                            </a>
                                        </div>
                                    </div>
                                    @else
    
                                    @endif
                                </div>
                            </div>
                        </div>
                    </li>
                    @endforeach
                </ul>
            </div>
        </div>
    </div>
    
    @endforeach

    Also, is there a way to make the li active?

    I tried different ways, but I failed.

    Thanks a lot !

Jun
28
4 months ago
Activity icon

Started a new Conversation Redirect After Login/Sign In E-commerce Checkout

Dear all,

I have a small app in wich a user can buy one or more courses.

For obvious reasons, I ask every user to log in or register before accessing the checkout page.

Route::group(['middleware' => ['auth']], function () { Route::get('/checkout', '[email protected]')->name('checkout.index'); Route::post('/checkout/charge', '[email protected]')->name('checkout.charge'); Route::get('/checkout/merci', '[email protected]')->name('checkout.thankyou'); });

The only problem is that when a user logs in, he's redirected to his dashboard as I specified in my LoginController (4 different roles) :

protected function redirectTo() { if (Auth::user()->roles->pluck('name')->contains('Admin')) { return '/admin/panel'; } elseif (Auth::user()->roles->pluck('name')->contains('Professeur')) { return '/teacher/panel'; } elseif (Auth::user()->roles->pluck('name')->contains('Responsable')) { return '/parent/panel'; } elseif (Auth::user()->roles->pluck('name')->contains('Étudiant')) { return '/student/panel'; } }

RegisterController :

protected function create(array $data) { $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]);

    $role = Role::select('id')->where('name', 'Responsable')->first();

    $user->roles()->attach($role);

    return $user;

}

What I would like is the user to be redirected to the checkout page right after logging in or registering and I really don't know how to do that...

Here's my CheckoutController :

public function charge(Request $request) { \Stripe\Stripe::setApiKey(env('STRIPE_PRIVATE_KEY'));

    try {
        $charge = \Stripe\Charge::create([
            'amount' => Cart::total() * 100,
            'currency' => 'EUR',
            'description' => 'Paiement Via la plateforme Cours Thalès',
            'source' => $request->input('stripeToken'),
            // 'receipt_email' => Auth::user()->email

        ]);

        foreach (Cart::content() as $item) {
            Payment::create([
                'formation_id' => $item->model->id,
                'amount' => $item->model->price,
                'email' => Auth::user()->email
            ]);
        }

        session()->flush();

        return redirect()->route('checkout.thankyou')->with('success', 'Paiement accepté');

    } catch (\Stripe\Exception\CardErrorException $error) {
        throw $error;
    }
}

Thank you all !

May
25
5 months ago
Activity icon

Replied to Get Total (video Durations) With GetID3

Thanks for your answers. I'll try this asap.

Activity icon

Replied to Get Total (video Durations) With GetID3

Thanks TRAY2.

Same question I asked tykus : How to use Collection sum?

I'm not a Laravel expert...

Thank you !

Activity icon

Replied to Get Total (video Durations) With GetID3

Thanks Tykys.

The values are stored in the database in a table called Course.

Can you please explain me how to use the Collection sum?

It would be very helpfull !

Thank you

Activity icon

Started a new Conversation Get Total (video Durations) With GetID3

Dear all,

I am building a Laravel app in which I upload videos.

To recover the duration of each video, I use the following package which is very good: https://github.com/JamesHeinrich/getID3/

Where I need help is to get the total duration of all the videos and I have no idea how to handle this.

Here is an image that illustrates my research:

https://i.stack.imgur.com/XzSKP.png

public function getVideoDuration($Videofile) { $getID3 = new \getID3(); $pathVideo = 'storage/chapitres-videos/' . Auth::user()->id . '/' . $Videofile; $fileAnalyze = $getID3->analyze($pathVideo); $playtime = $fileAnalyze['playtime_string'];

    return $playtime;
}

$Videofile = $this->videoManager->videoStorage($request->file('video')); $lecture->video = $Videofile;

Thank you all and have a nice day!

May
10
5 months ago
Activity icon

Replied to Attach And Sync Issues

@bobbybouwmann

Awesome ! Thank you very much !

One last question if you don't mind :

How can I get the old values in my create page ? (let's say I forget to add a field and I get an error).

Thank you !

Activity icon

Replied to Attach And Sync Issues

Hi again bobby.

No problem in the create page with this code thanks to your previous message :

Matières @foreach ($disciplines as $discipline) {{ $discipline->title }} @endforeach

Everything works and the db is populated.

In the update page I have this code :

                                    <div class="col-lg-7">
                                        <label class="col-sm-12 col-form-label">Matières</label>
                                        <select name="disciplines[]"  class="select2 form-control @error('disciplines') is-invalid @enderror" type="text select2-multiple" multiple="multiple"
                                            data-placeholder="Choisir une formation ..." required>
                                            @foreach($disciplines as $id => $discipline)
                                                <option value="{{ $discipline->id,  }}"  @if ($disciplines->contains($discipline->id, )) selected @endif>{{ $discipline->title }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

The problem here is that I see all the Matières options and I would like to see the ones I selected when I create a course.

I don't know if I'm clear enough, english is not my first language (I'm french...).

Thanks again !

Activity icon

Replied to Attach And Sync Issues

Thank you bobbybouwmann !

It works great.

However, I don't see the old values in my update file and I would like to use select2 instead of checkboxes.

Any idea ?

But at least, I don't see any errors now and my db is populated. Thanks for that !

May
09
5 months ago
Activity icon

Started a new Conversation Attach And Sync Issues

Hi all.

I hope you're all good and safe wherever you are. In France, we're like in The Walking Dead series !

I'm making a small school management app with Laravel.

I have a many to many relationship between my table Courses and my table Disciplines (a course can have many disciplines).

Using Select2 JS, I can easily select my disciplines in my create blade view, but when I select one or many disciplines, different ones are shown in my show blade page.

Heres an example :

If I choose "Matière 3 and Matière 4", it shows me Matière 1 and Matière 2 in my index page.

https://i.stack.imgur.com/hCDEO.png

https://i.stack.imgur.com/Hxzxn.png

If I choose Matière 1 (with Id 1) I get this error :

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (elearning.course_discipline, CONSTRAINT course_discipline_discipline_id_foreign FOREIGN KEY (discipline_id) REFERENCES disciplines (id) ON DELETE CASCADE) (SQL: insert into course_discipline (course_id, discipline_id) values (9, 0), (9, 1))

Here's my controller

public function createCourse(Request $request) { $request->validate([ 'title' => 'required|string', 'slug' => 'required|string', 'status' => 'required|integer', 'formation_id' => 'required|integer', 'description' => 'required', 'price' => 'required', 'video_prev' => 'required',

]);

$course = new Course();
$course->title = $request['title'];
$course->slug = $request['slug'];
$course->status = $request['status'];
$course->formation_id = $request['formation_id'];
$course->description = $request['description'];
$course->price = $request['price'];
$course->video_prev = $request['video_prev'];
$course->user_id = Auth::id();


$course->save();

$course->disciplines()->attach(request('disciplines'));

return redirect(route('adminCourses'))->with('success', 'Le cours a bien été crée');

}

public function editCourse($id) { $course = Course::findOrFail($id); $disciplines = Discipline::all(); $formations = Formation::all();

return view('admin.cours.editCourse', compact('course',  'disciplines', 'formations'));

}

public function editCoursePost(Request $request, $id) {

$request->validate([
    'title' => 'required|string',
    'slug' => 'required|string',
    'status' => 'required|string',
    'formation_id' => 'required|string',
    'description' => 'required',
    'price' => 'required',
    'video_prev' => 'required',

]);

$course = Course::findOrFail($id);

$course->title = $request['title'];
$course->slug = $request['slug'];
$course->status = $request['status'];
$course->formation_id = $request['formation_id'];
$course->description = $request['description'];
$course->video_prev = $request['video_prev'];
$course->price = $request['price'];


$course->save();

$course->disciplines()->sync($request->input('disciplines', []));


return redirect(route('adminCourses'))->with('success', "Le cours a bien été mis à jour");

}

My HTML Code for creating, updating and index :

Create :

I hope you're all good and safe wherever you are. In France, we're like in The Walking Dead series !

I'm making a small school management app with Laravel.

I have a many to many relationship between my table Courses and my table Disciplines (a course can have many disciplines).

Using Select2 JS, I can easily select my disciplines in my create blade view, but when I select one or many disciplines, different ones are shown in my show blade page.

Heres an example :

If I choose "Matière 3 and Matière 4", it shows me Matière 1 and Matière 2 in my index page.

enter image description here

enter image description here

If I choose Matie 1 (with Id 1) I get this error :

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (elearning.course_discipline, CONSTRAINT course_discipline_discipline_id_foreign FOREIGN KEY (discipline_id) REFERENCES disciplines (id) ON DELETE CASCADE) (SQL: insert into course_discipline (course_id, discipline_id) values (9, 0), (9, 1))

Here's my controller

public function createCourse(Request $request) { $request->validate([ 'title' => 'required|string', 'slug' => 'required|string', 'status' => 'required|integer', 'formation_id' => 'required|integer', 'description' => 'required', 'price' => 'required', 'video_prev' => 'required',

]);

$course = new Course();
$course->title = $request['title'];
$course->slug = $request['slug'];
$course->status = $request['status'];
$course->formation_id = $request['formation_id'];
$course->description = $request['description'];
$course->price = $request['price'];
$course->video_prev = $request['video_prev'];
$course->user_id = Auth::id();


$course->save();

$course->disciplines()->attach(request('disciplines'));

return redirect(route('adminCourses'))->with('success', 'Le cours a bien été crée');

}

public function editCourse($id) { $course = Course::findOrFail($id); $disciplines = Discipline::all(); $formations = Formation::all();

return view('admin.cours.editCourse', compact('course',  'disciplines', 'formations'));

}

public function editCoursePost(Request $request, $id) {

$request->validate([
    'title' => 'required|string',
    'slug' => 'required|string',
    'status' => 'required|string',
    'formation_id' => 'required|string',
    'description' => 'required',
    'price' => 'required',
    'video_prev' => 'required',

]);

$course = Course::findOrFail($id);

$course->title = $request['title'];
$course->slug = $request['slug'];
$course->status = $request['status'];
$course->formation_id = $request['formation_id'];
$course->description = $request['description'];
$course->video_prev = $request['video_prev'];
$course->price = $request['price'];


$course->save();

$course->disciplines()->sync($request->input('disciplines', []));


return redirect(route('adminCourses'))->with('success', "Le cours a bien été mis à jour");

} My HTML Code for creating, updating and index :

Create :

Matières @foreach($disciplines as $id => $discipline) {{ $discipline->title }} @endforeach

Update :

$discipline) disciplines->contains($id)) ? 'selected' : '' }}>{{ $discipline->title }} @endforeach

Index :

@foreach ($course->disciplines as $discipline) {{ $discipline->title }} @endforeach

So now, I'm stuck...

Thank you everyone and stay safe !

May
06
5 months ago
Activity icon

Started a new Conversation Update Multiple Fields In Laravel Edit View

Hi Everyone

I'm buliding a school management system with Laravel and I'm trying to update a form with multiple values.

I use Select2 js witch is fine when I create a course. I can see all my categories and i can save them in the databse.

The problem is that I don't see these categories when I try to update the course in the edit file.

Since I'm not Laravel expert, I really don't know what to insert in my update methode in the controller and same in my update form.

This is my controller :

I'm buliding a school management system with Laravel and I'm trying to update a form with multiple values.

I use Select2 js witch is fine when I create a course. I can see all my categories and i can save them in the databse.

The problem is that I don't see these categories when I try to update the course in the edit file as shown in the image below :

enter image description here

Since I'm quite new to Laravel, I really don't know what to insert in my update methode in the controller and same in my update form.

This is my controller :

public function update(Request $request, $id) {

$request->validate([
    'title' => 'required|string',
    'slug' => 'required|string',
    'status' => 'required|string',
    'description' => 'required',
    'price' => 'required',
    'video_prev' => 'required',

]);

$course = Course::findOrFail($id);

$course->title = $request['title'];
$course->slug = $request['slug'];
$course->status = $request['status'];
$course->description = $request['description'];
$course->video_prev = $request['video_prev'];
$course->price = $request['price'];

$course->save();

$course->categories()->attach(request('categories'));

return redirect(route('adminCourses'))->with('success', "Le cours a bien été mis à jour");

}

My Models :

public function courses() { return $this->belongsToMany('App\Course'); }

public function categories() { return $this->belongsToMany('App\Category'); }

The html in my edit view :

Formations @foreach ($categories as $category) category_id === $course->id ? 'selected' : '' }} selected="selected">{{ $category->title }} @endforeach

The only thing this code returns is the list of all categories, but it's not what I want. I want to see the categories I selected and I created the course and more important, I would like to be able to change theme. So far when I try to insert a new category, it's just added to the old ones..

Thank you very much !