MostafaGamal

Member Since 2 Years Ago

Cairo

Experience Points
34,040
Total
Experience

960 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
244
Lessons
Completed
Best Reply Awards
14
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.

  • Community Pillar

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

Level 7
34,040 XP
Mar
21
3 weeks ago
Activity icon

Awarded Best Reply on Showing 404 Even That The Route Is Already Exists

@ammargomaa select your answer as best reply

I've solved the problem it was a typo, thanks anyway.

Activity icon

Replied to Arr::keys Arr::flip Error: Method Does Not Exist

@spook1 yes, you can use collection methods instead of Arr::method . I don't know if Arr:: methods were exist in old versions of laravel or not but in laravel 8 collection methods will solve your problem.

Activity icon

Replied to Showing 404 Even That The Route Is Already Exists

@ammargomaa select your answer as best reply

I've solved the problem it was a typo, thanks anyway.

Activity icon

Replied to Remember Me On Log In?

@panthro Glad, it makes sense for you. please, mark it as a solved thread.

Activity icon

Replied to Remember Me On Log In?

if you don't check remember me then you will be logged out only when your session expired even if you closed your browser. Since you close your browser but your session lifetime did not expire yet, you still logged in even if you closed your browser.

You can configure your session lifetime from SESSION_LIFETIME in .env file.

remember me keep the user authenticated until they are manually logout. It will be valid if you closed your browser or your session expired then you will be logged in automatically without the need to enter your credentials again.

is remember me function clear to you now?

Activity icon

Replied to Display PAGINATION GroupBy In BLADE View

@batotanete Please, Mark the thread as solved.

Activity icon

Replied to Use Middleware On Fortify Login And Register Routes

@hybride After a long time writing my answer and after I submitted it I discovered that you found the solution :D

Please post your solution. I believe that your solution will be more simple :).

Activity icon

Replied to Use Middleware On Fortify Login And Register Routes

Too many steps which are hard to follow:

Open you vendor\laravel\fortify\src\FortifyServiceProvider.php in which you will find method configureRoutes.

Grap method configureRoutes and paste it inside app\Providers\FortifyServiceProvider.php

Add Fortify::ignoreRoutes() to register() method.

Also add $this->configureRoutes() at the end of boot method.

get rid of the condition inside the configureRoutes method:

// get rid of the following condition. Just keep the code inside this condition
if (Fortify::$registersRoutes) {
           
 }

copy the code inside vendor\laravel\fortify\routes\routes.php and paste it inside new created file routes\fortify.php

Then inside app\Providers\FortifyServiceProvider.php update the configureRoutes() method and replace $this->loadRoutesFrom(__DIR__.'/../routes/routes.php') with $this->loadRoutesFrom(base_path('routes/fortify.php'))

So your app\Providers\FortifyServiceProvider.php will be like this:

<?php

namespace App\Providers;

use App\Actions\Fortify\CreateNewUser;
use App\Actions\Fortify\ResetUserPassword;
use App\Actions\Fortify\UpdateUserPassword;
use App\Actions\Fortify\UpdateUserProfileInformation;
use App\Models\User;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\Fortify;

class FortifyServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        Fortify::ignoreRoutes();
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

        Fortify::createUsersUsing(CreateNewUser::class);
        Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
        Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
        Fortify::resetUserPasswordsUsing(ResetUserPassword::class);

        RateLimiter::for('login', function (Request $request) {
            return Limit::perMinute(5)->by($request->username.$request->ip());
        });

        RateLimiter::for('two-factor', function (Request $request) {
            return Limit::perMinute(5)->by($request->session()->get('login.id'));
        });
        
        $this->configureRoutes();
    }

    /**
     * Configure the routes offered by the application.
     *
     * @return void
     */
    protected function configureRoutes()
    {
		Route::group([
                'namespace' => 'Laravel\Fortify\Http\Controllers',
                'domain' => config('fortify.domain', null),
                'prefix' => config('fortify.prefix'),
            ], function () {
                $this->loadRoutesFrom((base_path('routes/fortify.php'));
            });       
    }
}

Now you can customize all fortify routes and add middleware as much as you want.

Activity icon

Replied to Arr::keys Arr::flip Error: Method Does Not Exist

Laravel Collection Merhods will solve all these problems . for Arr::merge try this

https://laravel.com/docs/8.x/collections#method-merge

Take a look at the other methods. Let me know if your problem solved

Activity icon

Replied to Display PAGINATION GroupBy In BLADE View

groupBy not working with pagination according to laravel 7 documentation

Note: Currently, pagination operations that use a groupBy statement cannot be executed efficiently by Laravel. If you need to use a groupBy with a paginated result set, it is recommended that you query the database and create a paginator manually.

https://laravel.com/docs/7.x/pagination

Activity icon

Replied to Arr::keys Arr::flip Error: Method Does Not Exist

@spook1 did you try this ??

$flipped = collect($your_array)->flip()->all();
Activity icon

Replied to Form Submit Is Not Working Only It Refreshes The Page

Make sure that you pass the action and the method to the form tag in your blade

<form action="{{ route('post.add') }} method="post">
Mar
20
3 weeks ago
Activity icon

