Nasmed

Nasmed

Member Since 1 Year Ago

Experience Points 37,450
Experience Level 8

2,550 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 353
Lessons
Completed
Best Reply Awards 3
Best Reply
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.

16 May
1 week ago
11 May
1 week ago

Nasmed left a reply on The Data Of Components Isn't Showing In Browser

Is there any error shows up in your browser console?

Nasmed left a reply on The Data Of Components Isn't Showing In Browser

@programmer111 Yes, change them manually then run the following command:

npm install

OR

npm remove vue
npm remove vue-template-compiler


npm install [email protected] --save
npm install [email protected] --save

Nasmed left a reply on The Data Of Components Isn't Showing In Browser

Try to add .default()after require.

let routes = [
  { path: '/dashboard', component: require('./components/Dashboard.vue').default() },
  { path: '/users', component: require('./components/Users.vue').default() },
  { path: '/profile', component: require('./components/Profile.vue').default() }
]

Nasmed left a reply on Line Break Inside Foeach

So, just try what @tray2 have suggested, use <p> or <div> instead :)

@foreach ($PaymentMethod_detail as $ph)
    <div>
        <input type="text" name="plable[]" id="plable_lbl" class="form-control" multiple>
    </div>                              
@endforeach

Nasmed left a reply on BelongsToMany With 4 Tables

** user_has_schools ** is a pivot table here, right?

So you may use withPivot() function to retrieve the role_id, something like that.

public function getUserSchools() {
    return $this->belongsToMany(Schools::class, 'user_has_schools', 'user_id', 'school_id')->withPivot('role_id');;
}

Also, take a look at Custom Intermediate Table you may need to use this feature. https://laravel.com/docs/5.8/eloquent-relationships#defining-custom-intermediate-table-models

Nasmed left a reply on Deploying Laravel On Cpanel Shared Account Failed - Composer Error

Can you connect to the server using SSH?

Try composer install

To import your packages and create the vendor folder, along with the autoload script.

Nasmed left a reply on Is It Possible For Mailing Verifications?

Why sending emails to Gmail users only?

10 May
2 weeks ago

Nasmed left a reply on All Other Crud Working Except Update

Try this approach to update the image:

public function storeImage($customer)
{   
    if (request()->has('image')) {
        $customer->image = request()->get('image')->store('images', 'public');
        $customer->save();

        $image = Image::make(public_path('storage/' . $customer->image))->fit(60, 60, null, 'top-left');
        $image->save();
    }
}

Nasmed left a reply on All Other Crud Working Except Update

Hi,

Please check your code or the error message, so we can help you.

Nasmed left a reply on Eloquent Create Call To A Member Function On Null

Try one of these:

$team->conversation()->sendMessage($request->message); $team->conversation->fresh()->sendMessage($request->message);

Nasmed left a reply on Validate UpdateOrCreate Method

Hi,

Do you mean validate the $request ?

If so, use Laravel is validate() method this way.

$this->validate($request, [
    'product_id' => 'nullable|integer',
    'name' => 'required|string',
    'email' => 'required|email'
]);

User::updateOrCreate(
    ['id' => $request->product_id], 
    ['name' => $request->name, 'email' => $request->email]
);        

return response()->json(['success'=>'User saved successfully.']);

Nasmed left a reply on How To Delete Records With Relationship With Multiple Tables

@abdulbazith You can do that using the same approach, listening for the created/updated event in your Product model and add update the supplier_amount table.

Nasmed left a reply on How To Pass User Info Into Vue

I just update my answer to add an example of an inline-template component.

@chrisgrim you're welcome my friend.

Nasmed left a reply on How To Pass User Info Into Vue

The first solution is to use Inline-template component, this way you can access all blade functionalities.

The second solution is what you have already done, by sending auth()->check() or auth()->user() as props.

    
<example-component     
        :is-auth="{{ json_encode(auth()->check()) }}"
                :user="{{ auth()->check() ? auth()->user() : 'null' }}">
</example-component >
props: {
    isAuth: {
        type: Boolean,
        default: false
    },
    user: {
        type: [Object, Array],
        required: false
    }
},

Another option is to store your user globally this way will be accessible for any component. (add it to your master blade)

    <script>
        window.App = {!! json_encode([
            'signedIn' => Auth::check(),
            'user' => Auth::user()
        ]) !!};
    </script>

Just be aware of this 'user' => Auth::user() since all user information will be accessible in your fornt-end, use $hidden attribute to hide the unwanted data.

The last solution may expend using Vuex.

Nasmed left a reply on Problem When Running Seeders Laravel 5.5

Maybe you're using customs table names, make sure you override $table in your models.

    protected $table = 'custom_table_name'

Nasmed left a reply on Relationships For Roster

Hi,

Maybe you can add admin_id to your games table this way each game will have one admin.

Each user may have multiple roles for each game, many to many relationships:

users -< ** role_user** (pivot table) >- roles

The pivot table has to include the game_id, so you need to mention that as well

    return $this->belongsToMany('App\Role')->withPivot('game_id');

Not sure about this solution but you can start from here and see.

09 May
2 weeks ago

Nasmed left a reply on POP UP View Modal

Hi,

What do you mean by "It doesn't work when I use variables." ?

Nasmed left a reply on How To Delete Records With Relationship With Multiple Tables

Hi,

You may need to use Eloquent models events.

Assuming you already set up the relationship between the two models.

