KalimeroMK

KalimeroMK

Member Since 3 Months Ago

Experience Points
14,380
Total
Experience

620 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
123
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 3
14,380 XP
Apr
02
3 days ago
Activity icon

Started a new Conversation Pass String To Route Name

My route

Route::get(
                    'experience/{type}/create',
                    [
                        'as' => 'experience.create',
                        'uses' => '\App\Http\Controllers\[email protected]'
                    ]
                );

url : experience/pages/create (type was add manual in in the url in blade) now I want to use route name

{{route('experience.create', ['type => pages'])}}

so my question, is this good practice or not and it will work or not

Mar
26
1 week ago
Activity icon

Replied to Use Of Undefined Constant

fix it by adding single quotes acted of an apostrophe

{{ route('client-prefix.launchpad.index', [‘client’ => ClientContext::get()->eid]) }}
Mar
25
1 week ago
Activity icon

Started a new Conversation Use Of Undefined Constant

Don't understand the error and how to fix it

Tests\Feature\TicketControllerTest::testSetStatusWithMismatchedClientAndTicket ErrorException: Use of undefined constant ‘client - assumed '‘client' (this will throw an Error in a future version of PHP) (View: /var/www/tether/resources/views/errors/500.blade.php)

public function testSetStatusWithMismatchedClientAndTicket()
    {
        // Arrange
        $otherClient = factory(Client::class)->create(['name' => 'Not Visible Client']);
        $visibleClient = factory(Client::class)->create(['name' => 'Visible Client']);

        $campaign = factory(Campaign::class)->create(['client_id' => $otherClient->id]);

        $participant = factory(Participant::class)->create();
        $person = factory(ClientParticipant::class)->create([
            'client_id' => $otherClient->id,
            'participant_id' => $participant->id,
        ]);

        $ticket = factory(Ticket::class)->create([
            'client_id' => $otherClient->id,
            'campaign_id' => $campaign->id,
            'participant_client_id' => $person->id
        ]);

        $user = factory(User::class)->create();
        $user->clients()->attach($visibleClient);
        $this->actingAs($user);
        Passport::actingAs($user);

        // Act
        $response = $this->post(
            '/' . $visibleClient->eid . '/ticket/' . $ticket->fresh()->eid . '/set-status',
            ['status' => 'escalated']
        );

        // Arrange
        $response->assertStatus(403);
    }

and the blade

