Kiddypet

Kiddypet

Member Since 1 Month Ago

Experience Points 4,530
Experience Level 1

470 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 38
Lessons
Completed
Best Reply Awards 1
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.

11 Sep
1 week ago

Kiddypet left a reply on PLUCK From An Array

@snapey yes exactly i didn't know how to formulate my question clearly

10 Sep
1 week ago

Kiddypet left a reply on PLUCK From An Array

@snapey Thnak you for your help. I 've tried that but it doesnt work : SQLSTATE[42S22]: Column not found: 1054 Unknown column 'project' in 'field list'

There is no project element in my roleProject just a "project_id" that belongsTo a project in my Project Table I'm able to access it on a single roleproject( $project=$roleproject->project) but it doesn't work as soon as i'm working with an array

Kiddypet started a new conversation PLUCK From An Array

Hi I have a project class that hasMany roleProjects a roleProject class that belongs to a Project

Here is my Controller :


       $roleprojects=RoleProject::where('user_id',$user)->where('role_id',1)->get();

    $projects= array();
      foreach ($roleprojects as $roleProject) {
            array_push($projects,$roleProject->project);
          }
    

I just want to know if there is some better more efficient way to do this without the loop

06 Sep
2 weeks ago

Kiddypet left a reply on ERROR Installing Laracasts Javascript Package

This is the closest thing thta i could find :

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laracasts/utilities": "^3.0",
        "laravel/framework": "5.8.*",
        "laravel/tinker": "^1.0",
        "maatwebsite/excel": "^3.1",
        "phpoffice/phpspreadsheet": "^1.9"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "laravel/telescope": "^2.0",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^7.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

Kiddypet left a reply on ERROR Installing Laracasts Javascript Package

@resin Yes Here it is

{
        "name": "laracasts/utilities",
        "version": "3.0.1",
        "version_normalized": "3.0.1.0",
        "source": {
            "type": "git",
            "url": "https://github.com/laracasts/PHP-Vars-To-Js-Transformer.git",
            "reference": "490c6cf4d23c26c94e01867265c84921863a5f19"
        },
        "dist": {
            "type": "zip",
            "url": "https://api.github.com/repos/laracasts/PHP-Vars-To-Js-Transformer/zipball/490c6cf4d23c26c94e01867265c84921863a5f19",
            "reference": "490c6cf4d23c26c94e01867265c84921863a5f19",
            "shasum": ""
        },
        "require": {
            "illuminate/support": "^5.0|^6.0",
            "php": ">=5.5.0"
        },
        "require-dev": {
            "phpspec/phpspec": "~2.0"
        },
        "time": "2019-09-04T12:55:27+00:00",
        "type": "library",
        "extra": {
            "laravel": {
                "providers": [
                    "Laracasts\Utilities\JavaScript\JavaScriptServiceProvider"
                ],
                "aliases": {
                    "JavaScript": "Laracasts\Utilities\JavaScript\JavaScriptFacade"
                }
            }
        },
        "installation-source": "dist",
        "autoload": {
            "files": [
                "src/helpers.php"
            ],
            "psr-4": {
                "Laracasts\Utilities\JavaScript\": "src/"
            }
        },
        "notification-url": "https://packagist.org/downloads/",
        "license": [
            "MIT"
        ],
        "authors": [
            {
                "name": "Jeffrey Way",
                "email": "[email protected]"
            }
        ],
        "description": "Transform your PHP to JavaScript",
        "keywords": [
            "javascript",
            "laravel"
        ]
    },

Kiddypet left a reply on ERROR Installing Laracasts Javascript Package

@lemmon it still gives me the same ERROR with or without the provider

Kiddypet left a reply on ERROR Installing Laracasts Javascript Package

@resin The \Javascript was just one solution i found in a forum but it doesn't work with or without

05 Sep
2 weeks ago

Kiddypet started a new conversation ERROR Installing Laracasts Javascript Package

Hello ,

I keep encountering this : "Class 'Javascript' not found" ERROR.

I'm trying to use the laracasts javascript package from : https://github.com/laracasts/PHP-Vars-To-Js-Transformer

I installed this javascript package using composer and following the doc i added it to my Config/app.php file

'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class,
        Illuminate\Auth\AuthServiceProvider::class,

Here is My controller :

use Illuminate\Http\Request;
use App\Project;
use \Javascript;

class DashController extends Controller
{
  public function overview()
  {

    $projects=Project::all()->pluck('budgetD');
    Javascript::put($projects);
    return view('welcome',compact('projects'));

  }
}

