DanyLok

DanyLok

Member Since 5 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.

Level 1
620 XP
Sep
24
1 month ago
Activity icon

Started a new Conversation Delete What Is Selected

d

Sep
23
1 month ago
Activity icon

Replied to Filter By County Nova

Yes but I want a filter by county name Ex: Filter by county -> Madrid or Roma, etc. But my function is not correct

Sep
22
1 month ago
Activity icon

Started a new Conversation Filter By County Nova

Hello, how I can do a filter by county name in nova?

 public function apply(Request $request, $query, $value)
    {
        return $query->where('county', $value);
    }

    /**
     * Get the filter's available options.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function options(Request $request)
    {
        return [
            'County' => 'county',
        ];
    }

I have this but doesn`t works

Sep
21
1 month ago
Activity icon

Started a new Conversation Show "old Than 30 Days"

How can I display a message "older than 30 days" by checking if it is older than that?

 @elseif(date('Y-m-d', strtotime('-30 day')))
                                                    <p class="small" style="font-weight: normal;">Old than 30 days</p>
                                                    @endif

Can I do this in blade ?

Sep
18
1 month ago
Activity icon

Replied to Upload Multiple Images

I don't really understand how I could adapt that foreach.

Activity icon

Started a new Conversation Upload Multiple Images

Hi, how can I upload multiple images at once? I have this script so far


if ($request->hasFile('images')) 
        {
            $postImages->images = $request->file('images');
            $name = time() . '.' . $postImages->images->getClientOriginalExtension();
            $destinationPath = public_path('/uploads/images');
            $postImages->images->move($destinationPath, $name);
        }
        $postImages->save();

view

<div class="images-group-uploader">
                                                    <input type="file" id="groupImages" name="images" m multiple="true" accept="image/png, image/jpeg" />
                                                    <label for="groupImages" class="general-btn positive-btn">
                                                        <span> Upload </span>
                                                        <i class="fad fa-upload"></i>
                                                    </label>
                                                </div>
May
13
5 months ago
Activity icon

Started a new Conversation Count A Value

Hi, how can I monitor a user's followers based on the id of the user they are friends with?

Follow controller:

public function follow($id) {
        Friend::create([
            'user_id' => Auth::user()->id, 
            'friend_id' => $id, 
        ]);
        Alert::success('Succes', 'Successfully follwed the user');
        return back();
    }

Model:
Schema::create('friends', function (Blueprint $table) {
            $table->increments('id');
            $table->bigInteger('user_id')->unsigned();
            $table->bigInteger('friend_id')->unsigned();
            $table->boolean('status')->default(0);
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('friend_id')->references('id')->on('users')->onDelete('cascade');
        });

protected $fillable = [
        'friend_id', 'user_id',
    ];
    
    public function friend() {
        return $this->belongsTo(User::class, 'friend_id');
    }

    public function user() {
        return $this->belongsTo(User::class);

     public function usersfriends() {
        return $this->hasMany(Friend::class, 'friend_id');
    }

    public function friends() {
        return $this->hasMany(Friend::class);
    }

May
09
5 months ago
Activity icon

Replied to The Problem When Creating A New Table In The Database.

Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->string('provider')->nullable();
            $table->string('provider_id')->nullable();
            $table->string('phoneNumber')->default();
            $table->boolean('admin')->default(0);
            $table->string('avatar')->default('default.jpg');
            $table->string('about')->default('default');
            $table->string('hobbies')->default('default');
            $table->string('skills')->default('default');
            $table->string('links')->default('default');
            $table->string('adress')->default('default');
            $table->string('nationality')->default('default');
            $table->integer('age')->nullable();
            $table->string('facebook')->default('default');
            $table->string('instagram')->default('default');
            $table->string('twitter')->default('default');
            $table->string('linkedin')->default('default');
            $table->boolean('userAcces')->default(1);
            $table->boolean('moderator')->default(0);
            $table->integer('coins')->default(0);
            $table->rememberToken();
            $table->timestamps();
        });

Activity icon

Replied to The Problem When Creating A New Table In The Database.

https://i.imgur.com/hKBfOAd.png

SQLSTATE[HY000]: General error: 1005 Can't create table `laravel`.`friends` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `friends` add constraint `friends_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade)

Activity icon

Started a new Conversation The Problem When Creating A New Table In The Database.

Hi, I still have a problem when I want to create this table in the database, I tried so many ways but I still get the same error.

  SQLSTATE[HY000]: General error: 1005 Can't create table `laravel`.`friends` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `friends` add constraint `friend
s_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade)

My models::

User->  public function usersfriends() {
        return $this->hasMany(Friend::class, 'friend_id');
    }

    public function friends() {
        return $this->hasMany(Friend::class);
    }

Friends->
protected $fillable = [
        'friend_id', 'user_id',
    ];
    
    public function friend() {
        return $this->belongsTo(User::class, 'friend_id');
    }

    public function user() {
        return $this->belongsTo(User::class);
    }

Tabel
  Schema::create('friends', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsinged();
            $table->integer('friend_id')->unsinged();
            $table->boolean('status')->default(0);
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('friend_id')->references('id')->on('users')->onDelete('cascade');
        });

May
04
5 months ago
Activity icon

Replied to The Profile Picture Is No Longer Displayed

public function profile(Request $request, $id) {
        $user = User::find($id);

        if ($user->userAcces != 0) {

        return view('pages.profile', compact('user'));

        }
        return view('pages.suspend');
    }

no change...

Activity icon

Replied to The Profile Picture Is No Longer Displayed

I tried something like that, it doesn't work. The problem is that only after I have updated the route according to the id does this happen.

Activity icon

Started a new Conversation The Profile Picture Is No Longer Displayed

Hi, I created the user profile for my site and when I put the route to the profile according to the player id the profile picture is no longer displayed, what can it be?

View:
 <div class="image d-flex justify-content-center">
                    <img src="uploads/avatars/{{ $user->avatar }}" class="rounded-circle" name="avatar">
  </div>

Route::
Route::GET('/pages/profile/{id}', '[email protected]')->name('pages.profile');
Controller:
public function profile(Request $request, $id) {
        $user = User::findOrFail($id);
        if (Auth::check() && Auth::user()->userAcces != 0) {
            return view('pages.profile', compact('user'));
        }
        if (Auth::user()->userAcces == 0) {
            return view('pages.suspend');
        } else {
            return redirect('register');
        }
    }
Apr
30
5 months ago
Apr
29
5 months ago
Activity icon

Started a new Conversation The Problem When Inserting In The Database.

Hi, I have a problem that I don't know exactly how to solve, when I want to change something for example from the admin page, where I can change another user's name and email, etc., if I want to change something I have to change the name otherwise I get error, how can I fix it?

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null (SQL: update `users` set `name` = ?, `email` = ?, `roles` = ?, `users`.`updated_at` = 2020-04-29 21:42:22 where `id` = 1)
Controller:
 public function update_UserInfo(Request $request) {
      	$user = User::where('name', request('usrName'))->first();
        $user->name = request('usrName');
        if($user->name = request('changeName')) {
            $user->save();
        } 
        else if($user->email = request('changeEmail')){
            $user->save();
        } 
        else if($user->roles = request('changeUserRoles')){
            $user->save();
        }
        if ($user->save()) {
            return view('profile', array('user' => Auth::user()))->with('success', 'Succes');
        } 
        else if (!$user->save()) {
            return view('profile', array('user' => Auth::user()))->with('danger', 'Something went wrong');
        }
    }

View:
<form method="post" class="tab-pane" id="adminpanel" action="{{ route('admin.adminPanel') }}">
                    {{ csrf_field() }}
                    <div class="form-group row">
                        <label class="col-lg-3 col-form-label form-control-label">Input user ID/Name</label>
                        <div class="col-lg-9">
                            <input class="form-control" type="usrName" name="usrName" value="">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-lg-3 col-form-label form-control-label">UserAcces</label>
                        <div class="col-lg-9">
                            <input class="form-control" type="userAcces" name="userAcces" value="">
                        </div>
                    </div>
                     <div class="form-group row">
                        <label class="col-lg-3 col-form-label form-control-label">Change Name</label>
                        <div class="col-lg-9">
                            <input class="form-control" type="text" name="changeName" value="">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-lg-3 col-form-label form-control-label">Change Email</label>
                        <div class="col-lg-9">
                            <input class="form-control" type="text" name="changeEmail" value="">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-lg-3 col-form-label form-control-label">Change User Role</label>
                        <div class="col-lg-9">
                            <input class="form-control" type="text" name="changeUserRole" value="">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-lg-3 col-form-label form-control-label"></label>
                        <div class="col-lg-9">
                            <button type="submit" class="btn btn-secondary" test>Cancel</button>
                            <button type="submit" class="btn btn-secondary" test>Submit</button>
                        </div>
                    </div>
                </form>
Activity icon

Started a new Conversation Simplification Of Conditions.

Hi, I made several conditions for updating the user profile, but I think it's a lot, can it be done with a switch? If so, what condition should I put?

public function update_Profile(Request $request) {
        $user = User::find(Auth::user()->id);
        if($user->email = request('email')) {
            $user->save();
        }
        else if($user->about = request('about')) {
            $user->save();
        }
        else if($user->skills = request('skills')) {
            $user->save();
        }
        else if($user->hobbies = request('hobbies')) {
            $user->save();
        }
        else if($user->name = request('name')) {
            $user->save();
        }
        else if($user->password = request('password')) {
            $user->save();
        }
        else if($user->phoneNumber = request('phoneNumber')) {
            $user->save();
        }
        else if($user->adress = request('adress')) {
            $user->save();
        }
        else if($user->nationality = request('nationality')) {
            $user->save();
        }
        else if($user->age = request('age')) {
            $user->save();
        }
        else if($user->facebook = request('facebook')) {
            $user->save();
        }
        else if($user->instagram = request('instagram')) {
            $user->save();
        }
        else if($user->twitter = request('twitter')) {
            $user->save();
        }
        else if($user->linkedin = request('linkedin)')) {
            $user->save();
        }
        else if($user->avatar = request('avatar')) {
            $user->save();
        }
        if ($user->save()) {
            return view('profile', array('user' => Auth::user()))->with('success', 'Succes');
        }
        else if (!$user->save()) {
            return view('profile', array('user' => Auth::user()))->with('danger', 'Something went wrong');
        }
    }
Apr
28
5 months ago
Activity icon

Replied to Error Redirecting To Another User's Profile

<h5><a href="{{ route('profile', ['name' => $row->name]) }}" i have this.

Activity icon

Started a new Conversation Error Redirecting To Another User's Profile

Hi, I would like to be able to enter another user's profile on my site and see his information, but I have a problem redirecting to that profile. Missing required parameters for [Route: profile] [URI: profile/{name}].

Route:
Route::any('/profile/{name}', '[email protected]')->name('profile');


Controller:
public function profile(Request $request, $name) {
        $user = User::where('name', $name)->first();
        if (Auth::check() && Auth::user()->userAcces != 0) {
            return view('profile', ['user' => $user]);
        }
        if (Auth::user()->userAcces == 0) {
            return view('suspend');
        } 
        else {
            return redirect('register');
        }
    }

View:

<div class="col-md-8">
            <div class="tab-content profile-tab" id="myTabContent">
                <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
                    <div class="row">
                        <div class="col-md-6">
                            <label>User Id</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->id }}</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label>Name</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->name }}</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label>Email</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->email }}</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label>Phone</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->phoneNumber }}</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label>Skills</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->skills }}</p>
                        </div>
                    </div>
                </div>
                <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
                    <div class="row">
                        <div class="col-md-6">
                            <label>About</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->about }}</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label>Hobbies</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->hobbies }}</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label>Nationality</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->nationality }}</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label>Age</label>
                        </div>
                        <div class="col-md-6">
                            <p>{{ $user->age }}</p>
                        </div>
                    </div>
                </div>