@extends('auth.layout')
@section('content')

    <style>
        body {
            display: block !important
        }
    </style>

    <div class="login loginBg" ng-cloak>
        <md-content class="md-padding loginBg">
            <md-card class="md-whiteframe-2dp">

                <md-card-content layout="column" layout-align="center center">

                    <h1 class="md-display-2 logo">tether</h1>
                    <h6 style="text-align:center">Internal Server Error (#500)</h6>
                    <a href="{{ route(‘client-prefix.launchpad.index’, [‘client’ => ClientContext::get()->eid]) }}">Return
                        to launchpad</a>

                </md-card-content>

            </md-card>
            <br/>
        </md-content>
    </div>

@endsection
Activity icon

Replied to Remove Extra Characters After File Extension

already try this not working

Activity icon

Started a new Conversation Remove Extra Characters After File Extension

I save an image from URL to storage using Intervention image but have a problem when the image come in this format

104202.jpg?w=318&#038;h=480

hot to stip everything after image extension

Mar
24
1 week ago
Activity icon

Replied to Test Invitation Mail

txh man

Activity icon

Replied to Test Invitation Mail

  1. Tests\User\Controllers\UserControllerTest::testStoreWithInvitationMail Illuminate\Session\TokenMismatchException:
Activity icon

Replied to Test Invitation Mail

this is the error mail is not sending don't understand why

  1. Tests\User\Controllers\UserControllerTest::testStoreWithInvitationMail The expected [App\Mail\UserProfileCreated] mailable was sent 0 times instead of 1 times. Failed asserting that false is true.
Activity icon

Replied to Test Invitation Mail

code refactored to

public static function sendWelcomeEmail($user)
    {
        $token = app('auth.password.broker')->createToken($user);
        Mail::to($user->email)->send(new UserProfileCreated($user->language, $user->mailerId, $token));
    } 

but test still not working

Activity icon

Started a new Conversation Test Invitation Mail

When admin create a user it sends invitation email with a password reset link and it working nice when is sending the mail manually on the staging server but need to write a test but when run the test is failing hire is my code

Controller

public function store(CreateUser $request)
    {
        $input = $request->validated();
        if ($user = User::getByEmail($input['email'], true)) {
            $user->deleted_at = null;
        } else {
            $user = new User;
        }

        $client = ClientContext::get();

        $user->email = $input['email'];
        $user->name = $input['name'];
        $user->phone = $client->shortcodes()->first()->phoneFormatter()->format($input['phone']);
        $user->language = $input['language'];

        $client_id = $input['client_id'];

        $user->password = Hash::make(Str::random(64));

        $now = gmdate('Y-m-d H:i:s');
        $user->updated_at = $now;

        $user->save();

        $user->clients()->sync(
            [
                $client_id => [
                    'client_role_id' => $input['client_role_id'],
                    'timezone' => $input['timezone'],
                ],
            ],
            false
        );

        if (!empty($input['lists'])) {
            $lists = explode(',', $input['lists']);
            $user->lists()->sync($lists);
        }
        Cache::tags(['clients'])->forget("user.{$user->eid}.clients");

        if (isset($input['invite'])) {
            $email = app(Email::class);
            $email->subject = 'Profile created on ' . config('app.name');
            $mailerId = Uuid::uuid4()->toString();
            $email->mailer_id = $mailerId;
            $email->user_id = $user->id;
            $email->save();
            User::sendWelcomeEmail($user);
        }

        return redirect('/user');
    }

Model

public static function sendWelcomeEmail($user)
    {
        $token = app('auth.password.broker')->createToken($user);
        Mail::send('user.mail.profile-created', compact('token', 'user'), function ($m) use ($user) {
            $m->from(
                '[email protected]' . parse_url(config('app.url'), PHP_URL_HOST)
            );
            $m->to($user->email)->subject('Welcome to Tether');
            $headers = $m->getHeaders();
            $headers->addTextHeader('X-Mailer-ID', $user->mailerId);
        });
    }

Test

public function testStoreWithInvitationMail()
    {
        Mail::fake();

        $client = factory(Client::class)->create(['has_dedicated_shortcode' => true]);
        $shortcode = factory(Shortcode::class)->create();
        $client->shortcodes()->attach($shortcode);
        $person = factory(ClientParticipant::class)->states('email')->create([
                'client_id' => $client->id,
            ]);
        $user = $this->createAdministrator($client);
        Passport::actingAs($user);
        $clientRole = factory(ClientRole::class)->states(['mxco'])->create();

        $params = [
            'email' => $this->faker->email,
            'name' => $this->faker->name,
            'phone' => $this->faker->phoneNumber,
            'client_id' => $client->id,
            'client_role_id' => $clientRole->id,
            'language' => 'en',
            'timezone' => 'US/Eastern',
            'keyword' => null,
            'territory_number' => null,
            'invite' => true
        ];

        $response = $this
            ->actingAs($user)
            ->sessionClient($client)
            ->post('/user', $params);

        $this->assertEquals(302, $response->getStatusCode());

        Mail::assertSent(UserProfileCreated::class, 1);
    }

and the UserProfileCreated class

class UserProfileCreated extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * @var string
     */
    public $lang;

    /**
     * @var string
     */
    private $mailerId;

    public function __construct($lang, $mailerId)
    {
        $this->lang = $lang;
        $this->mailerId = $mailerId;
    }

    /**
     * Build the message.
     *
     * @return void
     */
    public function build()
    {
        $this->withSwiftMessage(function ($message) {
            $message->getHeaders()->addTextHeader('X-Mailer-ID', $this->mailerId);
        });

        $this->view('user.mail.profile-created')
            ->with(['$lang' => $this->lang])
            ->subject('Profile created on ' . config('app.name'))
            ->from(config('mail.from.address'), config('mail.from.name'));
    }
}
Mar
19
2 weeks ago
Activity icon

Started a new Conversation Class 'Illuminate\Support\Facades\Input' Not Found

After update to laravel 6 Class 'Illuminate\Support\Facades\Input' not found an error shows and in the controller I have a try

use Illuminate\Support\Facades\Input; use Input; but is the same

I bypass it adding

        'Input' => Illuminate\Support\Facades\Request::class,

in config app

Mar
17
2 weeks ago
Activity icon

Replied to Reload Page In Vue.js

thx man for the help and telling me the write way

Activity icon

Replied to Reload Page In Vue.js

this was the solution

                        this.$forceUpdate();  // Calling forceUpdate will only force the view to re-render.
Activity icon

Replied to Reload Page In Vue.js

Still noting show on generate how I see you have made a change on disable or I em wrong

Activity icon

Replied to Reload Page In Vue.js

can you show me what I need to do is my second day with vue.js and need to debag this

Activity icon

Started a new Conversation Reload Page In Vue.js

This is my component and when I click on generate button key is generating but is not showing until I press refresh how to fix it or to reload the page on click

<template>
    <div class="text-center">
        <div class="checkbox">
            <label>
                <input type="checkbox" v-model="toggle" :disabled="user.google2fa_secret"> {{ toggletext }}
            </label>
        </div>

        <hr>
        <div v-if="toggle">
            <div v-if="user.google2fa_secret">
                <p v-if="user.google2fa_secret">Your 2FA Secret Key</p>
                <h3>{{ user.google2fa_secret }}</h3>

                <button class="md-button md-raised md-accent" @click="disable">{{ disabletext }}</button>

                <p>Instructions for first time setup:</p>
                <p>Please install the <a :href="google_link">Google Authenticator</a> first.</p>
                <p>
                    You can install it from the
                    <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en">Google
                        Play</a> or
                    <a href="https://apps.apple.com/us/app/google-authenticator/id388497605">Apple Store</a>.
                </p>

                <p>Scan The QR code:</p>
                <img :src="qr_code" alt="qr_code"/>
                <br>

                <form action="/google2fa/authenticate" method="POST">
                    <input type="hidden" v-model="csrf" name="_token">
                    <input name="one_time_password" type="text">

                    <button type="submit">Authenticate</button>
                </form>


            </div>

            <div v-else>
                <button class="md-button md-raised md-accent" @click="generate">{{ generatetext }}</button>
            </div>
        </div>

        <div v-else>
            <p>You don't have the 2FA enabled.</p>
        </div>


    </div>

