almokhtar_br

almokhtar_br

somewhere in world

Hire Me

Member Since 8 Months Ago

Experience Points 510
Experience
Level
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

21 Aug
2 months ago

almokhtar_br left a reply on "Argument 2 Passed To App\Http\Controllers\LessonsController::update() Must Be An Instance Of App\Lesson, Instance Of App\Serie Given"

hahaha the error was because the order of arguments of update function in controller : so the fault way was :

    public function update(Lesson $lesson,Serie $serie,UpdateLessonRequest $request)
    {
        $lesson->update($request->all());
        return $lesson->fresh();
    }

And right way is :

    public function update(Serie $serie,Lesson $lesson,UpdateLessonRequest $request)
    {
        $lesson->update($request->all());
        return $lesson->fresh();
    }

almokhtar_br started a new conversation Heeelp

i get this error when put request with axios

{,…}
exception
:
"Symfony\Component\Debug\Exception\FatalThrowableError"
file
:
"/Volumes/HHD/#dev/laravel/udemy_clone/app/Http/Controllers/LessonsController.php"
line
:
72
message
:
"Argument 2 passed to App\Http\Controllers\LessonsController::update() must be an instance of App\Lesson, instance of App\Serie given"
trace
:
[{function: "update", class: "App\Http\Controllers\LessonsController", type: "->"}, {,…}, {,…}, {,…},…]

this is vue component :

<template>

<div class="modal fade" id="NewLessonModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        
    <div class="form-group">
            <input type="text" class="form-control" placeholder="title" v-model="title">
    </div>
    <div class="form-group">
        <textarea class="form-control"  placeholder="description" v-model="description"></textarea>
    </div>
    <div class="form-group">
            <input type="text" class="form-control" placeholder="video number" v-model="video_id">
    </div>
    <div class="form-group">
            <input type="text" class="form-control" placeholder="epsoide number" v-model="episode_number">
    </div>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-success" @click="updateLesson()" v-if="editing">update lesson</button>
        <button type="button" class="btn btn-primary" @click="CreateLesson()" v-else>add lesson</button>
      </div>
    </div>
  </div>
</div>

</template>
<script>

  import axios from 'axios'
    
  export default{

    data (){
      return{
            title : '',
            description : '',
            video_id : '',
            episode_number : '',
            serie_id : '',
            editing : false
      }
    },

    mounted (){
    
      this.$parent.$on('new_lesson',(serie_id)=>{

          this.editing = false 
          this.title = ''
          this.description = ''
          this.video_id = ''
          this.episode_number = ''
          this.serie_id = serie_id
          $('#NewLessonModal').modal()

      })

      this.$parent.$on('edit_lesson',({lesson,serieId})=>{
          
          this.editing = true 
          this.title = lesson.title
          this.description = lesson.description
          this.video_id = lesson.video_id
          this.episode_number = lesson.episode_number
          this.lessonId = lesson.id
          this.serieId = serieId
          $('#NewLessonModal').modal()
      })



    },

    methods :{

            CreateLesson() {
                axios.post(`/admin/${this.serie_id}/lessons`,{
                    title : this.title,
                    description : this.description,
                    video_id : this.video_id,
                    episode_number : this.episode_number,
                }).then(response => {
                  this.$parent.$emit('hasCreatedLesson',response.data)
                  $('#NewLessonModal').modal('hide')
                    this.title = ''
                    this.description = ''
                    this.video_id = ''
                    this.episode_number = ''
                    this.serie_id = ''

                }).catch(error=>{
                    console.log(error)
                })
            },

            updateLesson(){
              axios.put(`/admin/${this.serieId}/lessons/${this.lessonId}`,{
                  title : this.title,
                  description : this.description,
                  video_id : this.video_id,
                  episode_number : this.episode_number
              }).then(response => {
                console.log(response)
              }).catch(response=>{
                console.log(response)
              })
            },
        }

    }
</script>

and this is laravel code :

    public function update(UpdateLessonRequest $request, lesson $lesson,Serie $serie)
    {
        $lesson->update($request->all());
        return $lesson->fresh();
    }

09 Aug
3 months ago

almokhtar_br started a new conversation Did Any One Try Themosis With Valet Before ?

when i try to run themosis via valet it give me that : did any one face that before ?

☁  ~  valet which
PHP Fatal error:  Uncaught Error: Class ' ThemosisValetDriver.php ' not found in /Users/mbr/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php:77
Stack trace:
#0 /Users/mbr/.composer/vendor/laravel/valet/cli/valet.php(160): ValetDriver::assign('/Users/mbr', 'mbr', '/')
#1 [internal function]: Silly\Application->{closure}()
#2 /Users/mbr/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#3 /Users/mbr/.composer/vendor/mnapoli/silly/src/Application.php(95): Invoker\Invoker->call(Object(Closure), Array)
#4 /Users/mbr/.composer/vendor/symfony/console/Command/Command.php(249): Silly\Application->Silly\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /Users/mbr/.composer/vendor/symfony/console/Application.php(886): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Users/mbr/.composer/vendor/symfony/cons in /Users/mbr/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php on line 77

