zabarah

zabarah

Member Since 4 Months Ago

Experience Points
9,270
Total
Experience

730 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
89
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 2
9,270 XP
May
09
3 weeks ago
Activity icon

Replied to What Is The Best Way To Add 2 Values In A Select Drop Option?

Should I just stick with the explode route?

May
08
3 weeks ago
Activity icon

Replied to What Is The Best Way To Add 2 Values In A Select Drop Option?

"locations" => array:3 [▼
    	"key" => "2123",
	"type" => "country"
	"name" => "Canada"
  ]
Activity icon

Started a new Conversation What Is The Best Way To Add 2 Values In A Select Drop Option?

I am looping through an api results that provides both a key and subkey that I need sent as a value for one option.

Currently I am adding both values and exploding them on the controller.

<select name="location" id="location" class="">
      @foreach($locations as $location)
            <option value="{{$location['type'] .'_' . $location['key'] }}">{{  $location['name]  }}</option>
      @endforeach
</select>

and then in controller

$location = $research->locationFilter(explode('_', $request->location));

I would need to do this for 12 other inputs about the same way. Is there a more elegant and efficient method to do this?

Apr
30
1 month ago
Activity icon

Replied to Laravel/Cashier Stripe Webhook On Failed Subscription

Got it. Just to be clear. This will just extend it, it wont over ride the current controller for the subscription deleted, in the cashier controller.

Thank you so much!

Activity icon

Started a new Conversation Laravel/Cashier Stripe Webhook On Failed Subscription

Hey All,

I am trying to implement the following function once cashier receives the cancelled subscription webhook from stripe, but I dont understand where to put it.

if($user->subscription('team')){
     $user->team->members()->detach();
}

I found the webhook functions in the [email protected], but it wasn't super clear to me where the cancelled subscription function was.

If anyone can shed some light for me that would be awesome.

Apr
29
1 month ago
Activity icon

Awarded Best Reply on Socialite/Facebook Adding To Database

I was actually able to solve with this

foreach ($adAccounts as $adAccount){
                for ($i=1; $i<count($adAccount); $i++){
                    $x = $adAccount[$i];
                    $newAdAccount = new AdAccount();
                    $newAdAccount->account_id = $x['id'];
                    $newAdAccount->account_name = $x['name'];
                    $newAdAccount->user_id = $user->getId();
                    $newAdAccount->save();
                }
            }
Apr
08
1 month ago
Activity icon

Replied to Switching 2 Values In Database Same Column.

For anyone who may have the same issue, this worked beautifully for me.

//Changing current primary page to 0
$original = Auth::user()->pages()->firstWhere(['primary'=>1]);
$original->update(['primary' => 0]);

//Changing chosen account as primary page
$chosen = Auth::user()->pages()->findOrFail($id);
$chosen->update(['primary' => 1]);
Activity icon

Replied to Switching 2 Values In Database Same Column.

Got it. Rather than create a new one, I want to change the new chosen one as the primary.

So the best way would be to on press:

  1. Change the chosen page primary to 1
  2. Change the current page primary to 0.

So it would essentially run 2 queries.

Thank you!!

Apr
07
1 month ago
Activity icon

Started a new Conversation Switching 2 Values In Database Same Column.

Hey All,

I am trying to setup a dropdown where a user can select a preferred page in his account.

My database has a user table and pages table with relation to the user table.

In the pages table I have a primary column with 0 or 1 - 1 being the primary.

How can I make it so when a user chooses a new page it switches the primary column for that new page to be 1 and changing the old page to 0.

Note: only 1 page connected to the can have 1 in the primary column.

Jan
31
4 months ago
Activity icon

Replied to Socialite/Facebook Adding To Database

I was actually able to solve with this

foreach ($adAccounts as $adAccount){
                for ($i=1; $i<count($adAccount); $i++){
                    $x = $adAccount[$i];
                    $newAdAccount = new AdAccount();
                    $newAdAccount->account_id = $x['id'];
                    $newAdAccount->account_name = $x['name'];
                    $newAdAccount->user_id = $user->getId();
                    $newAdAccount->save();
                }
            }
Activity icon

Replied to Socialite/Facebook Adding To Database

hey @singhwithlaravel

Thank you very much for the reply. but that would mean I would need to specify the exact values, which I am unable to do in my case because I am getting the json call from FB.

$adAccounts = $user->getAdAccounts();
$newUser = new User();
$data = [
              'account_id'=>'id',
              'account_name'=>'name',
              'user_id'=> '10003'
            ];
return $newUser->adAccounts()->create($data);
Jan
30
4 months ago
Activity icon

Started a new Conversation Socialite/Facebook Adding To Database

Hey All,

I am still learning laravel and decided to dive head first into building a project. I do have a fair bit of knowledge but I am stuck on this aspect.

I used socialite to login a user using Facebook and modified it a bit to include a bit more information such as 'birthday', 'ad accounts' and 'facebook pages'.

The ad accounts returns an array within an array:

Laravel\Socialite\Two\User {#296 ▼ +token: "REDACTED ▶" +refreshToken: null +expiresIn: null +id: "2342342325763" +nickname: null +name: "Zabarah" +email: "[email protected]" +avatar: "https://graph.facebook.com/v5.0/82342342325763/picture?type=normal" +user: array:7 [▶] +"birthday": "04/20/1969" +"accounts": array:2 [▶] +"adaccounts": array:2 [▼ "data" => array:9 [▼ 0 => array:2 [▶] 1 => array:2 [▶] 2 => array:2 [▶] 3 => array:2 [▶] 4 => array:2 [▶] 5 => array:2 [▶] 6 => array:2 [▶] 7 => array:2 [▶] 8 => array:2 [▼ "name" => "ad account#2" "id" => "act_517861234234935" ] ] "paging" => array:1 [▶] ] +"avatar_original": "https://graph.facebook.com/v5.0/8623423425763/picture?width=1920" +"profileUrl": null }

and this is my controller to save it

public function fbCallBack(){ $user = Socialite::driver('facebook')->fields(self::fbFields)->user();

    if ($user){
        $newUser = new User();
        $newUser->name = $user->getName();
        $newUser->email = $user->getEmail() == '' ? '' : $user->getEmail();
        $newUser->password = '';

        // I setup a relationship between Adaccount model and User model
        $newUser->adAccounts()= $user->getAdAccounts();

        $newUser->save();
        $newUser = $user;
    }
    return redirect('/');
}

So my question is, how do i save the (array within the array) ad account name and id into the DB?