thiagocardoso

thiagocardoso

Member Since 2 Years Ago

Experience Points 340
Experience Level 1

4,660 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 1
Lessons
Completed
Best Reply Awards 0
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.

30 Mar
2 years ago

thiagocardoso left a reply on Return Subset Of The Same Data

Snapey, it wouldn't work, as I've tried already.

The only way, however ugly, to get what I need was really creating a new item as collection and populating it with the results of a new query:

$q = $q->join('users as user', 'user.id', '=', 'user_id')
       ->select(['escalas.name', 'user_id'])
       ->groupBy(['escalas.name', 'user_id'])
       ->orderBy('user.name', 'asc')->get();
       
// adiciona os itens de data de cada registro
foreach ($q as $entry) {
    $entry['datas'] = collect();
    $d = Escala::select('data_inicio')
               ->where('user_id', '=', $entry->user_id)
               ->orderBy('data_inicio')
               ->get();
    foreach ($d as $key => $value) {
        $entry['datas']->put($key, $value->data_inicio);
    }
}

Anyway, thanks for the help!

thiagocardoso started a new conversation Return Subset Of The Same Data

Hi!

I have a query, but it isn't doing quite what I need. First my table (a small part of the table):

name  | user_id | date
--------------------------------------
DELTA | 28      | 2017-04-03 09:00:00
DELTA | 28      | 2017-04-07 09:00:00
DELTA | 28      | 2017-04-11 09:00:00
DELTA | 28      | 2017-04-15 09:00:00
DELTA | 28      | 2017-04-19 09:00:00
DELTA | 28      | 2017-04-23 09:00:00
DELTA | 28      | 2017-04-27 09:00:00
BETA  | 3       | 2017-04-21 09:00:00
BETA  | 3       | 2017-04-09 09:00:00
BETA  | 3       | 2017-04-05 09:00:00
BETA  | 3       | 2017-04-25 09:00:00
BETA  | 3       | 2017-04-29 09:00:00
BETA  | 3       | 2017-04-01 09:00:00
BETA  | 3       | 2017-04-13 09:00:00
BETA  | 3       | 2017-04-17 09:00:00
DELTA | 33      | 2017-04-27 09:00:00
DELTA | 33      | 2017-04-03 09:00:00
DELTA | 33      | 2017-04-07 09:00:00
DELTA | 33      | 2017-04-19 09:00:00
DELTA | 33      | 2017-04-23 09:00:00
DELTA | 33      | 2017-04-11 09:00:00
DELTA | 33      | 2017-04-15 09:00:00

And here's my Eloquent query:

        $q = Escala::query();
        $q = $q->join('users as user', 'user.id', '=', 'user_id')
                    ->select(['escalas.name', 'user_id'])
                    ->selectRaw('data_inicio as escalas')
                    ->orderBy('user.name', 'asc');

And it's returning a JSON for my application:

[
  {
    "name": "DELTA",
    "user_id": 28,
    "escalas": "2017-04-27 09:00:00"
  },
  {
    "name": "DELTA",
    "user_id": 28,
    "escalas": "2017-04-03 09:00:00"
  },
  {
    "name": "DELTA",
    "user_id": 28,
    "escalas": "2017-04-07 09:00:00"
  },
  {
    "name": "DELTA",
    "user_id": 28,
    "escalas": "2017-04-19 09:00:00"
  },
  {
    "name": "DELTA",
    "user_id": 28,
    "escalas": "2017-04-23 09:00:00"
  },
  {
    "name": "DELTA",
    "user_id": 28,
    "escalas": "2017-04-11 09:00:00"
  },
  {
    "name": "DELTA",
    "user_id": 28,
    "escalas": "2017-04-15 09:00:00"
  },
  {
    "name": "BETA",
    "user_id": 3,
    "escalas": "2017-04-21 09:00:00"
  },
  {
    "name": "BETA",
    "user_id": 3,
    "escalas": "2017-04-09 09:00:00"
  },
  {
    "name": "BETA",
    "user_id": 3,
    "escalas": "2017-04-05 09:00:00"
  },
  {
    "name": "BETA",
    "user_id": 3,
    "escalas": "2017-04-25 09:00:00"
  }, ... ,
  {
    "name": "DELTA",
    "user_id": 11,
    "escalas": "2017-04-19 09:00:00"
  }
]

