Yamen

Yamen

Member Since 2 Years Ago

Experience Points 70,100
Experience Level 15

4,900 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 550
Lessons
Completed
Best Reply Awards 23
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.

04 Feb
4 months ago

Yamen left a reply on Laravel + Stripe Connect

Great work.

01 Nov
7 months ago

Yamen left a reply on Which Laptop To Buy?

First of all go for Mac/Linux and stay away from windows as possible as you can for development, Consider memory not be less than 8GB and process not less i5 core.

If you're budget let's you get a macbook pro so go ahead confidentialy.

Yamen left a reply on Queue Jobs

php artisan queue:flush If you're using horizon php artisan horizon:terminate

25 Oct
7 months ago

Yamen left a reply on Laravel Queues

To make the command queue:work automatic you need to setup a service called Supervisor https://laravel.com/docs/5.7/queues#supervisor-configuration .

Supervisor will handle this for you, it works on linux, macos (dev and production). If you are on windows you should consider scheduled tasks.

Yamen left a reply on Date Filter

$users = App\User::where('created_at', today())->get(); // users created today
$users = App\User::whereBetween('created_at', [today()->subMonth(), today()])->get(); // users created this month

Yamen left a reply on Changing Laravel Date Format

Timestamps ('created_at', 'updated_at') are actually Carbon instances, so you can format it as you want by format method like ->format('dd-mm-yyy') or maybe ->diffForHumans(), ->toDateString() or many more here:

https://carbon.nesbot.com/docs/#api-formatting

30 Aug
9 months ago

Yamen left a reply on Datatables Not Applaying To The Table

Define datatables to be globally scoped.

window.datatables = require('datatables.net');

13 Aug
10 months ago

Yamen left a reply on Custom Make Language File And Keywords

You may create a resources/lang/es.json file:

{
    "I love programming.": "Me encanta programar."
}

use it in your views as follows:

{{ __('I love programming.') }}
03 Jul
11 months ago

Yamen left a reply on Enforcing SSL Redirects Every Http Request To Homepage

This is the normal behavior, That doesn't make sense! no one needs a redirect to another page.

21 Jun
11 months ago

Yamen left a reply on Is There Something Like WithAvarage?

Yes, there is.

In Salon.php add a mutator to calculate that reviews and then append it to the model.

protected $appends = ['score'];

public function getScoreAttribute()
{
    return round($this->salon_reviews()->avg('score'), 0, PHP_ROUND_HALF_UP);
}

// access salon score
$salon->score;

20 Jun
11 months ago

Yamen started a new conversation What Is The Suitable Number Of Queue Workers ?

I was wondering if there is a relation between number of queue workers and CPU or RAM resources. I noticed that Laravel defaults to 8-10 workers, however on my own experience I've tried once to increase them to 50 workers and what a huge and fast performance I get with my Digitalocean VPS 8GB RAM and 4CPUs compared to only 10 workers.

So is there any relation between there number and resources ?

02 May
1 year ago

Yamen left a reply on Update One-to-many Relation

$awards = [
    ['year' => 2016, 'award_type' => 1],
    ['year' => 2017, 'award_type' => 2],
    ['year' => 2018, 'award_type' => 1]
];

$user->awards()->createMany($awards);

Yamen left a reply on Multi User Role

There is https://github.com/Zizaco/entrust and also https://github.com/JosephSilber/bouncer , however I prefer Spatie's package https://github.com/spatie/laravel-permission , They are really producing very usefull dedicated packages for Laravel

28 Mar
1 year ago

Yamen left a reply on "Maximum Execution Time Of 30 Seconds Exceeded" In A Job

You may try --timeout=0 or whatever amount you want.

12 Mar
1 year ago

Yamen left a reply on Logged In User Info In Vue.js And Laravel

auth()->user(); // user
auth()->id(); // id

Yamen left a reply on Composer Create-project Gives [ErrorException] Mkdir(): Permission Denied

Within your code folder just run: sudo chmod 777 code

Yamen left a reply on How Do I Schedule A Job With Laravel And Xampp

I suppose you're working on Windows, so You need to make a task scheduler by following these steps:

1 - Create batch file "myfile.bat", like this one and save it:

`cd c:\laravel-project\

c:\xampp\php\php.exe artisan schedule:run 1>> NUL 2>&1`

2 - Go to Windows Task Scheduler (fast way is press Win+R and enter taskschd.msc).

3 - Click Create basic task, choose When I logon trigger and then choose Start a program -> your .bat file.

4 - Check Open properties dialog option and click Finish.

5 - In task properties click Triggers, then click New and add new trigger Repeat task every - 1 minute.

Now this task will run Laravel scheduler every one minute.

04 Mar
1 year ago

Yamen left a reply on Routing Issue

I recommend using https://github.com/spatie/laravel-permission , it handles almost all what you want, just follow the instructions and get your kernel to use the package middleware and you're good to go.

28 Feb
1 year ago

Yamen left a reply on ENOENT: No Such File Or Directory

These issues occur alot because of regular npm and plugins updates, So try to update nodejs and npm and finally run npm cache clean.

20 Feb
1 year ago

Yamen left a reply on Customer Support Live Chat By Laravel

@srikanthgopi Your answer should be accepted as the correct answer. Thanks buddy.

24 Dec
1 year ago

Yamen left a reply on How To Save Event Class Name? Event Listener Problem

If you're using 5.5 then change the propert $events to $dispatchesEvents.

Yamen left a reply on How To Debug SASS With Laravel-mix

Just import in resources/assets/sass/app.scss.

Yamen left a reply on How To Use React Without Compile All The Time?

No way, you need to compile whenever you update your code. Consider a command like npm run watch

