mariohbrino

mariohbrino

Member Since 11 Months Ago

Experience Points 55,670
Experience Level 12

4,330 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 540
Lessons
Completed
Best Reply Awards 2
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.

23 Apr
1 month ago

mariohbrino left a reply on Tinker Not Working

Which php version are you using?

It can be related about php version 7.3. You can install php version 7.2 or lower and it will work fine.

13 Feb
3 months ago

mariohbrino left a reply on Convert This Query To Eloquent

Here is an example of how you can do this, this is standardized for laravel.

Migrations - designations and employee_details

Schema::create('designations', function (Blueprint $table) {
    $table->increments('id');
    $table->string('name');
    $table->timestamps();
});

Schema::create('employee_details', function (Blueprint $table) {
    $table->increments('id');
    $table->unsignedInteger('designation_id');
    $table->timestamps();

    $table->foreign('designation_id')
        ->references('id')
        ->on('designations')
        ->onDelete('cascade');
});

Models - relationships one to many

class EmployeeDetail extends Model
{
    protected $table = 'employee_details';

    public $fillable = [
        'designation_id'
    ];

    public function designation() {
        return $this->belongsTo(Designation::class);
    }
}

class Designation extends Model
{
    protected $table = 'designations';

    public $fillable = [
        'name'
    ];

    public function employee_details() {
        return $this->hasMany(EmployeeDetail::class);
    }
}

Controller - DesignationController

public function index()
{
    return Designation::select('name')->withCount(['employee_details'])->get();
}

// return [ {"name": "Test', "employee_details_count": 2} , ...]
11 Feb
3 months ago

mariohbrino left a reply on Upload Multiple Images

Follow the link below of article where explain how you can do it.

Medium

mariohbrino left a reply on Pixel Measuring Tool

Yes, it's correct.

You can select a region of the screen by pressing Command–Shift–4 and then holding the cursor pressed while dragging it around. Without releasing the cursor, it makes for a convenient screen ruler that can be opened quickly up at any time. By releasing it you will take a screenshot or you can dismiss it by pressing the Escape key.

Link

04 Feb
3 months ago

mariohbrino left a reply on How Can I Make This Api To Display In The Browser

You can use eloquent relationships. Laravel eloquent relationships

model - add the relationship on your model Property

public function category()
{
        return $this->belongsTo(Category::class);
}

controller - by default laravel return json

public function index()
{
    $property = new Property();
    return $property->with(['category'])->get();
}
03 Jan
4 months ago

mariohbrino left a reply on Artisan Tinker Exit Without Error Message

@bobbybouwmann Thank you, I did find out about it as well.

