berkayk

berkayk

Member Since 4 Years Ago

Experience Points 4,870
Experience Level 1

130 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 40
Lessons
Completed
Best Reply Awards 0
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.

11 Jul
1 year ago

berkayk started a new conversation Session Driver Performance

Hi,

After upgrading to Laravel 5.4, my session drivers stopped working in cookie setting and I have switched to file setting. After changing to file driver, my servers performance and response time degraded in a massive way. I also use redis as cache driver, do you suggest using redis as session driver or is it better to use cookie setting. If cookie is the best option, what could be the reason that cookie driver is not working. I am also open to the other solutions as well.

Thanks.

berkayk left a reply on Laravel 5.3 Auth Not Working On Session Cookie Base

Have you found a solution for this? file setting for sessions was causing my server a performance trouble. With cookie setting, I cannot use authentication at all.

05 Dec
3 years ago

berkayk started a new conversation Get Relation Count As JSON Response

I have a Post model where has many comments via hasMany('App/Comment') relation. I am trying to return the number of comments in JSON format. The response I would like to get is like

comments: [...],
numComments: 5,

I am able to return the comments but I don't know whether there is an easy way to get number of comments with eager loading.

Post::whereIn('user_id', $ids)->with('comments')->get();

Thanks.

18 Sep
3 years ago

berkayk started a new conversation Libsass Bindings Not Found (Node V4.1.0 On Windows 7)

Hi,

After upgrading node to v4.1.0, gulp stopped working. I have tried

  1. reinstalling node-sass and gulp-sass
  2. deleting node_modules folder and start from the scratch

but none of them solved the issue.

Error: `libsass` bindings not found. Try reinstalling `node-sass`?
    at getBinding (C:\wamp2\www\eg\node_modules\laravel-elixir\node_modules\gulp-sass\node_modules\node-sass\lib\index.js:22:11)
    at Object.<anonymous> (C:\wamp2\www\eg\node_modules\laravel-elixir\node_modules\gulp-sass\node_modules\node-sass\lib\index.js:188:23)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\wamp2\www\eg\node_modules\laravel-elixir\node_modules\gulp-sass\index.js:3:17)
    at Module._compile (module.js:434:26)

Thanks

14 Aug
3 years ago

berkayk left a reply on Asset Manifest Problems

I tried it on mac and paths seem to be working. Instead of css\all.min.css I get css/all.min.css which is fine but not on Windows. Maybe I need to alter some settings.

Even though paths work fine on mac, I still cannot include css with elixir command because it returns to some path like /build/css/all.min-c52bdece.css which is not reachable. How can I change it to absolute path like http//localhost.com/css/all.min-c52bdece.css

Thanks in advance.

10 Aug
3 years ago

berkayk left a reply on Asset Manifest Problems

I am compiling on windows machine.

berkayk left a reply on Asset Manifest Problems

I am on Windows 7.

Below is my gulpfile.js.

elixir(function(mix) {
    mix.styles([
     'css/bootstrap.min.css',
     'css/bootstrap-social.css',
     'css/overrides.css',
     'css/header.css',
     'css/animate.css'
    ])
    .scripts([
         'js/jquery.min.js',
         'js/jquery.lazyload.js',
         'js/bootstrap.min.js',
         'js/modernizr.js',
         'js/autosize.min.js',
         'js/mobile-utils.js'
    ])

    .version(['public/css/all.min.css','public/js/all.min.js']);

});

Thanks.

berkayk started a new conversation Asset Manifest Problems

Hi, I am having problems using elixir on asset loading stage. Building works fine but I cannot use the versioned file in my blade file. This is the error I am having

**File css/all.min.css not defined in asset manifest. **

Below is my rev-manifest.json.

{
  "css\\all.min.css": "css\\all.min-c52bdece.css",
  "js\\all.min.js": "js\\all.min-9bf32d9b.js"
}

public/build/css/all.min-c52bdece.css and public/build/js/all.min-0bf32d9b.js are both reachable and they contain correct styles/scripts.

07 Aug
3 years ago

berkayk left a reply on Auth::user() Returns Unexpected User

Am I missing something?

28 Jul
3 years ago

berkayk left a reply on Auth::user() Returns Unexpected User

I have 2 different login blocks, one with email-password and the other with facebook id and email. Maybe one of the flows are wrong.

Below is my email-password login flow.

$userdata = array(
                        'name' => Input::get('login'),
                        'password' => Input::get('password')
                    );

                    if (Auth::attempt($userdata, $remember)){
                        return redirect($redirectURI);
                    }
                    else
                    {
                        // validation not successful, send back to form
                        $errors = new MessageBag(['error' => ["L├╝tfen bilgilerinizi kontrol edin."]]);
                        return Redirect::to('login')->withErrors($errors)->withInput(Input::except('password'));
                    }

And this is the part where log user with facebook id.

