Member Since 4 Years Ago

Experience Points

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
Best Reply Awards
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    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 1
4,870 XP
11 Jul
2 years ago

berkayk started a new conversation Session Driver Performance


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.


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();


18 Sep
4 years ago

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


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)


14 Aug
4 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//

Thanks in advance.

10 Aug
4 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) {




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

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

Am I missing something?

28 Jul
4 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);
                        // 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;


if (Auth::check()){
    return redirect($redirectURI);
    return redirect('login');


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.


27 Jul
4 years ago

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


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
4 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.


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


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 = 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');
03 Jan
4 years ago

berkayk left a reply on Querying Models With Contains

Thank you very much for both answers. I guess that method should be

public function isLikedBy($user) {
    $likes = $this->likes->all('user_id')->toArray();
    if(in_array($user->id, $likes)) {  // --> Changed here
        return true;
    return false;
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 :)


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?