afghany

afghany

cairo

Member Since 6 Months Ago

Experience Points 820
Experience
Level
Lessons Completed 2
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.

01 Nov
1 week ago

afghany left a reply on Can't Use Moment With Vue.js

@D9705996 not working too !

afghany left a reply on Can't Use Moment With Vue.js

@martinbean it's not working too -_-

afghany started a new conversation Can't Use Moment With Vue.js

i am trying to use moment with vue.js at laravel project and i installed moment by npm "npm install moment --save" and here is my bootstrap.js :

window.moment = require('moment');

and here is what i am trying to do 'inside vue component template' : {{window.moment(notification.created_at).formNow()}}

i got this error [Vue warn]: Property or method "window" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

[Vue warn]: Error in render: "TypeError: Cannot read property 'moment' of undefined"

found in

---> at resources/js/components/Notifications.vue

when try to use it from browser console it's working !

30 Oct
2 weeks ago

afghany started a new conversation Npm Watcher Not Working

after run my script "npm run watch" it's compile down all file but after any changes in files it's not compile it down again i mean it's work once not working after files changes

21 Oct
3 weeks ago

afghany left a reply on Laravel Echo Not Listen On Presence Channels With Pusher

i figure out what's the problem i was return a boolean at my channels.php file and it's the problem

afghany started a new conversation Laravel Echo Not Listen On Presence Channels With Pusher

i am broadcast on Presence Channel but it's not working with laravel-echo but i got the api message on pusher but i can't got it with laravel echo at client side and it's work with public channel every thing working correctly anyone can help me to figure out what's wrong ? here is my code blade file : @extends('layouts.app')

section('content')

        <chat-room></chat-room>

@endsection

vue component :

  <div class="container">

        <div class="row">

         <div class="col-md-12">

                <div class="panel panel-default mx-auto">

                   <div class="panel-heading text-center">

                     <span class="glyphicon glyphicon-comment"></span> Chat Room

                     <span class="pull-right glyphicon glyphicon-trash" title="Delete All Messages"             @click="truncate"></span>
                     </div>

                    <div class="panel-body">

                       <p v-for="message in messages"> {{message.user.name}} : {{message.body}}     </p>

                  </div>

                 <div class="panel-footer">

                       <input type="text" v-model="body" class="form-control" placeholder="Your     Message...">

                        <!--<span v-show="activeUser">{{activeUser.name}} is typing...</span>-->

                        <button class="btn btn-success btn-block mt-3" @click="save">Send</button>

                    </div>

                </div>

         </div>

       </div>

 </div>

</template>

<script>

    export default {

        data() {
            return {
                messages: [],
                body: '',
            }
        },
        methods :{
            truncate(){
                axios.delete('/messages').then(this.messages = []);
            },
            save(){
                axios.post('/messages',{body : this.body , user_id : app.user.id}).then(response =>     this.messages.push(response.data));
                this.body = '';
            }
        },
        computed: {
            channel() {
                return Echo.join('Messages');
            },
        },
        mounted() {
            axios.get('/messages').then(response => this.messages = response.data);

            this.channel.listen('NewMessage', (e) => {
                this.messages.push(e.message);
            });
        }
    }

</script>

and here is web.php file

Route::get('messages',function (){

   return Message::all()->load('user');

});

Route::post('messages',function (){

    $message = Message::create(request(['body','user_id']));

    NewMessage::dispatch($message->load('user'));

    return $message->load('user');
});

Route::delete('messages',function (){

    Message::truncate();

});

here is my event :

class NewMessage implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

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

        $this->dontBroadcastToCurrentUser();
    }

    public function broadcastOn()
    {
        return new PresenceChannel('Messages');
    }
}
09 Sep
2 months ago

afghany left a reply on Issue With Accessing Data From My Component

@bobbybouwmann editFields passed to parent component and parent component pass it to child as well

08 Sep
2 months ago

afghany started a new conversation Issue With Accessing Data From My Component

i am passing data to my component and all data assigned to my component correctly "i checked it at vue dev tool it's assigned correctly" but when i am try to access the id attribute from specific component it's return latest component id attribute not the current component attribute

parent component code :

        <tr v-for="object in data">

            <td v-for="field in fields">{{object[field.includes(' ') ? field.replace(' ','_') : field]}}</td>

            <td v-if="Actions">

                <a v-for="action in Object.keys(Actions)"
                   
                   @click.prevent="determineAction(action,object[Key])"
                   
                   :href="getActionURI(object[Key],action)"
                   
                   :class="getBtnClass(action)">
                    
                    {{action}}
                
                </a>

            </td>

            <edit-modal v-show="displayEditModal" @EditModalClose="hideEditMoodal()"                             
             :data="object" :fields="editFields"></edit-modal>

        </tr>