// $fb_id holds unique facebook id

$user = User::where('fb_id', '=', $fb_id)->first();

if (is_null($user)){

    $emailUser = User::where('email', '=', $email)->first();
    if (isset($emailUser)){
        // There is a user with this email
        $errorText = "...";
        $errors = new MessageBag(['email' => [$errorText]]);
        Log::error("User logging in facebook with same e-mail ".$fb_id." and ".$email);
        return Redirect::to('login')->withErrors($errors)->withInput(Input::except('password'));
    }

    $user = new User();

    $user->name = $username;
    $user->first_name = $firstName;
    $user->last_name = $lastName;
    $user->email = $email;
    $user->fb_id = $fb_id;
    $user->save();
}

Auth::login($user);

if (Auth::check()){
    return redirect($redirectURI);
}
else{
    Log::error("Error.");
    return redirect('login');
}

Thanks

berkayk left a reply on Auth::user() Returns Unexpected User

I am using nginx but I haven't modified it for caching.

Is admin function is not the problem, I debugged the user id, it returns the first user in the users table instead of himself. Is there a possibility that Auth::user() returns the first record in users table? I have encountered this error 3-4 times, always it returned the first record.

Thanks.

27 Jul
3 years ago

berkayk started a new conversation Auth::user() Returns Unexpected User

Hi,

I have a Laravel 5 app where users write some questions etc. Sometimes, Auth::user() returns another user's data and I am not able to find what causes this.

For instance, I have only one user in the database with status field is set to 1, where all others are defaulted to **0**. But sometimes, I see some users' questsions posted as admin. The method (in User model) I am using is pretty simple like

public function isAdmin(){
        return $this->status == 1;
    }

What could be causing this problem? From the logs I have written, Auth::user() returns an unexpected user, not this simple function is failing.

Thanks in advance.

24 Jul
3 years ago

berkayk left a reply on Querying Using Pivots

Ok, I am familiar with iterating through photos but there may be photos with different tags in the same post. I need to filter those before iterating.

Anyway, I guess this can be done inside Post model file, thanks for your answer.

$posts = Post::with('photos')->whereHas('photos.tags', function ($query) use ($tag_id) {

    $query->where('id', '=', $tag_id);

});

I didn't know how to join tables with this syntax. Problem solved.

Cheers.

berkayk left a reply on Querying Using Pivots

Thanks pmall for the answer. You are right, I couldn't explain clearly. I will try to explain with examples.

Let's say for tag 2,

Post 1 has photos with id: 1001, 1002, 1003 Post 2 has photos with id: 2001, 2002, 2007

In my view, I would like to show them like

1001 (and two other photos) 2001 (and 1 other photo)

So, I need to loop over posts, but I still want to get other photos in the same post.

Hope this clear things up.

Thanks again.

berkayk started a new conversation Querying Using Pivots

Hi,

I am building a simple web app where each Post hasMany Photo and each Photo belongsToMany Tag with photo_tag pivot table. Everything works fine, however, I am not able to get photos in a post with given tag id.

For instance, I am getting photos with tag.id = 2, with

$tag = Tag::find($tagId);
$photos = $tag->photos()->groupBy('post_id')->orderBy('post_id','desc')-get();

This gives me all posts which have at least one photo with tag 2. From this point, I would like to query other photos in a given post with the same tags. Below are my models.

Thanks for the help.

Post model:

public function photos(){
        return $this->hasMany('App\Models\Photo', 'post_id');
    }

Photo model:

public function post(){
        return $this->belongsTo('App\Models\Post','post_id');
    }

public function tags(){
        return $this->belongsToMany('App\Models\Tag', 'photo_tag', 'photo_id', 'tag_id');
    }

and finally Tag model

public function photos(){
        return $this->belongsToMany('App\Models\Photo');
    }

What I did so far is to get

03 Jan
4 years ago

berkayk left a reply on Querying Models With Contains

Thank you very much for both answers.

02 Jan
4 years ago

berkayk left a reply on Querying Models With Contains

Thanks for the fast reply Cocoon :) I think PostPresenters will be an advanced thing for me to do right now. How can I implement hasUser method on Like model. I have read all of the methods in #collections link you have mentioned but couldn't find a way to inject that logic into my model :)

Thanks.

berkayk started a new conversation Querying Models With Contains

Hi all, I am trying to implement a blog where posts are being commented and liked. I have defined relations such that a post has many likes(or comments) and a like(or comment) belongs to a post etc. Everything is working fine but I need to find a way whether a post is liked by a user or not. In the controller, before liking a post, I have iterated through all likes of the post and checked for the author_id. This is working fine but I couldn't find a good way to put these on the view side.

$post->likes->contains(Auth::user()) doesn't work because contains expects the key of the like.

Currently, I am looping through all likes and trying to find a match with the user id. Is this the optimized way of doing it or am I missing something?