Nasmed

Nasmed

Member Since 2 Years Ago

Experience Points
44,010
Total
Experience

990 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
417
Lessons
Completed
Best Reply Awards
3
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 9
44,010 XP
09 Sep
1 week ago

Nasmed commented on At A Glance

Is there anyone doing a similar job in the programming industry or just Laracasts, just wondering!

16 May
4 months ago

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

@abdulbazith what does orderLists return?

It must return a collection so each() iterates over the items in the collection and passes each item to a callback to perform the delete.

To delete all the order items at once do this

$purchaseOrder->orderLists->delete();

But it will produce the same error if orderLists() doesn't return a collection.

If each PurchaseOrder has many OrderList, the relation must be like that.

public function orderLists()
{
    return $this->hasMany(OrderList::class);
}
11 May
4 months 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() }
]

Also, try to match the Vue version with vue-template-compiler

        "vue": "2.5.22",
        "vue-template-compiler": "2.5.22"

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?

Nasmed left a reply on Line Break Inside Foeach

Use <br>

10 May
4 months 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 share 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->fresh()->sendMessage($request->message); 

$team->conversation()->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' => 'required|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.']);

Here are all the available validation rules you can use: https://laravel.com/docs/5.8/validation#available-validation-rules

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 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 functionality. Here's an example:

<example-component inline-template>
    @auth()
        <input v-model="{{ auth()->user()->name }}">
    @elseguest()
        <button @click="login"></button>
    @endauth
</example-component>

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 the front-end, use $hidden attribute in the User model to hide the unwanted data.

The last solution may expand using Vuex.

Nasmed left a reply on Problem When Running Seeders Laravel 5.5

Maybe you're using custom table names, make sure you override $table property 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 relationship:

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
4 months 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
4 months ago

Nasmed left a reply on Where Are You All From?

El Jadida, Morocco

15 Jun
1 year ago

Nasmed left a reply on Problem With Hosting Laravel Project

Problem solved 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
1 year 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 inputs: mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper

PHP extensions on the server: http://prntscr.com/jv5p2f

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

NOTE: The pages that don't require database connection work.

11 Jun
1 year ago

Nasmed left a reply on Redirect After Logout

One way is to store the username in a cookie before logout them and then check in the login form if the cookie has a username if so output it.

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'));
}

Your view:

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

Now 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 in the first place?

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::get('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 then 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
1 year 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_dash|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