codebullet

codebullet

Member Since 1 Year Ago

Experience Points 22,010
Experience Level 5

2,990 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 209
Lessons
Completed
Best Reply Awards 1
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

01 May
1 month ago

codebullet left a reply on Error Getting Data Through API Laravel 5.8

Finally Got the issue,

It was a database table with invalid Json content, (nested Array)

All Solved now

Thank you @m

30 Apr
1 month ago

codebullet left a reply on Error Getting Data Through API Laravel 5.8

Even i tried to import Agolia it gives me this error

could it be issue with packages?


C:\laragon\www\testate>php artisan scout:import "App\Project"

   InvalidArgumentException  : json_encode error: Malformed UTF-8 characters, possibly incorrectly encoded

  at C:\laragon\www\testate\vendor\algolia\algoliasearch-client-php\src\RetryStrategy\ApiWrapper.php:233
    229|                 $body = '';
    230|             } else {
    231|                 $body = \json_encode($body);
    232|                 if (JSON_ERROR_NONE !== json_last_error()) {
  > 233|                     throw new \InvalidArgumentException(
    234|                         'json_encode error: '.json_last_error_msg());
    235|                 }
    236|             }
    237|         }

  Exception trace:

  1   Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper::createRequest("POST", Object(Algolia\AlgoliaSearch\Http\Psr7\Uri), ["KVVHQ6QFVS", "bfdb2210fe91a855c91f61044b2ef8a8", "Algolia for PHP (2.2.0); PHP (7.2.11)
; Laravel Scout (7.0.0)", "application/json"])
      C:\laragon\www\testate\vendor\algolia\algoliasearch-client-php\src\RetryStrategy\ApiWrapper.php:139

  2   Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper::request("POST", "/1/indexes/projects_index/batch", Object(Algolia\AlgoliaSearch\RequestOptions\RequestOptions), [])
      C:\laragon\www\testate\vendor\algolia\algoliasearch-client-php\src\RetryStrategy\ApiWrapper.php:89

  Please use the argument -v to see more details.


codebullet started a new conversation Error Getting Data Through API Laravel 5.8

Good day all, Please I need some help, for some reason, I can't get data through API I get this error

            $this->data = $data->toJson($this->encodingOptions);
        } elseif ($data instanceof JsonSerializable) {
            $this->data = json_encode($data->jsonSerialize(), $this->encodingOptions);
        } elseif ($data instanceof Arrayable) {
            $this->data = json_encode($data->toArray(), $this->encodingOptions);
        } else {
            $this->data = json_encode($data, $this->encodingOptions);
        }
 
        if (! $this->hasValidJson(json_last_error())) {
            throw new InvalidArgumentException(json_last_error_msg());
        }
 
        return $this->update();
    }
 
    /**
     * Determine if an error occurred during JSON encoding.
     *
     * @param  int  $jsonError
     * @return bool
     */
    protected function hasValidJson($jsonError)
    {
        if ($jsonError === JSON_ERROR_NONE) {
            return true;
        }
 
        return $this->hasEncodingOption(JSON_PARTIAL_OUTPUT_ON_ERROR) &&
                    in_array($jsonError, [
                        JSON_ERROR_RECURSION,
Arguments
"Malformed UTF-8 characters, possibly incorrectly encoded"

Here is my API route


<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::get('projects', 'API\[email protected]');

and this is my Api/ProjectsController


<?php

namespace App\Http\Controllers\Api;

use App\Project;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ProjectsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        return Project::latest()->paginate(10);
    }

I tried resources I get the root URL HTML content

I appreciate your help

23 Apr
2 months ago

codebullet started a new conversation Ajax Response "Malformed UTF-8 Characters, Possibly Incorrectly Encoded"

Hi everyone I am facing some issues JSON response

in my API controller

    public function index()
    {
        //
        $properties = Property::all();
        return Response::json($properties);
    }

I get this error


"Malformed UTF-8 characters, possibly incorrectly encoded"

I want to access this data from external javascript file to show on map, so I tried to convert the collection into JSON to read from the external file

please advise if there is a better way to approach

Thanks a lot for reading

22 Apr
2 months ago

codebullet left a reply on Laravel Migrate Error

Maybe you can check if there is a duplicate user table migration file Because you can face this error if you have 2 migration file trying to create the same table Or check your database if any table exists, try to delete manually and run again

04 Feb
4 months ago

codebullet left a reply on Select Options Based On The First Selection

Hi, use to face similar issue

I used this resource, i just replace the php part with my laravel and also the "axios.get" to my api

hope it helps

https://itsolutionstuff.com/post/dynamic-dependent-dropdown-using-vuejs-and-phpexample.html

codebullet left a reply on "Call To Undefined Method App\User::profile()"

Thank you guys for your support i shifted all fields on user's table and then use the 'has' and it worked

Thank you

03 Feb
4 months ago

codebullet left a reply on "Call To Undefined Method App\User::profile()"

@snapey when a user signed up they don't have a profile yet, then the user will have the option to add a profile.

so some users don't have a profile some have a profile,

Or should I create a profile when creating a user in a database can create a user with just profile ID?

Here is the scenario is a mini-company employee portal, only the company Admin can create a profile, a user can sign up as a subscriber, then the company admin can choose to add profile

I was thinking to approach this way if i can have user created with no profile then admin can view all users without a profile. i think it is not the right way to approach

I think to create a user profile once the user is created the user's profile will have only the ID and rest of the information will be filled by admin

or better still i will put all information on user's table and let the admin fill in the rest of the information he requires

Any way to better approach this

Thanks in advance

codebullet left a reply on "Call To Undefined Method App\User::profile()"

yes i did

<?php

namespace App\Http\Controllers;
use App\Employee;
use App\User;
use App\Department;
use App\Designation;
use Illuminate\Http\Request;

That is in place

codebullet started a new conversation "Call To Undefined Method App\User::profile()"

Greetings i need little help here,

I have 2 tables, a table for users, and a table for profiles ( one to one relationship)

I want to get all users without profile

From Tinker i can get $user->profile through relationship no error but when i use

 public function create()
    {
        //
        $departments = Department::all();
        $users = User::has('profile')->get();
        return view('manager.profile.create')->with(compact('departments','users'));
    }

I get this error

C:\xampp\htdocs\fidu\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php
            if ($matches['class'] != get_class($object) ||
                $matches['method'] != $method) {
                throw $e;
            }
 
            static::throwBadMethodCallException($method);
        }
    }
 
    /**
     * Throw a bad method call exception for the given method.
     *
     * @param  string  $method
     * @return void
     *
     * @throws \BadMethodCallException
     */
    protected static function throwBadMethodCallException($method)
    {
        throw new BadMethodCallException(sprintf(
            'Call to undefined method %s::%s()', static::class, $method
        ));
    }
}
 