In your PurchaseOrder model add the following code:

    protected static function boot()
    {
        parent::boot();

        self::deleting(function ($purchaseOrder) {
           $purchaseOrder->orderLists->each->delete();
        });

    }

This will delete all the relevant data in your order_lists table.

You may need to check the doc: https://laravel.com/docs/5.8/eloquent#events

06 May
2 weeks ago

Nasmed left a reply on Where Are You All From?

El Jadida, Morocco

15 Jun
11 months ago

Nasmed left a reply on Problem With Hosting Laravel Project

Problem solve by the host support.

They enabled nd_pdo_mysql and disabled pdo_mysql because both are not possible to be enabled as there is a conflict if both present at the same time.

14 Jun
11 months ago

Nasmed left a reply on Problem With Hosting Laravel Project

@jdc1898 the connections properly configured, it's work locally only, I think the problem comes from the pdo_mysql module, something wrong with the hosting server.

Nasmed started a new conversation Problem With Hosting Laravel Project

Hi guys,

Today, I host my website on FastComet, the first problem I faced is 500 internal server error when trying to access it, I fixed that by changing the PHP version to 7.2 since I'm using Laravel 5.6 it required that.

then I got that error:

Illuminate \ Database \ QueryException
could not find driver (SQL: select count(*) as aggregate from `courses` where `visible` = 1)
/home/lib/library/vendor/laravel/framework/src/Illuminate/Database/Connection.php
     * @param  array     $bindings
     * @param  \Closure  $callback
     * @return mixed
     *
     * @throws \Illuminate\Database\QueryException
     */
    protected function runQueryCallback($query, $bindings, Closure $callback)
    {
        // To execute the statement, we'll simply call the callback, which will actually
        // run the SQL against the PDO connection. Then we can calculate the time it
        // took to execute and log the query SQL, bindings and time in our memory.
        try {
            $result = $callback($query, $bindings);
        }
 
        // If an exception occurs when attempting to run a query, we'll format the error
        // message to include the bindings with SQL, which will make this exception a
        // lot more helpful to the developer instead of just the database's errors.
        catch (Exception $e) {
            throw new QueryException(
                $query, $this->prepareBindings($bindings), $e
            );
        }
 
        return $result;
    }

I talked to the support, he tells me to try PHP 7.1, I did that but the same error occurs.

I can access my hosting server using SSH, so I tried Composer Update, nothing happens I can access MySQL via SSH, works fine.

php -v inputs: ea-php-cli Copyright 2017 cPanel, Inc. PHP 7.2.6 (cli) (built: May 25 2018 07:56:12) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

mysql --version input: mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper

I have searched and try many solutions but nothing...

11 Jun
11 months ago

Nasmed left a reply on Redirect After Logout

One way is to store the username in a session before logout them and then check in the login form if the session with username exists...

Nasmed left a reply on Property [id] Does Not Exist On This Collection Instance.

Just to make your code more readable

public function index() {
    $inventories = Inventory::all(); 
    $avgStar = Rating::all()->where('inv_id', $inventories->id)->avg('rating'); 
    return view('inventory.index', compact('inventories', 'avgStar'));
}

Index.blade.php

@foreach ($avgStar as $rating) 
    @if ($inventory->id == $rating->inv_id) 
        {{ $avgStar->rating }} 
    @endif 
@endforeach

Not let's look for the problem, you sent $inventories to your view and try to get the id of a single inventory, $inventory->id ? how you get that $inventory first?

Nasmed left a reply on How To Create A New Function In Resource Controller In Laravel?

If you need to add additional routes to a resource controller beyond the default set of resource routes, you should define those routes before your call to Route::resource; otherwise, the routes defined by the resource method may unintentionally take precedence over your supplemental routes:

Route::resource('Purchase_details/open', '[email protected]');
Route::resource('Purchase_details', 'Purchase_detailsController');

Learn more here: https://laravel.com/docs/5.6/controllers#restful-supplementing-resource-controllers

Nasmed left a reply on Can't Vagrant Up

If you're using Windows Start vagrant as admin first (C:\USER\Vagrant\bin\vagrant.exe) and than vagrant up.

Nasmed left a reply on Issue In Auth

You're using mass assignment (User::create([...])) Try to add venue_emailid and venue_password in the fillable attribute in your User class (model)

protected $fillable = ['venue_emailid', 'venue_password'];

If that the case, learn more about mass assignment here: https://laravel.com/docs/5.6/eloquent#mass-assignment

hope that works.

28 May
11 months ago

Nasmed left a reply on Alpha_dash Validation Doesn't Accept Spaces

Hi @Jerome2116,

Thanks for taking the time to reply.

So I will stick with the good practice, and use alpha_dash instead of allowing spaces in the username.

Also, thank you @click for explaining the regex and the giving website, very helpful.

Thanks for your help.

Nasmed started a new conversation Alpha_dash Validation Doesn't Accept Spaces

Hi guys,

I tried alpha_dash to validate and restrict input for characters, as well as dashes and underscores. but it doesn't accept spaces!

            'username' => 'required|string|min:3|max:30|alpha|unique:users',
    

What I'm looking for is to make the username input accept only one space (optional) as well as characters, dashes and underscores, so for example:

'nasmed' -> success 'nas med' -> success 'nas_med' -> success 'nas moha med' -> failed

I've searched and found this Regular Expression Rule:

    'username' => 'required|string|min:3|max:30|regex:/^[\pL\s\-]+$/u|unique:users',

but it allows more than one space, how to make this Regular Expression Rule accept only one space.

Regards, Mohamed