18 Dec
1 year ago

Yamen left a reply on Redirect After Deleting Cookies.

This is called a "Middleware", when you run artisan make:auth Laravel generates bunch of classes and views, one of them is AuthMiddleware, you'll notice that in HomeController the constructor has

$this->middleware('auth');

this prevents the access to those functionalities unless the user is authenticated.

So If you want to implement this to other controllers you have to options:

First: To construct the controller with the same method as mentioned in HomeController

Second: Wrap your routes or group them in web.php as follow:

Route::group(['middleware' => ['web','auth']], function () {
    // your routes
});
15 Dec
1 year ago

Yamen left a reply on L5 - Best Way To Get User Timezone

@ardianck Yes, thank you, I forgot to write that we'll override it.

12 Dec
1 year ago

Yamen left a reply on Semantic UI Integration

@limsocheat Make sure you have the latest version of node.js and npm installed.

Assuming you are using linux, to upgrade node and npm just paste this in your terminal

sudo apt upgrade node && sudo npm i -g npm

10 Dec
1 year ago

Yamen left a reply on Migrating To Bootstrap 4 = Removal Of Most Code From Blade Files...

You only make that with a fresh installation, otherwise you should made them manually.

Yamen left a reply on Deploy Laravel App And Can Only See Homepage Others Got 404

Make sure that the .htaccess file is in your public_html.

Yamen left a reply on How Do I Include Material-icons In My Build.

npm install material-icons --save-dev

Then in webpack.mix.js

mix.js('resources/assets/js/app.js', 'public/js')
    .sass('resources/assets/sass/app.scss', 'public/css')
    .copy('node_modules/material-icons/css/material-icons.min.css', 'public/css/material-icons.min.css'); // add this

Run npm run dev

Refer to it from your master layout as <link rel="stylesheet" href="{{ asset('css/material-icons-min.css') }}" />

09 Dec
1 year ago

Yamen left a reply on How To Do Create Custom Users Activity Tracker ?

If there are packages that track this for you then it does't make sense to say "without package" just to reinvent the wheel.

For database logging there is "Laravel Auditing" www.laravel-auditing.com/docs/4.1/getting-audits For user activity tracking there is "Tracker" https://github.com/antonioribeiro/tracker

Yamen left a reply on How Do I Pass User Param To Vue Frontend

It seems you found a way to do it, Anyway, for anyone else who's struggling with something similar there's a good package made by Jeffrey called "JsTransformer" that make it easy to handle. https://github.com/laracasts/PHP-Vars-To-Js-Transformer

Yamen left a reply on How To Save Code In Database

You can make a column with "Json" format, in the migration maybe

Schema::create('information', function (Blueprint $table) {
    ...
    $table->json('user');
    ...
});

However it doesn't make sense to me what you're acheiving.

Yamen left a reply on How Can I Run Two Functions On Same Url

The problem is here:

Route::get('/', '[email protected]');
Route::get('/', '[email protected]');

The get request to "/" doesn't know where to go, you are providing two functions with the same route, so you may change one of them and try again.

Route::get('/random-entries', '[email protected]');
Route::get('/entries', '[email protected]');
02 Dec
1 year ago

Yamen left a reply on Using Static Classes

It depends on your needs but it's always advised to stick to the docs and common approaches. So just try to stick to Models when you retrieve anything from databases.

Yamen left a reply on Create Without Internet Connectivity

If you want to use cached packages to install laravel dont use the laravel installer withlaravel new my-app , but use the composer template

composer create-project --prefer-dist laravel/laravel my-app

You can later run composer update

27 Nov
1 year ago

Yamen left a reply on Laravel - Search Through Table By Name & Pagination

Okay, You want the query to pop-up without refresh, then go with datatables.net, here is the zero config https://datatables.net/examples/basic_init/zero_configuration.html

Yamen left a reply on Nested GroupBy() ?

For now it's great! Just don't get headache of good practice or elegance, they will come by time. Go back to the next task. Good luck!

Yamen left a reply on OrderBy On Nested Relation

1- In Comment model

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

    static::addGlobalScope('likesCount', function ($builder) {
        $builder->withCount('likes');
    });
}

public function commentable()
{
    return $this->morphTo();
}

public function likes()
{
    return $this->hasMany(Like::class);
}

2- In Post model

public function scopePublished($query)
{
     return $query->whereNotNull('published_at');
}

public function comments()
{
    return $this->morphTo();
}


Now, to view comments ordered by likes

Post::published()->with('comments', function ($comments)
{
    $comments->orderBy('likesCount');
})->paginate(50);

Yamen left a reply on Authenticating Users

Try $request instead of the helper function

$user->update([
        'username' => $request->username,
        'email' => $request->email
    ]);

Yamen left a reply on How To Mix Multiple Js In One?

mix.scripts([
    'public/js/admin.js',
    'public/js/dashboard.js'
], 'public/js/all.js');

Yamen left a reply on Updates To The Mobile App Framework Discussion

Framework7+vue served by phonegap

That's what I'm going for now.

26 Nov
1 year ago

Yamen left a reply on How To Count A User's Gained Upvotes/likes?

First, In User Model

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

    static::addGlobalScope('likesCount', function ($builder) {
        $builder->withCount('likes');
    });
}

public function likes()
{
    return $this->hasManyThrough(Like::class, Reply::class);
}

Now you have

$user->likescount; // 10

Yamen left a reply on How To Restrict Direct Access To Files

This is not achievable.. Just enter https://laracasts.com/asdasd.php it will give you the same, This is how Nginx server says that file doesn't exist.

14 Nov
1 year ago

Yamen left a reply on How To Process Multiple Queue's With Supervisor

No, It won't process them in order it's not a chain.