Replied to Arr::keys Arr::flip Error: Method Does Not Exist

Try this

$flipped = collect(your_array)->flip()->all();
Mar
19
3 weeks ago
Activity icon

Replied to Laravel Realtime

The laravel-websockets broadcasting without a commercial WebSocket provider, it's free and easy to use and compatible with laravel

Mar
18
3 weeks ago
Activity icon

Replied to Unable To Destroy An ID

open your network tab what is the response returned from this request ?

Mar
17
3 weeks ago
Activity icon

Replied to My Blade Not Loading In Browser

And i till you that your blade not returned because your $request->date is null !!

Activity icon

Replied to My Blade Not Loading In Browser

@letmeknow try dd($request->date) i believe it would be null

Activity icon

Replied to My Blade Not Loading In Browser

Your condition ($request->date) not satisfied which means your ($request->date) is null so the view is not returned

Activity icon

Replied to Eloquent Closures Insert To Query - "SELECT *" And "is Null"

Subquerie compares the results of a subquery to the value you give to the where as a second parameter. since you didn't pass a second parameter to where , the sebquery result compared to null and your subquery do nothing

Activity icon

Replied to Getting Response()->json() As Undefined In Consolelog

@yanikkumar You can check whether the status code is 200 in case you are just trying to change the text of the button

Mar
15
4 weeks ago
Activity icon

Replied to Getting Response()->json() As Undefined In Consolelog

@snapey Sorry, I didn't read this line:

Someone suggested We shouldn't be touching the traits files of the package. Should I add something in that?

I thought he is using his own trait.

Activity icon

Replied to Getting Response()->json() As Undefined In Consolelog

@snapey I think sync method might solve his problem, right?

Activity icon

Awarded Best Reply on Validate Two (or More) Fields Within The Same Custom Rule

@rachids Try the custom validation rule option:

php artisan make:rule AvailableDate

inside AvailableDate class

<?php

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;

class AvailableDate implements Rule
{
    
	 public $starting_at;
	 public $ending_at;
	public $lockedDays;

    public function __construct($starting_at, $ending_at)
    {
        $this-starting_at;= $starting_at;
		$this-ending_at;= $ending_at;
    }


    // Determine if the validation rule passes.  

    public function passes($attribute, $value)
    {
        $this->lockedDays = YourLockedDaysModel::whereBetween('yourLockedDayColumn', [$this->starting_at, 		 
        $this->ending_at])->get();
		
		return !$this->lockedDays->Count() > 0;
    }

    
     // Get the validation error message.
 
    public function message()
    {
        return 'There are some locked days: ' .  $this->lockedDays;
    }
}

in your controller you can use the custom rule AvailableDate


'your_field' => [new AvailableDate($request->starting_date, $request->ending_date)]
Activity icon

Replied to Csrf-token Does Not Store In The Browser Cookies That Send By Laravel8 Sanctum

open inspect > Application tab> cookies then click on 127.0.0.1:8000 can you see cookies with the name XSRF-TOKEN AND laravel_session?

Activity icon

Awarded Best Reply on Laravel 8 Not Broadcasting An Event (pusher)

@shariff in your comoser.json change this

"pusher/pusher-php-server": "5.0"

to this:

"pusher/pusher-php-server": "^5.0"

then run composer update

Activity icon

Replied to Laravel 8 Not Broadcasting An Event (pusher)

@shariff in your comoser.json change this

"pusher/pusher-php-server": "5.0"

to this:

"pusher/pusher-php-server": "^5.0"

then run composer update

Activity icon

Replied to Getting Response()->json() As Undefined In Consolelog

@yanikkumar attach and detach methods both of them return null Try sync() method which returns an array of attached ids

if you want to unsync then pass an empty array to sync method

Activity icon

Replied to Controller Does Not Exist.

You are lucky, 4 comments in just less than 1 minute :D

Activity icon

Replied to Controller Does Not Exist.

Remove Admin from your path 'Admin\[email protected]' or create Admin folder and put your controller in this folder and update the namespace to namespace App\Http\Controllers\Admin;

Activity icon

Replied to Laravel 8 Not Broadcasting An Event (pusher)

Show me your composer.json file

Activity icon