As you can see, it's returning on separate lines what I need to be together, as the following example (handmade, just to be clear):

[
  {
    "name": "DELTA",
    "user_id": 28,
    "escalas": {
      1: "2017-04-27 09:00:00",
      2: "2017-04-03 09:00:00",
      3: "2017-04-07 09:00:00",
      4: "2017-04-19 09:00:00",
      5: "2017-04-23 09:00:00",
      6: "2017-04-11 09:00:00",
      7: "2017-04-15 09:00:00"
  },
  {
    "name": "BETA",
    "user_id": 3,
    "escalas": {
      1: "2017-04-21 09:00:00",
      2: "2017-04-09 09:00:00",
      3: "2017-04-05 09:00:00",
      4: "2017-04-25 09:00:00",
      5: "2017-04-29 09:00:00",
      6: "2017-04-01 09:00:00",
      7: "2017-04-13 09:00:00",
      8: "2017-04-17 09:00:00"
    } 
  },
  {
    "name": "BETA",
    "user_id": 47,
    "escalas": {
      1: "2017-04-13 09:00:00",
      2: "2017-04-23 09:00:00",
      3: "2017-04-11 09:00:00",
      4: "2017-04-15 09:00:00",
      5: "2017-04-27 09:00:00",
      6: "2017-04-03 09:00:00",
      7: "2017-04-07 09:00:00",
      8: "2017-04-19 09:00:00"
    }
  }
]

How can I achieve this? I'm trying to do another query and trying to push it inside the collection made by the first query but is not working, so should be another way.

Thanks in advance.

15 Mar
2 years ago

thiagocardoso left a reply on How To Retrieve Fields With A Count Field

I've managed to get my desired result with the following code:

$escala = Escala::select(['name', 'data_inicio'])
                        ->selectRaw('count(*) as users_count')
                        ->groupBy(['name', 'data_inicio'])->get();

output:

[
  {
    "name": "a",
    "data_inicio": "2017-03-16 10:00:00",
    "users_count": 2
  },
  {
    "name": "a",
    "data_inicio": "2017-03-17 10:00:00",
    "users_count": 2
  }
]

thiagocardoso started a new conversation How To Retrieve Fields With A Count Field

Hello everybody,

What I have:

  • code: Escala::select(['name', 'data_inicio'])->groupBy(['name', 'data_inicio'])
  • raw SQL (with toSql()) : "select`name`,`data_inicio`from`escalas`groupby`name`,`data_inicio`"
  • result (with get()):
[
  {
    "name": "a",
    "data_inicio": "2017-03-16 10:00:00"
  },
  {
    "name": "a",
    "data_inicio": "2017-03-17 10:00:00"
  }
]
  • full data :
[
  {
    "id": 1,
    "name": "a",
    "data_inicio": "2017-03-16 10:00:00",
    "user_id": 2
  },
  {
    "id": 2,
    "name": "a",
    "data_inicio": "2017-03-16 10:00:00",
    "user_id": 3
  },
  {
    "id": 3,
    "name": "a",
    "data_inicio": "2017-03-17 10:00:00",
    "user_id": 2
  },
  {
    "id": 4,
    "name": "a",
    "data_inicio": "2017-03-17 10:00:00",
    "user_id": 3
  }
]

what I'm trying to get is the same output, but with a field with the count of the rows (like this)

[
  {
    "name": "a",
    "data_inicio": "2017-03-16 10:00:00",
    "count": 2
  },
  {
    "name": "a",
    "data_inicio": "2017-03-17 10:00:00",
    "count": 2
  }
]

How to get it? Should I use raw statements?

08 Mar
2 years ago

thiagocardoso started a new conversation Why Can't I Have My Variable In My View?

I'm passing via controller method a redirect to my view with a var attached to it, but it doens't appear to my view. Instead, Laravel raises an error that my variable wasn't found.

Here's the code from the controller's method (the [1,2]is just for testing, either way, no working):

public function showLogin(){
        return redirect()->route('appindex.show')->withDevices([1, 2]);
    }

Here's the output from the view:

array:3 [▼
  "__env" => Factory {#107 ▶}
  "app" => Application {#3 ▶}
  "errors" => ViewErrorBag {#189 ▼
    #bags: []
  }
]

Inside the view, I'm just asking for Laravel's to show all variables ({{ dd(get_defined_vars()['__data']) }})

Here is the view's code, asking for echoing out the data

    <div class="row">
        <div class="col-md-1 col-xs-3">
          <label for="device-select">Dispositivo</label>  
        </div>
        <div class="col-md-3 col-xs-9">
          <div class="dropdown">
            <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
              Selecione o dispositivo
              <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
              @if($devices::count())
                @foreach($devices as $d)
                  <li><a href="#">{{ $d->alias }}</a></li>
                @endforeach
              @else
                <li><a href="{{ route('appdevices.show') }}"></a></li>
              @endif
            </ul>
          </div>
        </div>
    </div>

And here is the actual error when I run the entire view, without the above line:

Whoops, looks like something went wrong.

2/2
ErrorException in 3eda6c0094415cf143ed6fab48073ecaa9339edd.php line 15:
Undefined variable: devices (View: /home/thiago/Projects/sia/resources/views/app/index.blade.php)
in 3eda6c0094415cf143ed6fab48073ecaa9339edd.php line 15
at CompilerEngine->handleViewException(object(ErrorException), '1') in PhpEngine.php line 44
at PhpEngine->evaluatePath('/home/thiago/Projects/sia/storage/framework/views/3eda6c0094415cf143ed6fab48073ecaa9339edd.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag))) in CompilerEngine.php line 59
at CompilerEngine->get('/home/thiago/Projects/sia/resources/views/app/index.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag))) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php line 45
at Response->setContent(object(View)) in Response.php line 201
at Response->__construct(object(View)) in Router.php line 1028
at Router->prepareResponse(object(Request), object(View)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/home/thiago/Projects/sia/public/index.php') in server.php line 21
1/2
ErrorException in 3eda6c0094415cf143ed6fab48073ecaa9339edd.php line 15:
Undefined variable: devices
in 3eda6c0094415cf143ed6fab48073ecaa9339edd.php line 15
at HandleExceptions->handleError('8', 'Undefined variable: devices', '/home/thiago/Projects/sia/storage/framework/views/3eda6c0094415cf143ed6fab48073ecaa9339edd.php', '15', array('__path' => '/home/thiago/Projects/sia/storage/framework/views/3eda6c0094415cf143ed6fab48073ecaa9339edd.php', '__data' => array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag)), 'obLevel' => '1', '__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag))) in 3eda6c0094415cf143ed6fab48073ecaa9339edd.php line 15
at include('/home/thiago/Projects/sia/storage/framework/views/3eda6c0094415cf143ed6fab48073ecaa9339edd.php') in PhpEngine.php line 42
at PhpEngine->evaluatePath('/home/thiago/Projects/sia/storage/framework/views/3eda6c0094415cf143ed6fab48073ecaa9339edd.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag))) in CompilerEngine.php line 59
at CompilerEngine->get('/home/thiago/Projects/sia/resources/views/app/index.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag))) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php line 45
at Response->setContent(object(View)) in Response.php line 201
at Response->__construct(object(View)) in Router.php line 1028
at Router->prepareResponse(object(Request), object(View)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/home/thiago/Projects/sia/public/index.php') in server.php line 21

thiagocardoso left a reply on How To Add A New Element To Every Item Of Collection?

I'm not able to do as @michaeldyrynda answer is saying.

I have this array (which I passed to my function under $scheduleData variable):

array:6 [▼
  "dates" => array:3 [▼
    0 => Carbon {#215 ▶}
    1 => Carbon {#220 ▶}
    2 => Carbon {#226 ▶}
  ]
  "starttime" => Carbon {#228 ▶}
  "jobtime" => Carbon {#229 ▶}
  "offsettime" => Carbon {#230 ▶}
  "user_owner" => User {#236 ▶}
  "users" => array:3 [▼
    0 => User {#237 ▶}
    1 => User {#238 ▶}
    2 => User {#239 ▶}
  ]
]

and what i need id (even in an array or collection):

Collection {#227 ▼
  #items: array:3 [▼
    0 => array:1 [▼
      "data" => Carbon {#215 ▶}
      "starttime" => Carbon {#228 ▶}
      "jobtime" => Carbon {#229 ▶}
      "offsettime" => Carbon {#230 ▶}
      "user_owner" => User {#236 ▶}
      "users" => array:3 [▼
          0 => User {#237 ▶}
          1 => User {#238 ▶}
          2 => User {#239 ▶}
        ]
    ]
    1 => array:1 [▼
      "data" => Carbon {#220 ▶}
      "starttime" => Carbon {#228 ▶}
      "jobtime" => Carbon {#229 ▶}
      "offsettime" => Carbon {#230 ▶}
      "user_owner" => User {#236 ▶}
      "users" => array:3 [▼
          0 => User {#237 ▶}
          1 => User {#238 ▶}
          2 => User {#239 ▶}
        ]
    ]
    2 => array:1 [▼
      "data" => Carbon {#226 ▶}
      "starttime" => Carbon {#228 ▶}
      "jobtime" => Carbon {#229 ▶}
      "offsettime" => Carbon {#230 ▶}
      "user_owner" => User {#236 ▶}
      "users" => array:3 [▼
          0 => User {#237 ▶}
          1 => User {#238 ▶}
          2 => User {#239 ▶}
        ]
    ]
  ]
}

I've created a blank collection and was able to separate the main dates:

        $data = collect([]);
        foreach($scheduleData['dates'] as $sd){
            $data->push(['data' => $sd]);
        }

which returned me the following structure

Collection {#227 ▼
  #items: array:3 [▼
    0 => array:1 [▼
      "data" => Carbon {#215 ▶}
    ]
    1 => array:1 [▼
      "data" => Carbon {#220 ▶}
    ]
    2 => array:1 [▼
      "data" => Carbon {#226 ▶}
    ]
  ]
}

and then I tried to use the answer above to add the rest of the info, but with no success

        $data->map(function($d){
            $d['starttime'] = $scheduleData['starttime'];
            return $d;
        });

thiagocardoso left a reply on Non-static Method Eloquent\Model::fill() Should Not Be Called Statically Error

Thank you very much Snapey. I thought that calling using the Placa::fill was the right way to call a function, and the 'Placa->something` was a way to access an attribute of the Model.

Now about the user_id security issue that you've mentioned, it's not a concern, because the field is filled by the system itself.

Thanks for the reply!

07 Mar
2 years ago

thiagocardoso started a new conversation Non-static Method Eloquent\Model::fill() Should Not Be Called Statically Error

Hi everybody! I'm trying to get a device info saved into my database but I'm getting an error which says: Non-static method Illuminate\Database\Eloquent\Model::fill() should not be called statically"

Here is the Model code:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Placa extends Model
{
    protected $fillable = ['part_number', 'alias', 'user_id'];
}

And here is the controller code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Placa;

class AppController extends Controller {
    public function postDevices(Request $request){
        $inputs = $request->all();
        $placa = Placa::fill($inputs);
        return $placa;
    }
}

A sidenote is that all fields inside request matches the table fields, therefore the fill method,

Why I'm still getting this error?

Complete error:

ErrorException in AppController.php line 34:
Non-static method Illuminate\Database\Eloquent\Model::fill() should not be called statically
in AppController.php line 34
at HandleExceptions->handleError('8192', 'Non-static method Illuminate\Database\Eloquent\Model::fill() should not be called statically', '/home/thiago/Projects/sia/app/Http/Controllers/AppController.php', '34', array('request' => object(Request), 'inputs' => array('_token' => 'OvcZCL8xCYJGRjuNhGwshizjTCItcPm21JzIic21', 'part_number' => 'testecod', 'alias' => 'testenome', 'user_id' => '1'))) in AppController.php line 34
at AppController->postDevices(object(Request))
at call_user_func_array(array(object(AppController), 'postDevices'), array(object(Request))) in Controller.php line 55
at Controller->callAction('postDevices', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(AppController), 'postDevices') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/home/thiago/Projects/sia/public/index.php') in server.php line 21