HOVO

Member Since 4 Months Ago

Experience Points
620
Total
Experience

4,380 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
0
Lessons
Completed
Best Reply Awards
0
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 1
620 XP
May
07
2 days ago
Activity icon

Started a new Conversation Order By Relation. Please Help 😢

Tell me please how can I order my users list by relation (product) field for example i have

|users    product_id  |   products
|1.jhon     2        |    1.cup
|2.dhoe    1          |    2.pen

and i want get ordered all users by -> cup and get list like -> 2.dhoe, 1.jhon

  $user = User::with('product')
            ->whereHas('product', function ($q){
                return $q->orderByRaw("FIELD(product, 'pen') DESC");
            })
            ->get();
Activity icon

Started a new Conversation Order By

Hello guys :) i have a problem how can i implement that query through eloquent???

      $profile->orderByRaw("CASE WHEN username like '{$filters->get('query')}%' THEN username END DESC")
                ->whereHas(
                    'profileTechnologies.profileTechnologyFramework.framework',
                    function ($query) use ($filters) {
                        $query->orderByRow("CASE WHEN name = '{$filters->get('query')}' THEN name END DESC");
                    }
                );
Apr
17
3 weeks ago
Activity icon

Started a new Conversation Indexing Foreign Keys Laravel Migration

I need to know the best way to define relations and indexes, Are there any difference between

 $table->unsignedBigInteger('example_id')->index();

OR

​$table->index(['example_id']);
Apr
16
3 weeks ago
Activity icon

Replied to Laravel COALESCE

@michaloravec still same error :( does it related with my laravel version ? and one more question. Does your option method faster than my ??

Apr
15
3 weeks ago
Activity icon

Replied to Laravel COALESCE

@michaloravec full method

public function scopeQueryFromRequest($q, $req) {
        if ($manager_order = $req->get('manager_order')) {
            $q->join('users', 'users.id', '=', 'projects.manager_id')
                ->select('projects.*')
                ->orderBy('users.name', $manager_order);
        }

        if ($direction_id = $req->get('direction_id')) {
            $q->where('direction_id', $direction_id);
        }

        if ($query = $req->get('query')) {
            $q->where('name', 'like', '%'.$query.'%')
              ->orWhere('description', 'like', '%'.$query.'%')
              ->orWhere('project_code', 'like', '%'.$query.'%');
        }

        if ($date_order = $req->get('date_order')) {
            $q->orderBy('created_at', $date_order);
        }

        if ($start_date_order = $req->get('start_date_order')) {
            $q->orderByRaw("COALESCE(mpp_start_date, start_date) ?",  [$start_date_order == 'ASC' ? 'ASC' : 'DESC']);
        }

        if ($end_date_order = $req->get('end_date_order')) {
            $q->orderByRaw("COALESCE(mpp_end_date, end_date) ?", [$end_date_order == 'ASC' ? 'ASC' : 'DESC']);
        }

        if ($progress_order = $req->get('progress_order')) {
            $q->orderByRaw(DB::raw("CONVERT(plan_progress, SIGNED) $progress_order"));
        }


        if ($start_date_from = $req->get('start_date_from')) {
            $q->whereDate('start_date', '>=', Carbon::parse($start_date_from));
        }

        if ($start_date_to = $req->get('start_date_to')) {
            $q->whereDate('start_date', '<=', Carbon::parse($start_date_to));
        }

        if ($end_date_from = $req->get('end_date_from')) {
            $q->whereDate('end_date', '>=', Carbon::parse($end_date_from));
        }

        if ($end_date_to = $req->get('end_date_to')) {
            $q->whereDate('end_date', '<=', Carbon::parse($end_date_to));
        }
   

        if ($name_order = $req->get('name_order')) {
            $q->orderBy('name', $name_order);
        }

        if ($date_order = $req->get('date_order')) {
            $q->orderBy('end_date', $date_order);
        }

        if ($project_type = $req->get('project_type')) {
            switch ($project_type) {
                case 'informational': $q->where('project_type_id', 1); break;
                case 'investional': $q->where('project_type_id', 2); break;
            }
        }

        if ($status = $req->get('status')) {
            switch ($status) {
                case 'in_work': $q->where('status', 'in_work'); break;
                case 'expired': $q->where('status', 'expired'); break;
            }
        }

        return $q;
    }
Activity icon

Replied to Laravel COALESCE

@michaloravec in my model i implemented sorting and have some conditions with that both

 if ($start_date_order = $req->get('start_date_order')) {
            $q->orderByRaw("COALESCE(mpp_start_date, start_date) ?",  [$start_date_order == 'ASC' ? 'ASC' : 'DESC']);
        }

        if ($end_date_order = $req->get('end_date_order')) {
            $q->orderByRaw("COALESCE(mpp_end_date, end_date) ?", [$end_date_order == 'ASC' ? 'ASC' : 'DESC']);
        }

i have tried with interpolation its work fine but it dangerous

Activity icon

Replied to Laravel COALESCE

@michaloravec so what i am doing wrong :( ?

Activity icon

Replied to Laravel COALESCE

@michaloravec hmmm i assume it replaced with DESC full code`

  if ($start_date_order = $req->get('start_date_order')) {
            $q->orderByRaw("COALESCE(mpp_start_date, start_date) ?",  [$start_date_order == 'ASC' ? 'ASC' : 'DESC']);
        }
Activity icon

Replied to Laravel COALESCE

dear @michaloravec i have tried to do something like this but every time throw me error like `

Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1 (SQL: select * from `projects` where `direction_id` = 3 order by COALESCE(mpp_end_date, end_date) DESC)",
 
Activity icon

Started a new Conversation Laravel COALESCE

Hello dear reader i have a problem i need to implement this query without interpolation to avoid some sql injections here is my code. thanks)

$q->orderByRaw(DB::raw("COALESCE(mpp_start_date, start_date) $start_date_order"));

$start_date_order -> will be ASC or DESC please help

Mar
18
1 month ago
Activity icon

Replied to After Create New Laravel Project Console Show Error

@neilstee hello for pure project dont have also i test it my other laravel projects and same thing for all project show that error idk why

Activity icon

Started a new Conversation After Create New Laravel Project Console Show Error

this css error

GET chrome-extension://moodehecnaobpilpaamkiahegcbcihma/content/styles.css net::ERR_FILE_NOT_FOUND
127.0.0.1/:1 GET chrome-extension://moodehecnaobpilpaamkiahegcbcihma/content/styles.css net::ERR_FILE_NOT_FOUND
Mar
17
1 month ago
Activity icon

Replied to Laravel Echo Does Not Listen To Channel

i find that suggestion on stackoverflow . without dot dont work too

Activity icon

Started a new Conversation Laravel Echo Does Not Listen To Channel

To broadcast an event on a channel I used laravel Echo , redis and socket-io. this is my event :


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

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

bootstrap.js

import Echo from "laravel-echo"
window.io = require('socket.io-client');

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: window.location.hostname + ':6001' // this is laravel-echo-server host
});