Thank you for your time

04 Sep
2 weeks ago

Kiddypet left a reply on Table Relation

Nope you can just access it directly,

Just in case if i have any doubts i usually check that the relation ship is working in the tinker

you can check this it perfectly explains how it work

https://laracasts.com/series/laravel-from-scratch-2018/episodes/16

Kiddypet left a reply on Table Relation

yes this should work fine . You can access it with :

$Metas=$product->productMetas
$images=$product->productMainImage
28 Aug
3 weeks ago

Kiddypet started a new conversation Can't Access A Variable Relations In View Laravel 5.8

Hi ! I'm new to laravel and i'm trying to build a project and workers manager of sort. I'm trying to access only the projects where the currently authanticated user is currently listed as Manager. But he is not listed as such in the project table directly. Rather i'm using a role_Project table to store all the roles foreach project.

It's when trying to acces the project related to a specific RoleProject record that i get the following error : "Undefined property: stdClass::$project (View: C:\laragon\www\sofsupmg\resources\views\projects\index.blade.php)"

Here are my tables :

  Schema::create('users', function (Blueprint $table) {
          $table->bigIncrements('id');
          $table->string('name');
          $table->string('nom')->nullable();
          $table->string('prenom')->nullable();
          $table->string('email')->unique();
          $table->timestamp('email_verified_at')->nullable();
          $table->string('password');
          $table->string('statut_id')->nullable();
          // $table->foreign('role_id')->references('id')->on('roles');
          $table->rememberToken();
          $table->timestamps();
        });
  Schema::create('projects', function (Blueprint $table) {
      $table->bigIncrements('id');
      $table->timestamps();
      $table->string('titre');
      $table->string('description');
      $table->unsignedInteger('budgetH');
      $table->unsignedInteger('budgetD');
      $table->unsignedBigInteger('parent_id')->nullable();
      $table->date('date_debut')->nullable();
      $table->date('date_fin')->nullable();
      $table->foreign('parent_id')->references('id')->on('projects')->onDelete('cascade');
    });

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

      Schema::create('role_projects', function (Blueprint $table) {
          $table->bigIncrements('id');
          $table->timestamps();
          $table->unsignedBigInteger('project_id');
          $table->unsignedBigInteger('user_id');
          $table->unsignedBigInteger('role_id');
          $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
          $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
          $table->foreign('project_id')->references('id')->on('projects')->onDelete('cascade');
        });

Here are my classes


class Project extends Model
{
    protected $guarded=[];

    public function projects(){
      return $this->hasMany(Project::class);
    }

    public function affectations(){
      return $this->hasMany(Affectation::class);
    }

    public function RoleProjects(){
      return $this->hasMany(RoleProject::class);
    }
}

class Role extends Model
{
    protected $guarded=[];

    public function RoleProjects(){
      return $this->hasMany(RoleProject::class);
    }
}

class User extends Authenticatable
{
    use Notifiable;

        public function statut(){
            return $this->belongsTo(Statut::class);
        }

        public function affectations(){
          return $this->hasMany(Affectation::class);
        }
        public function RoleProjects(){
          return $this->hasMany(RoleProject::class);
        }
}

class RoleProject extends Model
{
    protected $guarded=[];

    public function role(){
      return $this->belongsTo(Role::class);
    }
    public function user(){
      return $this->belongsTo(User::class);
    }
    public function project(){
      return $this->belongsTo(Project::class);
    }
}   

Here is my ProjectController

public function index()
{

  ///Pour Montrer Tous les Projets de tous les utilisateurs
   // $projects=Project::all();

            //Pour Montrer uniquement les projets pour lesquel l'utilisateur connecté est chef de projet
            $user=auth()->id();
            $roleprojects = DB::table('role_projects')
                        ->where('user_id',$user)
                        ->where('role_id',1)
                        ->get();

          
  return view('projects.index',compact('roleprojects'));
}

}


And finally my blade view where i think the problem is coming from 


@extends('welcome0')
@section('title')
  roles : Permet la gestion des autorisations
@endsection
@section('content')
    <div class="index">


   
      <h3>Projets Index</h3>
              <ul>
                @foreach($roleprojects as $roleproject)
                  <li> <a href="/projects/{{ $roleproject->project->id }}"> {{ $roleproject->project->id }} : {{ $roleproject->project->titre }}  </a> </li>
                @endforeach
              </ul>
    </div>

@endsection



The problem is that i can't access "$roleproject->project->id" in the blade view.
Thanks for your help