mykelcodex

mykelcodex

Web Developer at Twingle Inc

Member Since 2 Years Ago

Lagos

Experience Points
8,230
Total
Experience

1,770 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
60
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • 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.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    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 2
8,230 XP
Dec
16
2 months ago
Activity icon

Started a new Conversation Pass Id Instead Of Name In Vuejs

Hi guys,

I am integrating a tag system in my app, but instead of me passing the id, I am passing the name, please how do I pass the id to the tags[] array?


<div class="mt-2 relative">
                  <input
                   v-model="tag"
                   class="text-sm tw-input appearance-none rounded outline-none w-full p-3 text-md leading-tight"
                   id="title" type="text" placeholder="Enter Tags">
                  <span class="tags-input-tag mt-2" v-for="(tag, index) in form.tags" :key="index">
                    <span>{{ tag }}</span>
                    <button type="button" class="tags-input-remove text-white font-sm leading-none" @click="removeTag(tag)">&times;</button>
                  </span>
                  <div v-if="sending" class="inset-y-0 absolute pointer-events-none right-0 mr-4 flex items-center">
                  </div>
<div v-if="showTag" class="z-50 absolute tw-card shadow">
                    <div class="w-full" v-if="fetchedTag.length > 0">
                      <span class="flex items-center cursor-pointer py-2 px-6 border-b-2 hover:bg-gray-300" @click="addTag(result.id,result.name)" v-for="result in fetchedTag" :value="result.id" :key="result.id">
                        <img :src="result.image_url" class="w-10 rounded-full" alt="">
                        <p class="ml-2">{{ result.name }}</p>
                      </span>
                    </div>
                  </div>

now I am adding a tag by doing this,


data(){
    return{
      form:{
        title:'',
        tags:[],
        body:''
      },
      fetchedTag:[],
      tag:'',
      sending:false,
      showTag:true,
    }
  },

addTag(id,name){
      this.form.tags.push(name)
      this.tag =''
      this.fetchedTag ='' "
    },

How can I push the id to tag[] and display the name in the tags array on the user's end?

Nov
27
2 months ago
Activity icon

Started a new Conversation Route Is Broken After While Trying To Authenticate Using Passport

hi guys,

Please i need some help, all API routes was working fine until i tried to authenticate and hitting this endpoint http://localhost:8000/api/login

public function login(Request $request){

        $http = new \GuzzleHttp\Client;

        try {
            $response = $http->post('http://localhost:8000/oauth/token',[
                
                'form_params' => [
                    'grant_type'=>'password',
                    'client_id'=>2,
                    'client_secret'=> '1yZCan6QUUmEDXW09iUCz3W4IAXImH5xhr9QebDM',
                    'username'=>$request->username,
                    'password'=>$request->password,

                    ]
                ]);
            return $response->getBody();
            } catch (\GuzzleHttp\Exception\BadResponseException $e){
                if ($e->getCode() === 400){
                    return response()->json('Invalid Request, Please enter a username and password.', $e->getCode());
                }elseif ($e->getCode() === 401){
                    return response()->json('Credentials are incorrect, Please try again', $e->getCode());
                }
            return response()->json('Something went wrong on the serve', $e->getCode());            

    }
}

after hitting this route, i can no longer access http://localhost:8000, it just not going.

Please am i doing anything wrong?

Oct
19
4 months ago
Activity icon

Replied to Adding Up Price Per Week With Transactions

@nakov, it does and it worked..thank you

Activity icon

Replied to Adding Up Price Per Week With Transactions

Hi, @nakov , i have this in my controller


 public function cashout($id){

$transactions = Transaction::where('user_id',$id)->orderBy('created_at','desc')->get()->groupBy(function($date) {
      return Carbon::parse($date->created_at)->format('W');
             })->map(function ($row) {
             return $row->toArray() + ['total' => $row->sum('product_price')]
                    ;
               });

         return view('cashout')->with(['transactions'=>$transactions]);
    }

and i have this in my view


@foreach($transactions as $week =>$transactions)

{{ count($transactions) }} {{ count($transactions) <= '1' ? 'Transaction' : 'Transactions' }} was made

@foreach($transactions as $trans)

<th scope="row">
       {{ $trans['product_name'] }}
    ......
 </th>

@endforeach
@endforeach

Oct
18
4 months ago
Activity icon

Replied to Adding Up Price Per Week With Transactions

@nakov , i have an issue with the total in my view, how do i fix this. It show an extra field?

Activity icon