Fatal error: Uncaught Error: Class ' ThemosisValetDriver.php ' not found in /Users/mbr/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php:77
Stack trace:
#0 /Users/mbr/.composer/vendor/laravel/valet/cli/valet.php(160): ValetDriver::assign('/Users/mbr', 'mbr', '/')
#1 [internal function]: Silly\Application->{closure}()
#2 /Users/mbr/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#3 /Users/mbr/.composer/vendor/mnapoli/silly/src/Application.php(95): Invoker\Invoker->call(Object(Closure), Array)
#4 /Users/mbr/.composer/vendor/symfony/console/Command/Command.php(249): Silly\Application->Silly\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /Users/mbr/.composer/vendor/symfony/console/Application.php(886): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Users/mbr/.composer/vendor/symfony/cons in /Users/mbr/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php on line 77
☁  ~  valet which
PHP Fatal error:  Uncaught Error: Class ' ThemosisValetDriver.php ' not found in /Users/mbr/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php:77
Stack trace:
#0 /Users/mbr/.composer/vendor/laravel/valet/cli/valet.php(160): ValetDriver::assign('/Users/mbr', 'mbr', '/')
#1 [internal function]: Silly\Application->{closure}()
#2 /Users/mbr/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#3 /Users/mbr/.composer/vendor/mnapoli/silly/src/Application.php(95): Invoker\Invoker->call(Object(Closure), Array)
#4 /Users/mbr/.composer/vendor/symfony/console/Command/Command.php(249): Silly\Application->Silly\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /Users/mbr/.composer/vendor/symfony/console/Application.php(886): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Users/mbr/.composer/vendor/symfony/cons in /Users/mbr/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php on line 77

Fatal error: Uncaught Error: Class ' ThemosisValetDriver.php ' not found in /Users/mbr/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php:77
Stack trace:
#0 /Users/mbr/.composer/vendor/laravel/valet/cli/valet.php(160): ValetDriver::assign('/Users/mbr', 'mbr', '/')
#1 [internal function]: Silly\Application->{closure}()
#2 /Users/mbr/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#3 /Users/mbr/.composer/vendor/mnapoli/silly/src/Application.php(95): Invoker\Invoker->call(Object(Closure), Array)
#4 /Users/mbr/.composer/vendor/symfony/console/Command/Command.php(249): Silly\Application->Silly\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /Users/mbr/.composer/vendor/symfony/console/Application.php(886): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Users/mbr/.composer/vendor/symfony/cons in /Users/mbr/.composer/vendor/laravel/valet/cli/drivers/ValetDriver.php on line 77
07 Aug
3 months ago
06 Aug
3 months ago

almokhtar_br left a reply on Help Me With Vue.js (newbie)

Update: I must have needed to clear my browser cache... after not having app.js loading, and therefore binding to body, I am not getting that warning. I'm not sure if that brings me to a better understanding of the error message, but it's obvious that I at least need to start this over and check my facts.

thank you all

almokhtar_br left a reply on Laravel + Vue.js [Vue Warn]: Unknown Custom Element: <vue-lessons> - Did You Register The Component Correctly? For Recursive Components, Make Sure To Provide The "name" Option. (found In <Root>)

Update: I must have needed to clear my browser cache... after not having app.js loading, and therefore binding to body, I am not getting that warning. I'm not sure if that brings me to a better understanding of the error message, but it's obvious that I at least need to start this over and check my facts.

almokhtar_br started a new conversation Laravel + Vue.js [Vue Warn]: Unknown Custom Element: <vue-lessons> - Did You Register The Component Correctly? For Recursive Components, Make Sure To Provide The "name" Option. (found In <Root>)

this is my app.js :

require('./bootstrap');

window.Vue = require('vue');

Vue.component('vue-login', require('./components/loginModal.vue'));
Vue.component('vue-lessons',require('./components/lessons.vue'));

const app = new Vue({
    el: '#app'
});

and this is the component that give the error

<template>

</template>

<script>
    export default {
        name :"vue-lessons",
        props : ['lessons_to_props'],
        data (){
          return {
            lessons : this.lessons_to_props
          }
        }
    }
</script>

and this is the view :

@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">

                <div class="card">
                    <div class="card-body">

                        <h4 class="text-center">{{$serie->title }}</h4>

                    </div>
                </div>

            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body">

                        <vue-lessons lessons_to_props="{{$serie->lessons}}"></vue-lessons>

                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

almokhtar_br left a reply on Help Me With Vue.js (newbie)

@click yes it still the same error .

almokhtar_br left a reply on Help Me With Vue.js (newbie)

@tykus i' running js npm run watch

almokhtar_br started a new conversation Help Me With Vue.js (newbie)

i had add a new component and this error face me : (i'm new in view js )

[Vue warn]: Unknown custom element: <vue-lessons> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)

this is my app.js :



require('./bootstrap');

window.Vue = require('vue');