Replied to Create And Save Don`t Does Not Occur

I can't understand anything !

Activity icon

Replied to Gitignore For .env?

No, it will not. Your .env.example not included in .gitignore so you can push it and after cloning your project you can create .env file and copy the .env.example to your new .env file then put your secret keys

Activity icon

Replied to Gitignore For .env?

Your .env file should not be committed to your application's source control, since each developer/server using your application could require a different environment configuration. Furthermore, this would be a security risk in the event an intruder gains access to your source control repository since any sensitive credentials would get exposed. You can push .env.example file then give your client secrets to your team mates in any way without pushing your .env file to your version control since it would be a high security risk.

Mar
14
4 weeks ago
Activity icon

Replied to Getting Response()->json() As Undefined In Consolelog

If it has no return value then why he assigned it to the $response variable ??

Activity icon

Replied to "Remember Me" Is Not Working As Expected

Remember me is not valid if you manually logged out It will be valid only if you closed your browser or your session expired then you will be logged in automatically without need to enter your credentials again.

From laravel documentation:

keep the user authenticated indefinitely or until they manually logout. Your users table must include the string remember_token column, which will be used to store the "remember me" token.

Activity icon

Replied to Laravel 8 Not Broadcasting An Event (pusher)

First, you passed a non declared variable $message to the MessageEvent class. also, you should define the property message at MessageEvent class.

Try this:

 public function sendMessage(Request $request)
    {
     
		event(new MessageEvent('Hello Sharrif'));

    }

Then at MessageEvent class:

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

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

	public $message

    

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

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('channel-name');
    }

    public function broadcastAs()
    {
        return 'userChatChannel';
    }

  
}

Mar
13
1 month ago
Activity icon

Replied to VueJS Variable Inside V-show Within Blade

Glad I helped, best wishes with your project :)

Activity icon

Awarded Best Reply on VueJS Variable Inside V-show Within Blade

okay, I deleted the reply. you can put your condition in the div root element in your CardModel.vue

<template>
	<div v-show="{{ showCardModel }}">
		<!-- Your template code -->
	</div>
</template>

otherwise, if you want to use directives inside blade I think you should use inline-template

<card-modal inline-template>
	<div v-show="{{ showCardModal }}">
		...
	<div>
</card-modal>
Activity icon

Replied to VueJS Variable Inside V-show Within Blade

okay, I deleted the reply. you can put your condition in the div root element in your CardModel.vue

<template>
	<div v-show="{{ showCardModel }}">
		<!-- Your template code -->
	</div>
</template>

otherwise, if you want to use directives inside blade I think you should use inline-template

<card-modal inline-template>
	<div v-show="{{ showCardModal }}">
		...
	<div>
</card-modal>
Activity icon

Replied to Module Not Found: Error: Can't Resolve

@kikoldasd

you named your component chat-messages

Vue.component('chat-messages', require('./components/ChatMesssages.vue'));

Then you call it in the blade chat-component you must call it with chat-messages as you named it in the app.js

so in your blade do this

<div id="app">
      <chat-messages :messages="messages"></chat-messages>
      <chat-form v-on:messagesend="addMessage" :user="{{ Auth::user() }}"></chat-form>
 </div>
Activity icon

Replied to Validate Two (or More) Fields Within The Same Custom Rule

@rachids Try the custom validation rule option:

php artisan make:rule AvailableDate

inside AvailableDate class

<?php

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;

class AvailableDate implements Rule
{
    
	 public $starting_at;
	 public $ending_at;
	public $lockedDays;

    public function __construct($starting_at, $ending_at)
    {
        $this-starting_at;= $starting_at;
		$this-ending_at;= $ending_at;
    }


    // Determine if the validation rule passes.  

    public function passes($attribute, $value)
    {
        $this->lockedDays = YourLockedDaysModel::whereBetween('yourLockedDayColumn', [$this->starting_at, 		 
        $this->ending_at])->get();
		
		return !$this->lockedDays->Count() > 0;
    }

    
     // Get the validation error message.
 
    public function message()
    {
        return 'There are some locked days: ' .  $this->lockedDays;
    }
}

in your controller you can use the custom rule AvailableDate


'your_field' => [new AvailableDate($request->starting_date, $request->ending_date)]
Activity icon

Replied to Getting Response()->json() As Undefined In Consolelog

if the database is updated and everything work as expected then I think you forgot to return value in toggleFollow method

Activity icon

Replied to Dates In Laravel

Try this:

use Carbon\Carbon;

$yourCurrentDate = Carbon::parse('YourStartDate')
$dateAfterFiveDays =  $yourCurrentDate->addDays(5);

// then validate

'date_field' => 'before:' . $dateAfterFiveDays
Activity icon

Replied to Getting Response()->json() As Undefined In Consolelog

First, return your request to make sure that you successfully sent it to your controller

public function follow(Request $request)
{
    retuen $request
}

if the data sent successfully to your controller then make sure that you have a user with this id, may be you sent the wrong id

$user = User::findOrFail($request->user_id); // make sure you have a user with this id
return $user

show us the code of toggleFollow method

Mar
12
1 month ago
Activity icon

Replied to Validate Two (or More) Fields Within The Same Custom Rule

Try this:

$lockedDays = YourLockedDaysModel::whereBetween('yourLockedDayColumn', [$request->starting_at, $request->ending_at])->get();

if($lockedDays->Count() > 0) {
 // do something
}
Activity icon

Replied to Parent/child Relationship By ID Within The Same Table

I think you should pass the parent_id as a second argument in the parent relation since the default is client_id ... Also pass the the client_id as second argument in the children relation .... Finally as @jlrdw said make sure that you used with in you controller

Activity icon

Replied to PHP Logical Operators

the hyphen will be removed only if $this->options['clientref'] is null !!

that what I thought you want when I read your question

Activity icon

Replied to PHP Logical Operators

Try this:


        'ClientReference' => is_null($this->options['clientref']) ?
                                    $this->filterOrderId($order) :
                                    $this->options['clientref'] . '-' . $this->filterOrderId($order);