Replied to Adding Up Price Per Week With Transactions

thanks @nakov , i sincerely appreciate. :)

Activity icon

Replied to Adding Up Price Per Week With Transactions

@nakov , It returned this, and i can't loop through

array:5 [▼
  42 => array:3 [▼
    0 => array:15 [▶]
    1 => array:15 [▼
      "id" => 1
      "user_id" => 3
      "product_id" => 1
      "transactionId" => "136537621"
      "orderId" => "#00000002"
      "product_name" => "Lonart"
      "product_description" => "Artemether 80mg, Lumefantrine 480mg"
      "product_price" => "5"
      "buyer_name" => "Oke Michael"
      "status" => "success"
      "created_at" => "2019-10-16 10:22:15"
      "updated_at" => "2019-10-16 10:22:15"
    ]
    "total" => 10
  ]
  41 => array:2 [▶]
  40 => array:5 [▶]
  39 => array:2 [▶]
  34 => array:2 [▶]
]

My blade

@foreach($transactions as $week =>$transactions)

{{ $transactions->count() }} {{ $transactions->count() <= '1' ? 'Transaction' : 'Transactions' }} was made

@foreach($transactions as $trans)

<th scope="row">
       {{ $trans->product_name }}
 </th>

@endforeach
@endforeach

but i kept getting an error

Activity icon

Replied to Adding Up Price Per Week With Transactions

@nakov , it worked. thank you

Activity icon

Started a new Conversation Adding Up Price Per Week With Transactions

I have this


$weekly_price = Transaction::where('user_id',$id)->orderBy('created_at','desc')->get()->groupBy(function($date) {
              return Carbon::parse($date->created_at)->format('W');
              })->map(function ($row) {
                  return $row->sum('product_price');
             });



$weekly_transaction = Transaction::where('user_id',$id)->orderBy('created_at','desc')->get()->groupBy(function($date) {
            return Carbon::parse($date->created_at)->format('W');
            });

The first code returns only the total price for weekly transactions, while the second code returns only weekly transactions in details.

How do i get to return weekly transactions alongside with the total price?

Oct
11
4 months ago
Activity icon

Replied to Display Weekly Transactions Alongside The Sum Of Product Price Column

hey @douglasakula , i would appreciate if you can show me how?

Activity icon

Started a new Conversation Display Weekly Transactions Alongside The Sum Of Product Price Column

Hey guys,

i have this code in my controller which displays the total amount of product price(weekly)


$weekly = Transaction::where('user_id',$id)->orderBy('created_at','desc')->get()->groupBy(function($date) {
             return Carbon::parse($date->created_at)->format('W');
             })->map(function ($row) {
                 return $row->sum('product_price');
             });

i also have this which displays the transactions(weekly)


$weekly = Transaction::where('user_id',$id)->orderBy('created_at','desc')->get()->groupBy(function($date) {
             return Carbon::parse($date->created_at)->format('W');
             });

i want to display the weekly transactions alongside the total of the product price(weekly). Please how do i do this?

Oct
10
4 months ago
Activity icon

Started a new Conversation Sum Column

Hey guys,

i have this code in my controller which displays the total amount of product price(weekly)


$weekly = Transaction::where('user_id',$id)->orderBy('created_at','desc')->get()->groupBy(function($date) {
             return Carbon::parse($date->created_at)->format('W');
             })->map(function ($row) {
                 return $row->sum('product_price');
             });

i also have this which displays the transactions(weekly)


$weekly = Transaction::where('user_id',$id)->orderBy('created_at','desc')->get()->groupBy(function($date) {
             return Carbon::parse($date->created_at)->format('W');
             });

i want to display the weekly transactions alongside the total of the product price(weekly). Please how do i do this?

Oct
03
4 months ago
Activity icon

Replied to Pass More Than One Value To Input Field

@geowrge

array:10 [▼
  "_token" => "qNhxlgaM7Z4Q6sEn0tMqcFXJepHOsl1jVgxmv8Cy"
  "amount" => "10,300"
  "payment_method" => "both"
  "description" => "Product from Abek Store"
  "country" => "NG"
  "currency" => "NGN"
  "email" => "[email protected]"
  "firstname" => "Careclick"
  "metadata" => "[{"metaname":"color","metavalue":"blue"},{"metaname":"size","metavalue":"big"}]"
  "phonenumber" => "08168696515"
]

i am trying to achieve something like this as seen above in my metadata

i have a button for payment, how can i iterate through the Cart::content and have it in my metadata