[link] (https://github.com/laravel/tinker/issues/63 ''Laravel/Tinker Issue")

mariohbrino started a new conversation Artisan Tinker Exit Without Message Error

I was using artisan tinker normally and now it doesn't work any more. I can get inside but on the first command it exit without any message error. Somebody did have this issue before? Any suggestions?

mariohbrino test $ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> $user = new App\User();
mariohbrino test $ 

Thanks. Regards.

13 Nov
6 months ago

mariohbrino left a reply on Missing Origin Validation In Webpack-dev-server

Any solution on this? I couldn't find a solution yet.

27 Oct
6 months ago

mariohbrino left a reply on Larave Spark To Define Which Users Can Create Team

You need to define where you want to apply the middleware, in this case I did apply into a group middleware web.

You can add the path of your middleware into app/Http/Kernel.php

protected $middlewareGroups = [
    'web' => [
        \ ------ code above ------
        \App\Http\Middleware\VerifyUserCanCreateTeam::class,
    ],
]
26 Oct
7 months ago

mariohbrino left a reply on Larave Spark To Define Which Users Can Create Team

@Cronix

I found out what was missing from your instructions, thank you.

mariohbrino left a reply on Larave Spark To Define Which Users Can Create Team

@Cronix

I add a field into table users to check if the user can create a team, and use a middleware to set the Spark::noAdditionalTeams, but it doesn't work.

Do you know how can I make it work? Thanks.

if(\Auth::check() && ! $request->user()->join_team && ! Spark::developer($request->user()->email)) {
      Spark::noAdditionalTeams();
}

mariohbrino started a new conversation Larave Spark To Define Which Users Can Create Team

There is a method I can use to define if the user can create teams named noAdditionalTeams, which it can be add at SparkServiceProvider.php to define all users cannot create a team. There is a way to I define which user can create team or cannot?

19 Oct
7 months ago

mariohbrino left a reply on Spark 7.0 Error With Route Model Binding

@Cronix

Thank you.

That worked and is what I needed in the begin. I was thinking and looking for a way to make it generic as well, so I do not have to create a new one for each model. Do you have one idea how to apply to all models?

Thanks.

18 Oct
7 months ago

mariohbrino left a reply on Spark 7.0 Error With Route Model Binding

@Cronix

Thanks, I forget to say that, I saw that before. But, I don't want to do it for each route I have, in case I forget it will be bad.

There is a case when I'll use resource, and this function where is not option for resource routes.

Route

Route::resource('/api/user', 'UserController');

Controller

public function show(User $user) {
    return $user;
}

mariohbrino started a new conversation Spark 7.0 Error With Route Model Binding

I have one issue with Laravel Spark 7.0, the route model binding doesn't abort when it passes a string. It works fine at Laravel 5.7, only in Spark it happens.

Any one can help me with this? Thanks.

Route

Route::get('api/users/{user}', function (App\User $user) {
    return $user->email;
});

Example: app.local/api/user/test

Result

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "test" (SQL: select * from "users" where "id" = test limit 1)
18 Sep
8 months ago

mariohbrino left a reply on How Can I Define A Route That Doesn't Redirect To Team Missing Page

@bobbybouwmann thank you, I did as you suggested, but it keeps happening on redirect me to team/missing. So I noticed that the route was with middleware set by default.

The route web have been set by default the middleware hasTeam, with that in mind I can made my own route admin. Laravel Spark changes the default web route and add a middleware hasTeam. Check the RouteServiceProvider file in app/Providers/RouteServiceProvider.php

protected function mapWebRoutes(Router $router)
    {
        $router->middleware(['web', 'hasTeam'])
               ->namespace($this->namespace)
               ->group(base_path('routes/web.php'));
    }
17 Sep
8 months ago

mariohbrino started a new conversation How Can I Define A Route That Doesn't Redirect To Team Missing Page

When I define the user CanJoinTeams the middleware VerifyUsersHasTeam redirect the user to a team missing, because I don't have a team setup. I want to find a way to bypass the team verification for the admin. Is that possible?

Thanks.

mariohbrino left a reply on Sh: Composer: Command Not Found

I have been install the composer as /usr/local/bin/composer/composer.phar when I should to install /usr/local/bin/composer that's why the alias don't work.

Install and setup composer into /usr/local/bin with name composer

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Add alias into ~/.bash_profile

alias composer="php /usr/local/bin/composer"

13 Sep
8 months ago

mariohbrino left a reply on Sh: Composer: Command Not Found

I did install composer in my macOS 10.13.6 and follow the instructions you guys give, but I still don't have access to composer when I use alias without file composer.phar.

Please, can someone help? Thanks.

  • [x] Install composer
  • [x] Move composer to /usr/local/bin/composer
  • [x] Add alias into ~/.bash_profile
  • [x] Test commands
# Install
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
# Move
mv composer.phar /usr/local/bin/composer

Add alias with file composer.phar into ~/.bash_profile

alias composer="php /usr/local/bin/composer/composer.phar"

Running

composer --version

generates this response

Composer version 1.7.2 2018-08-16 16:57:12

Running

laravel new project-name

generates this response

Crafting application...
sh: composer: command not found
Application ready! Build something amazing.

Change alias without file composer.phar into ~/.bash_profile

alias composer="php /usr/local/bin/composer"

Running

imac server $ composer --version

generates this response

imac server $

Running

cd project-name
imac server $ composer install

generates this response, this don't install any dependencies

imac server $


18 Aug
9 months ago

mariohbrino left a reply on Package Composer Psr-4 Autoload Class Not Found

I found my mistake, my path was wrong.

Wrong: "scr/"

"autoload": {
    "psr-4": {
      "Footer\": "scr/"
    }
  }

Correct: "src/"

"autoload": {
    "psr-4": {
      "Footer\": "src/"
    }
  }

mariohbrino started a new conversation Package Composer Psr-4 Autoload Class Does Not Found

Please can someone help?

I want to make a package test, I did create a composer package dependency. The error message when I import it to my project is Class 'Footer\Foo' not found.

  • Package create test

I did put this dependency into my vendor and run:

    composer dump-autoload

Folder structure

    .
    ├── ...
    ├── vendor
    |   ├── mariohbrino
    |       ├── footer
    |           ├── src
    |               ├── classes
    |                   ├── Whatever.php
    |               Foo.php
    |       ├── composer.json

src\classes\Whatever.php

<?php

namespace Footer\Classes;

class Whatever
{
    public function build(){
        echo 'called';
    }
}

src\Foo.php

<?php

namespace Footer;

use Footer\Classes\Whatever;

class Foo extends Whatever
{
    public function __construct()
    {
        $this->build();
    }
}

composer.json

{
  "name": "mariohbrino/footer",
  "type": "library",
  "description": "Package test",
  "homepage": "http://github.com/mariohbrino/footer",
  "keywords": ["Package", "Test"],
  "license": "MIT",
  "minimum-stability": "dev",
  "authors": [
    {
      "name": "Mario Brino",
      "email": "[email protected]"
    }
  ],
  "require": {
    "php": ">=5.5.0"
  },
  "autoload": {
    "psr-4": {
      "Footer\": "scr/"
    }
  }
}