here is the child component code :

    <section class="modal-card-body">
    
      <form>

            <div class="form-group" v-for="(field,index) in fields">
            
                <label>
                        
                        {{index}}

                        <input :type="field" class="form-control" :placeholder="'Please enter ' + index"     
                               :value="data[index]" @input="index = $event.target.value">

                </label>
           
            </div>                

      </form>
    
    </section>
    
    <footer class="modal-card-foot">
      
        <button class="btn btn-success btn-block" @click="update">Update</button>
    
        
    </footer>
    


<script>

    export default{
        props:{
            data: {
                type: Object,
                required : true
            },
            fields: {
                type: Object,
                required : false
            }
        },
        data(){
            let temp = {};
            for(let field in this.fields){

                temp[field] = this.data[field.includes(' ') ? field.replace(' ','_') : field];
            }
            return temp;
        },
        methods:{
            fireEvent(eventName,data = null){
                window.Events.fire(eventName,data);
            },
            update(){
                console.log(this.data.id);
            }
        }
    }

</script>
20 Aug
2 months ago

afghany left a reply on Can't Make Phpunit Configurations To Work With DatabaseMigrations Trait

thanks guys it's solved by re-install laravel .

19 Aug
2 months ago

afghany left a reply on Can't Make Phpunit Configurations To Work With DatabaseMigrations Trait

@Krisell i am not make any changes in config/database.php

afghany started a new conversation Can't Make Phpunit Configurations To Work With DatabaseMigrations Trait

here is my phpunit.xml file :

<?xml version="1.0" encoding="UTF-8"?>

./tests/Feature

    <testsuite name="Unit">
        <directory suffix="Test.php">./tests/Unit</directory>
    </testsuite>
</testsuites>
<filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">./app</directory>
    </whitelist>
</filter>
<php>
    <env name="APP_ENV" value="testing"/>
    <env name="DB_CONNECTION" value="sqlite"/>
    <env name="DB_DATABASE" value=":memory:"/>
    <env name="CACHE_DRIVER" value="array"/>
    <env name="SESSION_DRIVER" value="array"/>
    <env name="QUEUE_DRIVER" value="sync"/>
</php>

here is my testclass :

<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\DatabaseMigrations; use Tests\TestCase;

class OrdersTest extends TestCase { use DatabaseMigrations;

/** @test */

public function foobar()
{
    $this->assertTrue(true);
}

}

and i have database.sqlite file at database directory

when i run the test it's refresh my main database "mysql"

10 Jul
4 months ago

afghany left a reply on I Have Problem With Eager Load Laravel

thanks guys for help

i got the solution

that what fix it

public function item() { return $this->hasOne(ProductItem::class, 'id','product_item_id'); }

public function product()
{
    return $this->hasOne(Product::class, 'id','product_id');
}

public function order()
{
    return $this->hasOne(Order::class, 'id','order_id');
}

by adding the localkey as third parameter .

afghany left a reply on I Have Problem With Eager Load Laravel

@lostdreamer_nl

i got this too , same problem i lose the item object #relations: array:3 [▼ "order" => Order {#1156 ▶} "item" => null "product" => Product {#1337 ▶} ], #relations: array:3 [▼ "order" => Order {#1156 ▶} "item" => null "product" => Product {#1338 ▶} ]

afghany left a reply on I Have Problem With Eager Load Laravel

@staudenmeir who order_item model belongsTo ProductItem ! ProductItem only belongsTo Product

afghany started a new conversation I Have Problem With Eager Load Laravel

hey guys .. i got a problem with eager load while fetching data from my model i eager load 3 relations , to understand the problem here is the migration from my model i fetch from it

$table->increments('id'); $table->unsignedInteger('order_id'); $table->unsignedInteger('product_item_id'); $table->unsignedInteger('product_id'); $table->integer('days'); $table->foreign('order_id')

            ->references('id')

            ->on('orders')

            ->onDelete('cascade');
        $table->foreign('product_item_id')

            ->references('id')

            ->on('product_items')

            ->onDelete('cascade');
        $table->foreign('product_id')

            ->references('id')

            ->on('products')

            ->onDelete('cascade');
        $table->timestamps();

and here the model contains the relation and eager load attribute

protected $with = ['order', 'item', 'product'];

public function item()
{
    return $this->hasOne(ProductItem::class, 'id');
}

public function product()
{
    return $this->hasOne(Product::class, 'id');
}

public function order()
{
    return $this->hasOne(Order::class, 'id');
}