<td data-column="Card Payment">
                  @php
                  $array = array(array('metaname' => 'color', 'metavalue' => 'blue'),
                                  array('metaname' => 'size', 'metavalue' => 'big'));
                  @endphp
                  <form method="POST" action="{{ route('pay') }}" id="paymentForm">
                      {{ csrf_field() }}
                      <input type="hidden" name="amount" value="{{ Cart::total() }}" />
                      <input type="hidden" name="payment_method"value= "both" /> 
                      <input type="hidden" name="description" value="Product from {{ $item->model->user->name}} Store" />
                      <input type="hidden" name="country" value="NG"/>
                      <input type="hidden" name="currency" value="NGN" />
                      <input type="hidden" name="email" value="{{ Auth::user()->email }}" /> 
                      <input type="hidden" name="firstname" value="{{ Auth::user()->name }}" />
                      <input type="text" name="metadata" value="{{ json_encode($array) }}" >
                      <input type="hidden" name="phonenumber" value="{{ Auth::user()->phone }}" /> 
                     <input class="text-sm w-full bg-green-500 text-white px-2 py-1 rounded shadow" type="submit" value="Pay with card"  />
                  </form>
              </td>

Activity icon

Replied to Pass More Than One Value To Input Field

sorry @ashbakernz , please check again

Activity icon

Started a new Conversation Pass More Than One Value To Input Field

I already have this in my blade which returns the total name of products in cart


@php
     foreach (Cart::content() as $item){
    $array = $item->name;
         dump($array);  
    }
 @endphp

Please how can i pass it to the value of my input field?

<input type="hidden" name="metadata" value="{{ $array }}" >

Activity icon

Replied to Foreach Is Only Returning The First Value

@resin @skauk I want to pass the details of the product as a metadata


<?php
                foreach (Cart::content() as $item){
                   $array = [
                     'product_name'=> $item->name
                    
                    ];
                }
  ?>
<h3>Buy Movie Tickets N500.00</h3>
<form method="POST" action="{{ route('pay') }}" id="paymentForm">
    {{ csrf_field() }}
    <input type="hidden" name="amount" value="500" /> <!-- Replace the value with your transaction amount -->
    <input type="hidden" name="payment_method" value="both" /> <!-- Can be card, account, both -->
    <input type="hidden" name="description" value="Beats by Dre. 2017" /> <!-- Replace the value with your transaction description -->
    <input type="hidden" name="country" value="NG" /> <!-- Replace the value with your transaction country -->
    <input type="hidden" name="currency" value="NGN" /> <!-- Replace the value with your transaction currency -->
    <input type="hidden" name="email" value="[email protected]" /> <!-- Replace the value with your customer email -->
    <input type="hidden" name="firstname" value="Oluwole" /> <!-- Replace the value with your customer firstname -->
    <input type="hidden" name="lastname" value="Adebiyi" /> <!-- Replace the value with your customer lastname -->
    <input type="hidden" name="metadata" value="{{ json_encode($array) }}" > <!-- Meta data that might be needed to be passed to the Rave Payment Gateway -->
    <input type="hidden" name="phonenumber" value="090929992892" /> <!-- Replace the value with your customer phonenumber -->
    {{-- <input type="hidden" name="paymentplan" value="362" /> <!-- Ucomment and Replace the value with the payment plan id --> --}}
    {{-- <input type="hidden" name="ref" value="MY_NAME_5uwh2a2a7f270ac98" /> <!-- Ucomment and  Replace the value with your transaction reference. It must be unique per transaction. You can delete this line if you want one to be generated for you. --> --}}
    {{-- <input type="hidden" name="logo" value="https://pbs.twimg.com/profile_images/915859962554929153/jnVxGxVj.jpg" /> <!-- Replace the value with your logo url (Optional, present in .env)--> --}}
    {{-- <input type="hidden" name="title" value="Flamez Co" /> <!-- Replace the value with your transaction title (Optional, present in .env) --> --}}
    <input type="submit" value="Buy"  />
</form>

But i keep getting this after

dump(request()->all());


array:10 [▼
  "_token" => "qNhxlgaM7Z4Q6sEn0tMqcFXJepHOsl1jVgxmv8Cy"
  "amount" => "5,800"
  "payment_method" => "both"
  "description" => "Product from Abek Store"
  "country" => "NG"
  "currency" => "NGN"
  "email" => "[email protected]"
  "firstname" => "Careclick"
  "metadata" => "{"product_name":"Paracetamol"}"
  "phonenumber" => "08168696515"
]