</template>

<script>
    import axios from 'axios';

    export default {
        name: "TwoFactorAuth",
        props: {
            qr: {
                type: String,
                required: false,
                default: '',
            },
            user: {
                type: Object,
                required: true,
            },
            toggletext: {
                type: String,
                required: true,
            },
            generatetext: {
                type: String,
                required: true,
            },
            disabletext: {
                type: String,
                required: true,
            },
        },
        data() {
            return {
                toggle: !!this.user.google2fa_secret,
                google_link: 'https://www.google.com/landing/2step/',
                qr_code: this.qr,
                csrf: ''
            }
        },
        methods: {
            generate() {
                axios.post(`/api/user/${this.user.eid}/2fa`)
                    .then(res => {
                        this.user.google2fa_secret = res.data.secret;
                        this.secret = this.user.google2fa_secret;
                        this.qr_code = res.data.qr;


                    })
                    .catch(this.handleError);
            },
            disable() {
                axios.post(`/api/user/${this.user.eid}/2fa`, {disable: true})
                    .then(res => {
                        this.user.google2fa_secret = res.data.secret;
                        this.qr_code = '';
                        this.toggle = false;
                    })
                    .catch(this.handleError);
            }
        },
        mounted() {
            this.csrf = document.head.querySelector('meta[name="csrf-token"]').content;

        }
    }
</script>

<style scoped>

</style>
Mar
16
2 weeks ago
Activity icon

Started a new Conversation Unit Test 2FA

have implemented Google 2 factor Authorization on my page and it is working but I was wondering if it possible to unit test it, if can be done, can someone tell me how to do it

Mar
12
3 weeks ago
Activity icon

Started a new Conversation Google2FA-Laravel Validation

I em using Google2FA-Laravel package and everything is ok but not find an example how to validate the numbers that are coming from my phone returns

Mar
11
3 weeks ago
Activity icon

Started a new Conversation Laravel Verification With 2FA Middleware

Have implemented on my page 2FA using Google2FA for Laravel package in users table I store the key in 'google2fa_secret' column and in clients table I have 'has_2fa' column where I store 1 for enabling 2fa and 0 if is disabled, now I need a way, Middleware of some to check if 2fa is enabled but no google2fa_secret key is generated to redirect me to link to generate one, and if 2fa is enabled and google2fa_secret key is generated redirect to URL with 2fa login and if 2fa is not enabled in client table to proceed to normal login and if

Activity icon

Replied to Unresolvable Dependency Resolving After Update To Laravel 7

on my end problem was in baum package for nested category remove it and it is ok

Mar
07
4 weeks ago
Activity icon

Started a new Conversation Unresolvable Dependency Resolving After Update To Laravel 7