when i am try to fetch my data from this model here the response i got "i will ignore un-important attributes from object"

Collection {#1478 ▼ #items: array:2 [▼ 0 => OrderItem {#1071 ▼ #guarded: [] #with: array:3 [▼ 0 => "order" 1 => "item" 2 => "product" ] #attributes: array:7 [▼ "id" => 1 "order_id" => 1 "product_item_id" => 1 "product_id" => 1 "days" => 0 "created_at" => "2018-07-10 08:15:02" "updated_at" => "2018-07-10 08:15:02" ] #original: array:7 [▶] #relations: array:3 [▼ "order" => Order {#1166 ▶} "item" => ProductItem {#1265 ▶} "product" => Product {#1366 ▶} ] }

1 => OrderItem {#1072 ▼
  #guarded: []
  #with: array:3 [▶]
  #attributes: array:7 [▼
    "id" => 21
    "order_id" => 1
    "product_item_id" => 15
    "product_id" => 4
    "days" => 0
    "created_at" => "2018-07-10 12:44:32"
    "updated_at" => "2018-07-10 12:44:32"
  ]
  #original: array:7 [▶]
  #relations: array:3 [▼
    "order" => null
    "item" => null
    "product" => null
  ]

}

] }

i am sure my foreign keys values are assigned correctly 100%

the problem is .. in first object in response i got my eager load correctly but second object it's return null !! while there is product have id 4 and product_item have id 15 !! anyone can help to know what's going on ?

06 Jul
4 months ago

afghany left a reply on Composer Error

@Cronix okay thanks for your help :)

afghany left a reply on Composer Error

@Snapey can u be specific , what i should change in php.ini ?

afghany started a new conversation Composer Error

i cloned my project on other machine and while i am trying execute "composer install" to download my dependencies i got this error :

Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Your requirements could not be resolved to an installable set of packages.

Problem 1 - Installation request for automattic/woocommerce 1.3.0 -> satisfiable by automattic/woocommerce[1.3.0]. - automattic/woocommerce 1.3.0 requires ext-curl * -> the requested PHP extension curl is missing from your system. Problem 2 - Installation request for erusev/parsedown 1.7.1 -> satisfiable by erusev/parsedown[1.7.1]. - erusev/parsedown 1.7.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system. Problem 3 - Installation request for laravel/framework v5.6.26 -> satisfiable by laravel/framework[v5.6.26]. - laravel/framework v5.6.26 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system. Problem 4 - Installation request for phar-io/manifest 1.0.1 -> satisfiable by phar-io/manifest[1.0.1]. - phar-io/manifest 1.0.1 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 5 - Installation request for phpunit/php-code-coverage 6.0.7 -> satisfiable by phpunit/php-code-coverage[6.0.7]. - phpunit/php-code-coverage 6.0.7 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 6 - Installation request for phpunit/phpunit 7.2.6 -> satisfiable by phpunit/phpunit[7.2.6]. - phpunit/phpunit 7.2.6 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 7 - Installation request for theseer/tokenizer 1.1.0 -> satisfiable by theseer/tokenizer[1.1.0]. - theseer/tokenizer 1.1.0 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 8 - automattic/woocommerce 1.3.0 requires ext-curl * -> the requested PHP extension curl is missing from your system. - pixelpeter/laravel5-woocommerce-api-client v3.0.1 requires automattic/woocommerce 1.3.* -> satisfiable by automattic/woocommerce[1.3.0]. - Installation request for pixelpeter/laravel5-woocommerce-api-client v3.0.1 -> satisfiable by pixelpeter/laravel5-woocommerce-api-client[v3.0.1].

To enable extensions, verify that they are enabled in those .ini files: - /etc/php/7.2/cli/php.ini - /etc/php/7.2/cli/conf.d/10-opcache.ini - /etc/php/7.2/cli/conf.d/10-pdo.ini - /etc/php/7.2/cli/conf.d/20-calendar.ini - /etc/php/7.2/cli/conf.d/20-ctype.ini - /etc/php/7.2/cli/conf.d/20-exif.ini - /etc/php/7.2/cli/conf.d/20-fileinfo.ini - /etc/php/7.2/cli/conf.d/20-ftp.ini - /etc/php/7.2/cli/conf.d/20-gettext.ini - /etc/php/7.2/cli/conf.d/20-iconv.ini - /etc/php/7.2/cli/conf.d/20-json.ini - /etc/php/7.2/cli/conf.d/20-phar.ini - /etc/php/7.2/cli/conf.d/20-posix.ini - /etc/php/7.2/cli/conf.d/20-readline.ini - /etc/php/7.2/cli/conf.d/20-shmop.ini - /etc/php/7.2/cli/conf.d/20-sockets.ini - /etc/php/7.2/cli/conf.d/20-sysvmsg.ini - /etc/php/7.2/cli/conf.d/20-sysvsem.ini - /etc/php/7.2/cli/conf.d/20-sysvshm.ini - /etc/php/7.2/cli/conf.d/20-tokenizer.ini You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.