on blade i want to get it like that

<script>
    Echo.channel('channel')
        .listen('.chat', e => {
            console.log(e)
        })
</script>

Echo show this


L A R A V E L  E C H O  S E R V E R

version 1.6.2

⚠ Starting server in DEV mode...

✔  Running at localhost on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!

Channel: laravel_database_channel
Event: chat
Channel: laravel_database_channel
Event: chat

controller method

   public function postMessage(Request $request){
       $message = Message::create($request->all());
        event(
            new NewMessageAdded($message)
        );
        return redirect()->back();
    }

on the redis monitor all events show correctly need to get log on other chat tab. Any idea ????

Activity icon

Replied to Class 'Redis' Not Found

your suggestion help me now work it thank u very much :D

Activity icon

Started a new Conversation Class 'Redis' Not Found

I want to build chat but when i start using redis it throw me that error.I have installed Redis on my project my .env

BROADCAST_DRIVER=redis

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

route for test if work

Route::get('/fire', function () {
    event(new \App\Events\NewMessageAdded());
    return 'ok';
});

What i am doing wrong ????

Feb
20
2 months ago
Activity icon

Replied to Get All Films Which Has One Or More Genre

OMG my mistake when i write country instead genre i never write something like this and didn't know if it would work THANK YOU WERY MUCH for attention ;)

Activity icon

Replied to Get All Films Which Has One Or More Genre

  public function genre(){
        return $this->belongsToMany(Genre::class);
    }

$request->genre

{
	genre: 'action' <-for example
}
Activity icon

Replied to Get All Films Which Has One Or More Genre

i just want to know is this right way to do it?

Activity icon

Started a new Conversation Get All Films Which Has One Or More Genre

Hello everyone need get all films from base where film have one and more genre

my films object for example this one

 {
                "id": 1,
                "name": "Mortal Kombat",
                "image": "http://avatars.mds.yandex.net/get-kinopoisk-image/1600647/ca7a6a43-b216-48de-b815-4bb49ad4ae2e/600x900",
                "video": "https://youtu.be/ow3fhDtRHiU",
                "description": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially",
                "release": 2021,
                "running": 120,
                "country_id": 1,
                "format": "HD",
                "limit": 16,
                "rating": 2,
                "created_at": null,
                "updated_at": null,
                "country": {
                    "id": 1,
                    "country": "USA",
                    "created_at": null,
                    "updated_at": null
                },
                "genre": [
                    {
                        "id": 2,
                        "genre": "horror",
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "film_id": 1,
                            "genre_id": 2
                        }
                    },
                    {
                        "id": 4,
                        "genre": "music",
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "film_id": 1,
                            "genre_id": 4
                        }
                    }
                ]
            },

there i have genre array need check

I trying do something like this

 $genre = $request->only('genre');

Film::with('country','genre')
            ->whereHas('genre', function ($q) use ($genre){
                return $q->where('genre','=', $genre);
            })
            ->get();

Help me please :)

Dec
16
4 months ago
Activity icon

Started a new Conversation How To Delete All Users Who Have Same Role

Hello everyone i am beginner on laravel so lets imagine i have roles and users table when deleted for example admin role on roles table need delete all users who have admin role i use many to many relationship

  Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

 Schema::create('roles', function (Blueprint $table) {
            $table->id();
            $table->string('role');
            $table->timestamps();
        });

 Schema::create('role_user', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->unsignedBigInteger('role_id');
            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
            $table->timestamps();
        });

Models

 public function roles(){
        return $this->belongsToMany(Role::class)->withTimestamps();
    }

 public function users(){
        return $this->belongsToMany(User::class)->withTimestamps();
    }

Please help me about that :3

Dec
15
4 months ago
Activity icon

Started a new Conversation Cascade On Delete Not Working

Hello everyone i have 2 tables users and roles i use many to many relationship and they have role_user pivot table need when some role will be deleted users who have that role will be deleted too onDeleted method not working what i am doing wrong ??? here is my code

    Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

 Schema::create('roles', function (Blueprint $table) {
            $table->id();
            $table->string('role');
            $table->timestamps();
        });

  Schema::create('role_user', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->unsignedBigInteger('role_id');
            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
            $table->timestamps();
        });

User model

 public function roles(){
        return $this->belongsToMany(Role::class)->withTimestamps();
    }

Role model

  public function users(){
        return $this->belongsToMany(User::class)->withTimestamps();
    }

THANKS :3