In Container.php line 993:
                                                                               
  Unresolvable dependency resolving [Parameter #1 [ <required> $customStubPath ]] in class Illuminate\Database\Migrations\MigrationCreator
Activity icon

Started a new Conversation Attribute [auth] Does Not Exist. Update From Laravel6 To Laravel7

In RouteRegistrar.php line 92:
                                    
  Attribute [auth] does not exist.
Feb
21
1 month ago
Activity icon

Replied to Navbar Form Nested Categories

thx man you are the best

$categories = Category::whereNull('parent_id')
    ->with(['children' => function ($query) {
        $query->join('category_language', 'categories.id', '=', 'category_language.category_id');}
    ])
    ->where('workflow_id', '=', '1')
    ->join('category_language', 'categories.id', '=', 'category_language.category_id')
    ->where('code', '=', 'en')
    ->get();

; was missing

Activity icon

Replied to Navbar Form Nested Categories

in the category table store https://ibb.co/7GFsmYR

in pivot table store name is present https://ibb.co/4FKpXFT name and description code ... but use join in sql

Activity icon

Replied to Navbar Form Nested Categories

SQL

$categories = Category::find(64)
            ->join('category_language', 'categories.id', '=', 'category_language.category_id')
            ->where('code', '=', 'en');
        dd($categories);

dd

Illuminate\Database\Eloquent\Builder {#897 ▼
  #query: Illuminate\Database\Query\Builder {#797 ▶}
  #model: App\Models\Category {#938 ▼
    #table: "categories"
    #fillable: array:8 [▶]
    #connection: "mysql"
    #primaryKey: "id"
    #keyType: "int"
    +incrementing: true
    #with: []
    #withCount: []
    #perPage: 15
    +exists: true
    +wasRecentlyCreated: false
    #attributes: array:14 [▼
      "id" => 64
      "slug" => "subcategory1-0"
      "name" => ""
      "description" => ""
      "image" => ""
      "file" => ""
      "filename" => ""
      "parent_id" => 63
      "left" => 6
      "right" => 7
      "depth" => 1
      "created_at" => "2020-02-20 20:38:08"
      "updated_at" => "2020-02-20 20:38:08"
      "workflow_id" => 1
    ]
    #original: array:14 [▶]
    #changes: []
    #casts: []
    #dates: []
    #dateFormat: null
    #appends: []
    #dispatchesEvents: []
    #observables: array:2 [▶]
    #relations: []
    #touches: []
    +timestamps: true
    #hidden: []
    #visible: []
    #guarded: array:1 [▶]
  }
  #eagerLoad: []
  #localMacros: array:3 [▼
    "reOrderBy" => Closure($builder, $column = null, $direction = 'asc') {#900 ▶}
    "unscoped" => Closure(Builder $builder) {#899 ▶}
    "scopedBy" => Closure(Builder $builder, $scopedBy = []) {#898 ▶}
  ]
  #onDelete: null
  #passthru: array:17 [▶]
  #scopes: array:2 [▼
    "Baum\NestedSet\Scopes\OrderingScope" => Baum\NestedSet\Scopes\OrderingScope {#791}
    "Baum\NestedSet\Scopes\ScopedByScope" => Baum\NestedSet\Scopes\ScopedByScope {#792}
  ]
  #removedScopes: []
}
Activity icon

Replied to Navbar Form Nested Categories

the name is camming form a pivot table and with SQL

Category::join('category_language', 'categories.id', '=', 'category_language.category_id')
            ->where('code', '=', 'en')
            ->get();

and foreach

 @foreach ($categories as $category)
                                    <li value="{{ $category->id }}">@for ($i = 0; $i < $category->depth; $i++)
                                            - @endfor <a
                                            href="{{ route('categories.edit', $category->id) }}"> {{ $category->name }}</a>
                                    </li>
                                @endforeach

Name i shown but when use

$categories = Category::whereNull('parent_id')->with('children')
            ->join('category_language', 'categories.id', '=', 'category_language.category_id')
            ->where('code', '=', 'mk')
            ->get();

and this foreach

@foreach ($categories as $category)
                                                        {{ $category->name }}
                                                        @foreach($category->children as $subcategory)
                                                            {{$subcategory->nane}}
                                                        @endforeach
                                                    @endforeach

no name in second foreach and the data is camming fom same teble

Feb
20
1 month ago
Activity icon

Replied to Navbar Form Nested Categories

Change the foreach form name to id

 @foreach ($categories as $category)
                                                        <li class="dropdown"><a
                                                                href="#">{{$category->name}}</a>
                                                        </li>
                                                        @foreach ($category->children as $children)
                                                            <li class="dropdown"><a
                                                                    href="#">{{ $children->id }}</a>
                                                            </li>
                                                        @endforeach
                                                    @endforeach

dd

Illuminate\Database\Eloquent\Collection {#905 ▼
  #items: array:3 [▼
    0 => App\Models\Category {#941 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 61
        "slug" => "category-0"
        "name" => "Category"
        "description" => "sdad"
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => null
        "left" => 1
        "right" => 4
        "depth" => 0
        "created_at" => "2020-02-20 20:35:22"
        "updated_at" => "2020-02-20 20:36:33"
        "workflow_id" => 1
        "category_id" => 61
        "language_id" => 1
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: array:1 [▼
        "children" => Illuminate\Database\Eloquent\Collection {#945 ▼
          #items: array:1 [▼
            0 => App\Models\Category {#982 ▼
              #table: "categories"
              #fillable: array:8 [▶]
              #connection: "mysql"
              #primaryKey: "id"
              #keyType: "int"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: true
              +wasRecentlyCreated: false
              #attributes: array:14 [▼
                "id" => 62
                "slug" => "subcategory-0"
                "name" => ""
                "description" => ""
                "image" => ""
                "file" => ""
                "filename" => ""
                "parent_id" => 61
                "left" => 2
                "right" => 3
                "depth" => 1
                "created_at" => "2020-02-20 20:36:33"
                "updated_at" => "2020-02-20 20:36:33"
                "workflow_id" => 1
              ]
              #original: array:14 [▶]
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: array:2 [▶]
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #guarded: array:1 [▶]
            }
          ]
        }
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
    1 => App\Models\Category {#942 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 63
        "slug" => "category1-0"
        "name" => "Category1"
        "description" => "dsa"
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => null
        "left" => 5
        "right" => 8
        "depth" => 0
        "created_at" => "2020-02-20 20:36:56"
        "updated_at" => "2020-02-20 20:38:08"
        "workflow_id" => 1
        "category_id" => 63
        "language_id" => 1
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: array:1 [▼
        "children" => Illuminate\Database\Eloquent\Collection {#940 ▼
          #items: array:1 [▼
            0 => App\Models\Category {#983 ▼
              #table: "categories"
              #fillable: array:8 [▶]
              #connection: "mysql"
              #primaryKey: "id"
              #keyType: "int"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: true
              +wasRecentlyCreated: false
              #attributes: array:14 [▼
                "id" => 64
                "slug" => "subcategory1-0"
                "name" => ""
                "description" => ""
                "image" => ""
                "file" => ""
                "filename" => ""
                "parent_id" => 63
                "left" => 6
                "right" => 7
                "depth" => 1
                "created_at" => "2020-02-20 20:38:08"
                "updated_at" => "2020-02-20 20:38:08"
                "workflow_id" => 1
              ]
              #original: array:14 [▶]
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: array:2 [▶]
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #guarded: array:1 [▶]
            }
          ]
        }
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
    2 => App\Models\Category {#943 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 67
        "slug" => "category3-0"
        "name" => "Category3"
        "description" => ""
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => null
        "left" => 11
        "right" => 12
        "depth" => 0
        "created_at" => "2020-02-20 20:59:03"
        "updated_at" => "2020-02-20 20:59:03"
        "workflow_id" => 1
        "category_id" => 67
        "language_id" => 2
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: array:1 [▼
        "children" => Illuminate\Database\Eloquent\Collection {#944 ▼
          #items: []
        }
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
  ]
}

sql

 $categories = Category::whereNull('parent_id')
            ->with('children')
            ->where('workflow_id', '=', '1')
            ->join('category_language', 'categories.id', '=', 'category_language.category_id')
            ->where('code', '=', 'en')
            ->get();

menu no dd https://ibb.co/qCbfVHY

Activity icon

Replied to Navbar Form Nested Categories

Illuminate\Database\Eloquent\Collection {#905 ▼
  #items: array:3 [▼
    0 => App\Models\Category {#941 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 61
        "slug" => "category-0"
        "name" => "Category"
        "description" => "sdad"
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => null
        "left" => 1
        "right" => 4
        "depth" => 0
        "created_at" => "2020-02-20 20:35:22"
        "updated_at" => "2020-02-20 20:36:33"
        "workflow_id" => 1
        "category_id" => 61
        "language_id" => 1
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▼
        0 => "moving"
        1 => "moved"
      ]
      #relations: array:1 [▼
        "children" => Illuminate\Database\Eloquent\Collection {#945 ▼
          #items: array:1 [▼
            0 => App\Models\Category {#982 ▼
              #table: "categories"
              #fillable: array:8 [▶]
              #connection: "mysql"
              #primaryKey: "id"
              #keyType: "int"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: true
              +wasRecentlyCreated: false
              #attributes: array:14 [▼
                "id" => 62
                "slug" => "subcategory-0"
                "name" => ""
                "description" => ""
                "image" => ""
                "file" => ""
                "filename" => ""
                "parent_id" => 61
                "left" => 2
                "right" => 3
                "depth" => 1
                "created_at" => "2020-02-20 20:36:33"
                "updated_at" => "2020-02-20 20:36:33"
                "workflow_id" => 1
              ]
              #original: array:14 [▶]
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: array:2 [▶]
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #guarded: array:1 [▶]
            }
          ]
        }
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
    1 => App\Models\Category {#942 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 63
        "slug" => "category1-0"
        "name" => "Category1"
        "description" => "dsa"
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => null
        "left" => 5
        "right" => 8
        "depth" => 0
        "created_at" => "2020-02-20 20:36:56"
        "updated_at" => "2020-02-20 20:38:08"
        "workflow_id" => 1
        "category_id" => 63
        "language_id" => 1
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: array:1 [▼
        "children" => Illuminate\Database\Eloquent\Collection {#940 ▼
          #items: array:1 [▼
            0 => App\Models\Category {#983 ▼
              #table: "categories"
              #fillable: array:8 [▶]
              #connection: "mysql"
              #primaryKey: "id"
              #keyType: "int"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: true
              +wasRecentlyCreated: false
              #attributes: array:14 [▼
                "id" => 64
                "slug" => "subcategory1-0"
                "name" => ""
                "description" => ""
                "image" => ""
                "file" => ""
                "filename" => ""
                "parent_id" => 63
                "left" => 6
                "right" => 7
                "depth" => 1
                "created_at" => "2020-02-20 20:38:08"
                "updated_at" => "2020-02-20 20:38:08"
                "workflow_id" => 1
              ]
              #original: array:14 [▶]
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: array:2 [▶]
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #guarded: array:1 [▶]
            }
          ]
        }
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
    2 => App\Models\Category {#943 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 67
        "slug" => "category3-0"
        "name" => "Category3"
        "description" => ""
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => null
        "left" => 11
        "right" => 12
        "depth" => 0
        "created_at" => "2020-02-20 20:59:03"
        "updated_at" => "2020-02-20 20:59:03"
        "workflow_id" => 1
        "category_id" => 67
        "language_id" => 2
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: array:1 [▼
        "children" => Illuminate\Database\Eloquent\Collection {#944 ▼
          #items: []
        }
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
  ]
}
Activity icon

Replied to Navbar Form Nested Categories

no data is coming form second foreach only 2 empty fileds

 @foreach ($category->children as $children)
                      <li class="dropdown"><a href="#">{{ $children->name }}</a> </li>
             @endforeach
Activity icon

Replied to Navbar Form Nested Categories

Main category has id 1 parent_id null Subcategory has id 1 parent_id = 1

Illuminate\Database\Eloquent\Collection {#940 ▼
  #items: array:4 [▼
    0 => App\Models\Category {#941 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 61
        "slug" => "category-0"
        "name" => "Category"
        "description" => "sdad"
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => null
        "left" => 1
        "right" => 4
        "depth" => 0
        "created_at" => "2020-02-20 20:35:22"
        "updated_at" => "2020-02-20 20:36:33"
        "workflow_id" => 1
        "category_id" => 61
        "language_id" => 1
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
    1 => App\Models\Category {#942 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 62
        "slug" => "subcategory-0"
        "name" => "SubCategory"
        "description" => ""
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => 61
        "left" => 2
        "right" => 3
        "depth" => 1
        "created_at" => "2020-02-20 20:36:33"
        "updated_at" => "2020-02-20 20:36:33"
        "workflow_id" => 1
        "category_id" => 62
        "language_id" => 1
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
    2 => App\Models\Category {#943 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 63
        "slug" => "category1-0"
        "name" => "Category1"
        "description" => "dsa"
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => null
        "left" => 5
        "right" => 8
        "depth" => 0
        "created_at" => "2020-02-20 20:36:56"
        "updated_at" => "2020-02-20 20:38:08"
        "workflow_id" => 1
        "category_id" => 63
        "language_id" => 1
        "code" => "en"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
    3 => App\Models\Category {#944 ▼
      #table: "categories"
      #fillable: array:8 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 64
        "slug" => "subcategory1-0"
        "name" => "SubCategory1"
        "description" => "sa"
        "image" => ""
        "file" => ""
        "filename" => ""
        "parent_id" => 63
        "left" => 6
        "right" => 7
        "depth" => 1
        "created_at" => "2020-02-20 20:38:08"
        "updated_at" => "2020-02-20 20:38:08"
        "workflow_id" => 1
        "category_id" => 64
        "language_id" => 1
        "code" => "EN"
      ]
      #original: array:17 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: array:2 [▶]
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
  ]
}
Activity icon

Started a new Conversation Navbar Form Nested Categories

I want to create a dynamic navigation menu with subcategories for my blog.

Model

<?php

namespace App\Models;


use App\Traits\ClearsResponseCache;
use Baum\Node;
use Eloquent;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
 * App\Models\Category
 *
 * @property int $id
 * @property string $slug
 * @property string $name
 * @property string $description
 * @property string $image
 * @property string $file
 * @property string $filename
 * @property int|null $parent_id
 * @property int|null $left
 * @property int|null $right
 * @property int|null $depth
 * @property string|null $created_at
 * @property string|null $updated_at
 * @property int $workflow_id
 * @property-read Collection|Category[] $children
 * @property-read int|null $children_count
 * @property-read Category|null $parent
 * @property-read Collection|Product[] $products
 * @property-read int|null $products_count
 * @method static \Illuminate\Database\Eloquent\Builder|\Baum\Node limitDepth($limit)
 * @method static \Illuminate\Database\Eloquent\Builder|Category newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Category newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Category query()
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereDepth($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereDescription($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereFile($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereFilename($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereImage($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereLeft($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereParentId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereRight($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereSlug($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Category whereWorkflowId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\Baum\Node withoutNode($node)
 * @method static \Illuminate\Database\Eloquent\Builder|\Baum\Node withoutRoot()
 * @method static \Illuminate\Database\Eloquent\Builder|\Baum\Node withoutSelf()
 * @mixin Eloquent
 */
class Category extends Node
{
    use ClearsResponseCache;

    protected $table = 'categories';

    protected $fillable = array('name', 'parent_id', 'slug', 'file', 'filename', 'image', 'description', 'workflow_id');


    /**
     * @return BelongsToMany
     */
    public function products()
    {
        return $this->belongsToMany(Product::class);
    }

    /**
     * @return BelongsToMany
     */
    public function language()
    {
        return $this->belongsToMany(language::class, 'category_language')->withPivot('name', 'description');
    }

    /**
     * @return HasMany
     */
    public function children()
    {
        return $this->hasMany(Category::class, 'parent_id');
    }
}

sql form controler

$categories = Category::where('parent_id', null)
            ->with('children')
            ->where('workflow_id', '=', '1')
            ->join('category_language', 'categories.id', '=', 'category_language.category_id')
            ->where('code', '=', 'en')
            ->get();

view code

@foreach ($categories as $category)
      <li class="dropdown"><a href="#">{{$category->name}}</a></li>
            @foreach ($category->children as $children)
                      <li class="dropdown"><a href="#">{{ $children->name }}</a> </li>
             @endforeach
@endforeach

only shows main category not the paren one

Feb
06
1 month ago
Activity icon

Started a new Conversation Preview Emails In Tab With Data

Hi all I have to tabs in one is the email form and in second need to be the Preview on the same mail with data that cames from the mail form

Thx in advance

Activity icon

Started a new Conversation Sending Email To All Users

Hi everyone!

I want to send email to all user in the database with some info, for example, the web will be down for an update

to write the message to a form and on send to send it to all users

Thanks in advance :)

Feb
03
2 months ago
Activity icon

Replied to Nested Array Save To Database

same array +2 filds

Illuminate\Support\Collection {#257 ▼
  #items: array:5 [▼
    0 => array:13 [▼
      "id" => "8c8c13b6-35ed-3ffb-92d5-c438825df67f"
      "date_of_birth" => "1990-06-29"
      "image" => "https://lorempixel.com/640/480/people/?96612"
      "email" => "[email protected]"
      "first_name" => "Dayni"
      "last_name" => "Mayez"
      "title" => "Mr."
      "address" => "18342 Alisa Square Suite 259"
      "country" => "USA"
      "bio" => """
        Maxime ratione optio ratione voluptatem sed rem rerum.
        \t\t\t\t  Eaque voluptatem veniam voluptatum porro. Animi sequi nisi ut
        \t\t\t\t  quia minima aspernatur. At enim consequuntur sunt blanditiis.
        """
      "rating" => "3.0600000000000001"
      "created_at" => "2020-02-03 15:18:41"
      "updated_at" => "2020-02-03 15:18:41"
    ]
    1 => array:13 [▶]
    2 => array:13 [▶]
    3 => array:13 [▶]
    4 => array:13 [▶]
  ]
}
Activity icon

Replied to Nested Array Save To Database

it is the same

Argument 1 passed to Illuminate\Database\Query\Builder::insert() must be of the type array, object given, called in /home/vagrant/code/test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php on line 1366
Activity icon

Replied to Nested Array Save To Database

public function getData()
    {
        $token = "0f92f725e8a90b5ba754937e09725c9c";
        $client = new Client();
        $response = $client->request('GET', 'http://technical_test.client.cosmicdevelopment.com/api/employee/list/', [
            'headers' => [
                'Access-Token' => $token,
                'Content-Type' => 'application/json',
            ],
        ]);
        $data = json_decode($response->getBody()->getContents(), true);
        $timestamp = Carbon::now()->toDateTimeString();
        $prepared = collect($data['data'])->map(function($item) use ($timestamp) {
            $item['created_at'] = $timestamp;
            $item['updated_at'] = $timestamp;
            return $item;
        });

        Employer::create($prepared);
    }

Argument 1 passed to Illuminate\Database\Eloquent\Builder::create() must be of the type array, object given, called in

Activity icon

Replied to Nested Array Save To Database

dd($data) shows the array from top

Activity icon

Replied to Nested Array Save To Database

$token = "0f92f725e8a90b5ba754937e09725c9c";
        $client = new Client();
        $response = $client->request('GET', 'http://technical_test.client.cosmicdevelopment.com/api/employee/list/', [
            'headers' => [
                'Access-Token' => $token,
                'Content-Type' => 'application/json',
            ],
        ]);
        $data = json_decode($response->getBody()->getContents(), true);
        $timestamp = Carbon::now()->toDateTimeString();
        $prepared = collect($data)->map(function($item) use ($timestamp) {
            $item['created_at'] = $timestamp;
            $item['updated_at'] = $timestamp;
            return $item;
        });

        Employer::insert($prepared);

trows ErrorException Illegal string offset 'created_at'

Activity icon

Replied to Nested Array Save To Database

ok and

$prepared = collect($data)->map(function($item) use ($timestamp) {
    $item['created_at'] = $timestamp;
    $item['updated_at'] = $timestamp;
    $item['date_of_birth'] 
    return $item;

need to define item or is auto

Activity icon

Replied to Nested Array Save To Database

$prepared = collect($data)->map(function($item) use ($timestamp) {
    $item['created_at'] = $timestamp;
    $item['updated_at'] = $timestamp;
    return $item;

pls explain this part with timestamp
Activity icon

Replied to Nested Array Save To Database

foreach($data as $value){

 Employer::create([
                'date_of_birth' => $value->date_of_birth,
                'image'         => $value->image,
                'title'         => $value->title,
                'address'       => $value->address,
                'country'       => $value->country,
                'bio'           => $value->bio,
                'rating'        => $value->rating,
                'email'         => $value->email,
                'first_name'    => $value->first_name,
                'last_name'     => $value->last_name,

            ]);
    }

something like this one
Activity icon

Started a new Conversation Nested Array Save To Database

array:3 [▼
  "status" => "success"
  "data" => array:5 [▼
    0 => array:11 [▼
      "id" => "8c8c13b6-35ed-3ffb-92d5-c438825df67f"
      "date_of_birth" => "1990-06-29"
      "image" => "https://lorempixel.com/640/480/people/?96612"
      "email" => "[email protected]"
      "first_name" => "Dayni"
      "last_name" => "Mayez"
      "title" => "Mr."
      "address" => "18342 Alisa Square Suite 259"
      "country" => "USA"
      "bio" => """
        Maxime ratione optio ratione voluptatem sed rem rerum.
        \t\t\t\t  Eaque voluptatem veniam voluptatum porro. Animi sequi nisi ut
        \t\t\t\t  quia minima aspernatur. At enim consequuntur sunt blanditiis.
        """
      "rating" => "3.0600000000000001"
    ]
    1 => array:11 [▼
      "id" => "8c2313b6-35ed-3ffb-92d5-c438825df67f"
      "date_of_birth" => "1980-06-29"
      "image" => "https://lorempixel.com/640/480/people/?96613"
      "email" => "[email protected]"
      "first_name" => "Alisa"
      "last_name" => "Milesz"
      "title" => "Mrs."
      "address" => "774 Snider Street"
      "country" => "USA"
      "bio" => """
        Maxime ratione optio ratione voluptatem sed rem rerum.
        \t\t\t\t  Eaque voluptatem veniam voluptatum porro. Animi sequi nisi ut
        \t\t\t\t  quia minima aspernatur. At enim consequuntur sunt blanditiis.
        """
      "rating" => "3.0600000000000002"
    ]
    2 => array:11 [▼
      "id" => "1c2313b6-35ed-3ffb-92d5-c438825df67f"
      "date_of_birth" => "1955-06-29"
      "image" => "https://lorempixel.com/640/480/people/?96614"
      "email" => "[email protected]"
      "first_name" => "Andre"
      "last_name" => "Barbuda"
      "title" => "Mr."
      "address" => "4593 Michigan Avenue"
      "country" => "USA"
      "bio" => """
        Maxime ratione optio ratione voluptatem sed rem rerum.
        \t\t\t\t  Eaque voluptatem veniam voluptatum porro. Animi sequi nisi ut
        \t\t\t\t  quia minima aspernatur. At enim consequuntur sunt blanditiis.
        """
      "rating" => "1.0600000000000001"
    ]
    3 => array:11 [▼
      "id" => "2c2313b6-35ed-3ffb-92d5-c438825df67f"
      "date_of_birth" => "1986-06-29"
      "image" => "https://lorempixel.com/640/480/people/?96616"
      "email" => "[email protected]"
      "first_name" => "James"
      "last_name" => "Stein"
      "title" => "Mr."
      "address" => "Colorado Springs, CO 80903"
      "country" => "USA"
      "bio" => """
        Maxime ratione optio ratione voluptatem sed rem rerum.
        \t\t\t\t  Eaque voluptatem veniam voluptatum porro. Animi sequi nisi ut
        \t\t\t\t  quia minima aspernatur. At enim consequuntur sunt blanditiis.
        """
      "rating" => "5.0600000000000001"
    ]
    4 => array:11 [▼
      "id" => "3c2313b6-35ed-3ffb-92d5-c438825df67f"
      "date_of_birth" => "1982-06-29"
      "image" => "https://lorempixel.com/640/480/people/?96618"
      "email" => "[email protected]"
      "first_name" => "John"
      "last_name" => "Tompkins"
      "title" => "Mr."
      "address" => "4451 Deans Lane"
      "country" => "USA"
      "bio" => """
        Maxime ratione optio ratione voluptatem sed rem rerum.
        \t\t\t\t  Eaque voluptatem veniam voluptatum porro. Animi sequi nisi ut
        \t\t\t\t  quia minima aspernatur. At enim consequuntur sunt blanditiis.
        """
      "rating" => "2.0600000000000001"
    ]
  ]
  "msg" => ""
]

how to save this array to database table with this structure

public function up()
    {
        Schema::create('employers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->date('date_of_birth');
            $table->string('image');
            $table->string('email');
            $table->string('first_name');
            $table->string('last_name');
            $table->string('title');
            $table->string('address');
            $table->string('country');
            $table->text('bio');
            $table->bigInteger('rating');
            $table->timestamps();
        });
    }
Jan
25
2 months ago
Activity icon

Started a new Conversation How To Save Title And Description In Pivot Table Laravel

Have table product and table language and a pivot table language_product where have title and description so for every product to be multi lang need to store title and description to the pivot table

product model

    public function lang()
    {
        return $this->belongsToMany(language::class)->withPivot('title', 'description');
    }

Lang model public function product() { return $this->belongsToMany(Product::class); } and in the blade create i have one

div class="bs-example">
                            <ul class="nav nav-tabs">
                                @foreach($language as $languages)
                                    <li class="nav-item">
                                        <a href="#{{$languages->name}}" class="nav-link"
                                           data-toggle="tab">{{$languages->name}}</a>
                                    </li>
                                @endforeach
                            </ul>
                            <div class="tab-content">
                                @foreach($language as $languages)
                                    <div class="tab-pane fade" id="{{$languages->name}}">
                                        <br>
                                        <div class="form-group">
                                            <input type="text" class="form-control"
                                                   placeholder="title"
                                                   name="title">
                                        </div>
                                        <div class="form-group">
                                            <textarea class="ckeditor" id="elm" name="description"></textarea>
                                        </div>
                                    </div>
                                @endforeach

                            </div>
                        </div>
this will add new tab for all languages how to store them in pivot table
Jan
09
2 months ago
Activity icon

Replied to Nested Category Depth

need to be in a select dropdown something like this https://ibb.co/C9XJLy9

Activity icon

Started a new Conversation Nested Category Depth

My table's fields are:

id | name | parent_id

model

public function parent() { return $this->belongsTo('Category', 'parent_id'); }

public function children()
{
    return $this->hasMany('Category', 'parent_id');
}

save working ok but how to show them in select drop down withe detps leke this

--- Php
------ Laravel
--------- Version
------------ V 5.7
--- Python
------ Django
--- Ruby
Jan
04
3 months ago
Activity icon

Replied to Model Binding Return Null

@nakov , @cronix thx people fix the problem by adding

        ```\Illuminate\Routing\Middleware\SubstituteBindings::class,

in kernel.php

Activity icon

Replied to Model Binding Return Null

yes everything is working ok just model b not :)

Activity icon

Replied to Model Binding Return Null

same returns null to be more precise this project is update form 5.1 to 6.9 and now I refactor it perhaps something i need to fix in laravel to enable model binding just thinking