22 Apr
6 months ago

afghany left a reply on Got This Error "htmlspecialchars() Expects Parameter 1 To Be String, Object Given" When I Try To Json_decode In Blade File

@Vilfago same error ...

Can't var_dump $before cuz there is a error "htmlspecialchars() expects parameter 1 to be string, array given"

here is the var_dump for $modify

object(App\modifyHistory)#479 (25) { ["guarded":protected]=> array(0) { } ["connection":protected]=> string(5) "mysql" ["table":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(8) { ["id"]=> int(8) ["user_id"]=> int(91) ["modified_id"]=> int(6) ["modified_type"]=> string(10) "App\Thread" ["before"]=> string(48) "{"slug":"one-more-try-6","title":"one more try"}" ["after"]=> string(50) "{"slug":"one-more-try2-6","title":"one more try2"}" ["created_at"]=> string(19) "2018-04-17 14:45:06" ["updated_at"]=> string(19) "2018-04-17 14:45:06" } ["original":protected]=> array(8) { ["id"]=> int(8) ["user_id"]=> int(91) ["modified_id"]=> int(6) ["modified_type"]=> string(10) "App\Thread" ["before"]=> string(48) "{"slug":"one-more-try-6","title":"one more try"}" ["after"]=> string(50) "{"slug":"one-more-try2-6","title":"one more try2"}" ["created_at"]=> string(19) "2018-04-17 14:45:06" ["updated_at"]=> string(19) "2018-04-17 14:45:06" } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["events":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["fillable":protected]=> array(0) { } }

20 Apr
6 months ago

afghany left a reply on Got This Error "htmlspecialchars() Expects Parameter 1 To Be String, Object Given" When I Try To Json_decode In Blade File

The problem with json_decode function Without using it there is no errors but it's string not array

afghany left a reply on Got This Error "htmlspecialchars() Expects Parameter 1 To Be String, Object Given" When I Try To Json_decode In Blade File

@Snapey before attribute saved as string can't fetch the title until i decode it , And when i use json_decode i got this error

afghany left a reply on Got This Error "htmlspecialchars() Expects Parameter 1 To Be String, Object Given" When I Try To Json_decode In Blade File

@Vilfago I fetch my 8 attrributes my before and after attribute saved as string i need to decode them and when i decode i got this error

18 Apr
6 months ago

afghany left a reply on Got This Error "htmlspecialchars() Expects Parameter 1 To Be String, Object Given" When I Try To Json_decode In Blade File

@jcmargentina Modify is a object contains my attributes Two of them "before " , "after" in this format I am tring to json_decode them

"before" => "{"slug":"one-more-try-6","title":"one more try"}" "after" => "{"slug":"one-more-try2-6","title":"one more try2"}"

17 Apr
6 months ago

afghany started a new conversation Got This Error "htmlspecialchars() Expects Parameter 1 To Be String, Object Given" When I Try To Json_decode In Blade File

here is my response

Collection {#478 ▼ #items: array:5 [▼ 0 => modifyHistory {#479 ▼ #guarded: [] #connection: "mysql" #table: null #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: true +wasRecentlyCreated: false #attributes: array:8 [▼ "id" => 8 "user_id" => 91 "modified_id" => 6 "modified_type" => "App\Thread" "before" => "{"slug":"one-more-try-6","title":"one more try"}" "after" => "{"slug":"one-more-try2-6","title":"one more try2"}" "created_at" => "2018-04-17 14:45:06" "updated_at" => "2018-04-17 14:45:06" ] #original: array:8 [▶] #casts: [] #dates: [] #dateFormat: null #appends: [] #events: [] #observables: [] #relations: [] #touches: [] +timestamps: true #hidden: [] #visible: [] #fillable: [] } 1 => modifyHistory {#480 ▶} 2 => modifyHistory {#481 ▶} 3 => modifyHistory {#482 ▶} 4 => modifyHistory {#483 ▶} ] }

and here is my blade code

@forelse($history as $key => $modify)

                            <li class="list-group-item">

                                <div class="level">

                                    <tr>

                                        <td> {{json_decode($modify->before)}} </td>


                                    </tr>


                                </div>

                            </li>

                        @empty

                            <strong>There is no updates for this thread </strong>

                        @endforelse