Activity icon

Replied to Foreach Is Only Returning The First Value

ok @skauk,

After dump(Cart::content())

CartItem {#1185 ▼
  +rowId: "370d08585360f5c568b18d1f2e4ca1df"
  +id: 2
  +qty: "1"
  +name: "Paracetamol"
  +price: 4500.0
  +weight: 10.0
  +options: CartItemOptions {#1186 ▶}
  -associatedModel: "App\PProduct"
  -taxRate: 0
  -discountRate: 0
}
CartItem {#1187 ▼
  +rowId: "027c91341fd5cf4d2579b49c4b6a90da"
  +id: 1
  +qty: 1
  +name: "Lonart"
  +price: 1300.0
  +weight: 10.0
  +options: CartItemOptions {#1188 ▶}
  -associatedModel: "App\PProduct"
  -taxRate: 0
  -discountRate: 0
}

Now trying to do this in my blade


<div>
@php
    foreach (Cart::content() as $item){
      dd($item->toArray());
      // $array = array('user_id' => $item->model->user->id, 'product_id'=>$item->model->product->id);
         }
 @endphp
</div>

i get just the first value.

Activity icon

Replied to Foreach Is Only Returning The First Value

@skauk very true but iterating as well, i get the first value alone

Activity icon

Started a new Conversation Foreach Is Only Returning The First Value

I am currently building a store and i am using Crinsane package but i found out that after trying to iterate over the cart item, i only get the first item but after dd(Cart::content()) i get a collection of all the items in the cart.


public function test(){

        foreach(Cart::content() as $row) {
            dd($row);

    }
}

please how do i go about this?

Sep
27
4 months ago
Activity icon

Replied to Create A Table With Foreign Key

Hi @munazzil , thanks for your swift response. i just tried this but i am still getting the same response error

Activity icon

Started a new Conversation Create A Table With Foreign Key

Anytime i tried creating this table i get

PDOException::("SQLSTATE[HY000]: General error: 1005 Can't create table store.products (errno: 150 "Foreign key constraint is incorrectly formed")")

Products Table


Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('category_id');
            $table->foreign('category_id')->references('id')->on('categories');
            $table->string('product_name');
            $table->string('product_image');
            $table->string('product_price');
            $table->string('brand');
            $table->string('product_description');
            $table->string('prescription_status')->nullable();
            $table->string('store_name');
            $table->timestamps();
        });

Category Name

Schema::create('categories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('category_name');
            $table->timestamps();
        });

Sep
10
5 months ago
Activity icon

Replied to Edit And Update With The Eloquent ORM

you are calling the create method instead of the update method like this

 $user->client->update([
......
]);
Aug
31
5 months ago
Activity icon

Replied to Illegal String Offset 'customer'

You are right @snapey , Thank you.

Activity icon

Started a new Conversation Illegal String Offset 'customer'

I have this in my controller

public function transactions(){
        $subs = Rave::listSubscriptions();
        $sub = $subs->data->plansubscriptions;
        
        return view('transactions',compact('subs'));
    }

I am trying to display this in my blade view like this

      @foreach ($subs as $sub)
                <tr>
                   <td>{{ $loop->iteration }}</td>
                   <td class="font-size-sm">{{ $sub['customer']['customer_email'] }}</td>
        </tr>
         @endforeach

but i keep getting "Illegal string offset 'customer'"

public function transactions(){
        $subs = Rave::listSubscriptions();
        $sub = $subs->data->plansubscriptions;
        dd($sub)
        return view('transactions',compact('sub'));
    }
array:10 [▼
  0 => {#482 ▼
    +"id": 3840
    +"amount": 1000
    +"customer": {#483 ▼
      +"id": 67773583
      +"customer_email": "[email protected]"
    }
    +"plan": 3249
    +"status": "cancelled"
    +"date_created": "2019-08-29T03:37:12.000Z"
  }
  1 => {#484 ▼
    +"id": 3839
    +"amount": 1000
    +"customer": {#485 ▶}
    +"plan": 3249
    +"status": "active"
    +"date_created": "2019-08-29T03:30:36.000Z"
  }
  2 => {#486 ▶}
  3 => {#488 ▶}
  4 => {#490 ▶}
  5 => {#492 ▶}
  6 => {#494 ▶}
  7 => {#496 ▶}
  8 => {#498 ▶}
  9 => {#500 ▶}
]

Please, how can i resolve this?