Arguments
"Call to undefined method App\User::employee()"

Here is my user Model relationship


<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laratrust\Traits\LaratrustUserTrait;

class User extends Authenticatable
{
    use LaratrustUserTrait;
    use HasApiTokens, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'email',
        'password',
        'first_name',
        'last_name',
        'spouse',
    ];



    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];


    protected function blog(){
        return $this->hasMany('App\Blog');
    }

    protected function profile(){
        return $this->hasOne(Property::class);
    }

Please advise, can't wrap my head around it.

Please help

07 Nov
7 months ago

codebullet left a reply on Error Seeding: LaratrustSeeder

@Snapey Thank you very much got it.

04 Nov
7 months ago

codebullet left a reply on Error Seeding: LaratrustSeeder

Thank @Snapey, I published the config files and I tried running on the fresh installation of 5.7 still didn't go through,

could it be issue with the latest version 5.7 let me try on lower version of Laravel

03 Nov
7 months ago

codebullet started a new conversation Error Seeding: LaratrustSeeder

Hi good day,

please i need some help with Laratrust

I followed the documentation and installed on laravel 5.7 i get this error when i am trying to run the seeder

PHP 7.2.9 MySql 5.0


> C:\xampp\php\php.exe artisan db:seed
Seeding: LaratrustSeeder
Truncating User, Role and Permission tables

   ErrorException  : Invalid argument supplied for foreach()

  at C:\xampp\htdocs\fidu\database\seeds\LaratrustSeeder.php:22
    18|         $config = config('laratrust_seeder.role_structure');
    19|         $userPermission = config('laratrust_seeder.permission_structure');
    20|         $mapPermission = collect(config('laratrust_seeder.permissions_map'));
    21| 
  > 22|         foreach ($config as $key => $modules) {
    23| 
    24|             // Create a new role
    25|             $role = \App\Role::create([
    26|                 'name' => $key,

  Exception trace:

  1   Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Invalid argument supplied for foreach()", "C:\xampp\htdocs\fidu\database\seeds\LaratrustSeeder.php", [Object(Illuminate\Support\Collection)])
      C:\xampp\htdocs\fidu\database\seeds\LaratrustSeeder.php:22

  2   LaratrustSeeder::run()
      C:\xampp\htdocs\fidu\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29

  Please use the argument -v to see more details.

Process finished with exit code 1 at 13:13:36.
Execution time: 468 ms.

I can't figure this out,

Thank you for your help

codebullet started a new conversation Foreign Key Constraint Is Incorrectly Formed

Greetings,

Please i need little help referencing in migration

If i make the migration referencing user_id on user table only i get no errors but if i do the same on another migration i get this below error

Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1005 Can't create table `fidu`.`#sql-ffc_57` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `offplans` add constraint `offplans_subcommunity_id_foreign` foreign key (`subcommunity_id`) references `subcommmunity` (`id`))

  at C:\xampp\htdocs\fidu\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

My Migration

Property Migration


<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePropertiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('properties', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->integer('price');
            $table->float('size');
            $table->string('ref')->nullable();
            $table->integer('developer_id')->unsigned();
            $table->foreign('developer_id')->references('id')->on('developers');
            $table->integer('emirate_id')->unsigned();
            $table->foreign('emirate_id')->references('id')->on('emirates');
            $table->integer('community_id')->unsigned();
            $table->foreign('community_id')->references('id')->on('communities');
            $table->integer('subcommunity_id')->unsigned();
            $table->foreign('subcommunity_id')->references('id')->on('subcommmunity');
            $table->string('gallery');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('properties');
    }
}


the other of which the file appear in the directory matters?

all other migrations in the below order user password_reset laratrust_setup emirates community subcommunity developers offplan developers

Thank you for going through and thank you for your support

16 Mar
1 year ago

codebullet left a reply on Little Help With Laravel And Vue Components Registration

thank you @ntraykov for your help the cdn link was the issue i guess cuz as i took out the link it was working properly

codebullet left a reply on Little Help With Laravel And Vue Components Registration

@Giddit Thank you very much, it is because i am using the CDN link that is why Thank you all for your support.

Cheers

codebullet started a new conversation Little Help With Laravel And Vue Components Registration

Good day everyone, i am new with vue, i am confused and need some heads up about vue components

I am using Webpack When i instantiate Vue on a Laravel page e.g (create.blade.php) it works without instantiating globally (in app.js)

Then i need to split my work in to vue components this is where i get issues using the components on blade files

Without instantiating Vue in the main app.js file, i get this error

([Vue warn]: Unknown custom element: <example-component> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
)

After reading stuff online then i instantiate vue in app.js the components was registered and rendered properly then i get another error with the other vue instances i had locally with new error

([Vue warn]: Property or method "permissionType" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property)

I am totally confused if i use vue instance in blade files it works fine then components wont' work and vice vesa

My app.js file

import Vue from 'vue';
require('./bootstrap');

window.Vue = require('vue');
window.Slug = require('slug');
Slug.defaults.mode = 'rfc3986';


Vue.component('example-component', require('./components/ExampleComponent.vue'));


const app = new Vue({
    el: '.m-portlet'
});


My Component Temp


<template>
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-heading">Example Component</div>

                    <div class="panel-body">
                        I'm an example component!
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>


My blade file i want to use component


@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Login</div>

                <div class=".m-portlet">
                  

                        <example-component></example-component>
                        
                </div>
            </div>
        </div>
    </div>
</div>
@endsection


@section('scripts')
    <script src="{{ asset('/js/app.js') }}"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>

    <script>
        const app = new Vue({
            el: '.m-portlet',
            data: {

            },

        });
    </script>

    <script>



    </script>

@endsection


please advise thank you

codebullet started a new conversation Little Help With Laravel And Vue Components Registration

Good day everyone, i am new with vue, i am confused and need some heads up about vue components

I am using Webpack When i instantiate Vue on a Laravel page e.g (create.blade.php) it works without instantiating globally (in app.js)

Then i need to split my work in to vue components this is where i get issues using the components on blade files

Without instantiating Vue in the main app.js file, i get this error

([Vue warn]: Unknown custom element: <example-component> - did you register the component correctly? For recursive components, make sure to provide the "name" option. )

After reading stuff online then i instantiate vue in app.js the components was registered and rendered properly then i get another error with the other vue instances i had locally with new error

([Vue warn]: Property or method "permissionType" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property)

I am totally confused if i use vue instance in blade files it works fine then components wont' work and vice vesa

please advise thank you

15 Feb
1 year ago

codebullet started a new conversation Returning Multiple Views In A Controller

Greetings, please i am little new with laravel and i am a bit confuse which is the best approach to display same data on different views layout for example there is a website front end with list of companies for read only (companies.index for the view) then on the other hand there is a back end to display companies by authenticated user and this view have full crud function

I am looking for an opinion for the best practice, is it good to have [email protected] return multiple views like so ( companies.index and companies.admin.index) if that is possible Or create companies main controller for front end then create second controller for admin section and extend the main controller or is there a better way to go about situations like this?

If you are the one how will you approach this in terms of structure and setup?

Please ignore this if the question is stupid, i am just trying to get a best approach to a scenario like this

Thank you so much for your time

31 Dec
1 year ago

codebullet started a new conversation Looking For Laravel Mentor To Work With

Happy New Year, Please I am looking for a Laravel Mentor to give me a guide/help with small project i am working

I need a hand with multi-company CRM, setting roles/permission levels and company registration structure (it is challenging for me. )

I need a guide so, i can learn master Laravel faster

Any help where I can connect with someone to work with

Any suggestion is welcome

Thanks