Vue.component('vue-login', require('./components/loginModal.vue'));
Vue.component('vue-lessons',require('./components/lessons.vue'));

const app = new Vue({
    el: '#app'
});

and this is the component that give the error

<template>

</template>

<script>
    export default {
        name :"vue-lessons",
        props : ['lessons_to_props'],
        data (){
          return {
            lessons : this.lessons_to_props
          }
        }
    }
</script>

and this is the view :

@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">

                <div class="card">
                    <div class="card-body">

                        <h4 class="text-center">{{$serie->title }}</h4>

                    </div>
                </div>

            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body">

                        <vue-lessons lessons_to_props="{{$serie->lessons}}"></vue-lessons>

                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection




17 Jul
4 months ago

almokhtar_br left a reply on Help Me With Testing

No it , the Post factory was missing , thank you again .

almokhtar_br left a reply on Help Me With Testing

yes exactly thank you .

almokhtar_br left a reply on Help Me With Testing

@xtremer360

<?php

use Faker\Generator as Faker;

$factory->define(App\Post::class, function (Faker $faker) {
    return [
        'title'=>$faker->sentence
    ];
});

almokhtar_br started a new conversation Help Me With Testing

Hi , guys i'm new in phpunit and i just learn it and this problem face me : InvalidArgumentException: Unable to locate factory with name [default] [App\Post]. this is my code :

        public function test_show_all_posts(){
            
            // arrangement
                $p1 = factory(Post::class)->create();
                $p2 = factory(Post::class)->create();
            // action
                $resp = $this->get('/posts');
            // assert
                $resp->assertStatus(200);
                $resp->assertSee($p1->title);
                $resp->assertSee($p2->title);
        }


02 May
6 months ago

almokhtar_br left a reply on Laravel MorphMany Returning Null Id

no it not misspelling !!

Replay {#749 ▼
  #fillable: array:4 [▼
    0 => "user_id"
    1 => "body"
    2 => "thread_id"
    3 => "id"
  ]
  #guarded: []
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
}

almokhtar_br left a reply on Laravel MorphMany Returning Null Id

no it not misspelling , something else

Replay {#749 ▼
  #fillable: array:4 [▼
    0 => "user_id"
    1 => "body"
    2 => "thread_id"
    3 => "id"
  ]
  #guarded: []
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
}

almokhtar_br started a new conversation Laravel MorphMany Returning Null Id

I'm trying to create Favorites for Replies, I have these models

App\Reply

public function favorites() { return $this->morphMany('App\Favorite', 'favorited'); } App\Favorite

public function favorited() { return $this->morphTo(); } Here is my DB table

public function up() { Schema::create('favorites', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned(); $table->integer('favorited_id')->unsigned(); $table->string('favorited_type', 50); $table->timestamps();

    $table->unique(['user_id', 'favorited_id', 'favorited_type']);
});

} When I try to create a new favorite like this:

public function store(Reply $reply){ $replay->favorites()->create(['user_id'=>Auth::id(),'favorited_id'=>$replay->id]);

return back();

} I get the error:

"SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'favorited_id' cannot be null (SQL: insert into favorites (user_id, favorited_id, `favorited_ ▶"

29 Apr
6 months ago

almokhtar_br left a reply on Where Are You All From?

from Morocco

21 Apr
6 months ago

almokhtar_br left a reply on Previous, Next Post

try this one :

public function single($slug){

    $post = Post::where('slug',$slug)->first();

    $previous_id = Post::where('id','<',$post->id)->max('id');
    $next_id = Post::where('id','>',$post->id)->min('id');

    $next = Post::find($next_id);
    $previous = Post::find($previous_id);


     return view('front-end.single',compact('post',$post))
         ->with('previous',$previous)
         ->with('next',$next);
}
15 Apr
7 months ago

almokhtar_br left a reply on Help !!! How I Can Keep The Image Uploaded In Edit Page

THANK YOU ALL , IT WORKING @Helmchen tank you too

almokhtar_br left a reply on Help !!! How I Can Keep The Image Uploaded In Edit Page

@Cronix i just add that accept="image/*" it ok now ?

almokhtar_br started a new conversation Help !!! How I Can Keep The Image Uploaded In Edit Page

   <div class="row">
                                <div class="col-3">
                                    <div class="c-field">
                                        <label for="">Image : </label>
                                        <input type="file" name="imagepath" value="{{ $post->image_path }}">
                                    </div>
                                </div>
                                <div class="col-9">
                                    <div class="uk-margin uk-grid-small uk-child-width-auto uk-grid">
                                        <label for="">Tags : </label>
                                    @foreach($tags as $tag)
                                    <label><input
                                            @foreach($post->tags as $t)
                                                    @if($tag->id == $t->id)
                                                    checked
                                                     @endif
                                             @endforeach
                                            class="uk-checkbox" type="checkbox" name="tag[]" value="{{ $tag->id }}"> {{ $tag->tag }} </label>
                                    @endforeach
                                    </div>
                                </div>
                            </div>