grozavule

Member Since 10 Months Ago

Experience Points
8,440
Total
Experience

1,560 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
67
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.

  • Community Pillar

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

Level 2
8,440 XP
Jan
19
2 days ago
Activity icon

Replied to Eloquent Is Passing Invalid Parameters To SQL Queries From A Model

Here is the migration for the models table:

<?php

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

class CreateProductModels extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('product_models', function (Blueprint $table) {
            $table->string('model_number', 10)->primary();
            $table->tinyInteger('family_id');
            $table->string('description', 40);
            $table->bigInteger('base_machine_feature_id');
            $table->timestamps();
        });
    }

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

Here is the migration for the model_features table:

<?php

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

class CreateModelFeatures extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('model_features', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('model_number', 10);
            $table->string('description', 100);
            $table->timestamps();
            $table->string('created_by', 40);
        });
    }

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

Replied to Eloquent Is Passing Invalid Parameters To SQL Queries From A Model

Thanks for your reply. I added the line per your suggestion. Eloquent still passes 0 as the model_number value.

Here is the updated store method:

public function store(Request $request)
    {
        $validInput = $this->verifyInput($request);
        $model = new ProductModel();
        $model->model_number = strtoupper($validInput['model_number']);
        $model->description = strtoupper($validInput['description']);
        $model->family_id = $validInput['family_id'];
        $model->created_by = $request->user()->username;

        $model->save();

        $feature = new ModelFeature();
        $feature->model_number = strtoupper($validInput['model_number']);
        $feature->description = strtoupper($validInput['model_number']) . ' BASIC MACHINE';
        $feature->created_by = $request->user()->username;

        $model->features()->save($feature);

        $model->base_machine_feature_id = $feature->id;

        $model->save();

        return redirect()->route('productmodels.index');
    }

Here is the error message:

SQLSTATE[23000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The INSERT statement conflicted with the FOREIGN KEY constraint "model_features_model_number_foreign". The conflict occurred in database "KEYSTONE", table "db_owner.product_models", column 'model_number'. (SQL: insert into [model_features] ([model_number], [description], [created_by], [updated_at], [created_at]) values (0, 901 BASIC MACHINE, eric.drake, 2021-01-19 23:38:46.355, 2021-01-19 23:38:46.355)) 

I was under the impression that the line -- $model->features()->save($feature) -- would inject the model_number value from the ProductModel object. Is that not the case?

Activity icon

Started a new Conversation Eloquent Is Passing Invalid Parameters To SQL Queries From A Model

I have two related models: ProductModel and ModelFeature. When I instantiate a new ProductModel, it should also create a new ModelFeature object and assign the ModelFeature object's ID to the ProductModel object's base_machine_feature_id attribute.

Here is my store and verifyInput methods in the ProductModelsController

public function store(Request $request)
    {
        $validInput = $this->verifyInput($request);
        $model = new ProductModel();
        $model->model_number = strtoupper($validInput['model_number']);
        $model->description = strtoupper($validInput['description']);
        $model->family_id = $validInput['family_id'];
        $model->created_by = $request->user()->username;

        $model->save();

        $feature = new ModelFeature();
        $feature->description = strtoupper($validInput['model_number']) . ' BASIC MACHINE';
        $feature->created_by = $request->user()->username;

        $model->features()->save($feature);

        $model->base_machine_feature_id = $feature->id;

        $model->save();

        return redirect()->route('productmodels.index');
    }

    protected function verifyInput(Request $request)
    {
        return $request->validate([
            'model_number' => ['required', 'string', 'max:10', 'unique:App\Pricebook\ProductModel'],
            'description' => ['required', 'string', 'max:100'],
            'family_id' => ['required', 'integer', 'exists:App\Pricebook\ProductFamily,id']
        ]);
    }

The application throws the following error when trying to save the ModelFeature:

SQLSTATE[23000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The INSERT statement conflicted with the FOREIGN KEY constraint "model_features_model_number_foreign". The conflict occurred in database "KEYSTONE", table "db_owner.product_models", column 'model_number'. (SQL: insert into [model_features] ([description], [created_by], [model_number], [updated_at], [created_at]) values (901 BASIC MACHINE, eric.drake, 0, 2021-01-19 23:01:38.504, 2021-01-19 23:01:38.504)) 

For some reason, Eloquent is passing the value of 0 to the insert query for the model_number. Why would it do that? (You can see that it passes the correct model number in the description field).

Activity icon

Replied to Retrieve Member Properties From Eloquent Collection

I like the idea of creating a member method that returns the properties of the class. If I were to do that, I would want to extend the Model class and add the method to the child class. I would want all of my models to extend this new child class. Is there any way create a model using an Artisan command that would use my custom child class instead of the default Model class?

Jan
15
6 days ago
Activity icon

Started a new Conversation Retrieve Member Properties From Eloquent Collection

I have a component that I would like to reuse with any Eloquent collection.

datatable.blade

@php
if($collection->count() > 0)
{
    $headers = array_keys(get_object_vars($collection->get(0)));
}
@endphp
@if($collection->count() > 0)
<table class="table table-striped">
    <thead>
        <tr>
            @foreach($headers as $header)
            <th>{{ $header }}</th>
            @endforeach
        </tr>
    </thead>
    @foreach($collection as $obj)
        @include('components.pricebook.datarow', ['obj' => $obj])
    @endforeach
@else
    <h2>NO RESULTS</h2>
@endif
</table>

You can see where $headers is instantiated. Is there a more eloquent way to retrieve the member properties of any model in the collection?

Dec
18
1 month ago
Activity icon

Started a new Conversation Using Custom Functions In A Blade Template

I have a Blade template with a function in the @php directive. This doesn't feel like the best place for it. Where should I declare this function to still make it callable in the template?

Dec
15
1 month ago
Activity icon

Started a new Conversation Capture Path Info From The Request In The Session

I want to capture each path that a user requests in the session. I thought that the best place to do this would be from the public/index.php file. Here is what I tried:

public/index.php

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <[email protected]>
 */

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'/../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);
dump(session()->all());
if(session()->has('breadcrumb'))
{
    session('breadcrumb')->addPage($request->getPathInfo());
}
else
{
    dump("created breadcrumb");
    $breadcrumb = new App\DoubleL\Application\NavigationBreadcrumb();
    session(['breadcrumb' => $breadcrumb]);
    session('breadcrumb')->addPage($request->getPathInfo());
}
dd(session()->all());
$response->send();

$kernel->terminate($request, $response);

Here is the NavigationBreadcrumb class:

<?php

namespace App\DoubleL\Application;

class NavigationBreadcrumb
{
    protected $flow;

    public function __construct()
    {
        $this->flow = collect();
    }

    public function addPage($routeName)
    {
        $this->flow->push($routeName);
    }

    public function getPreviousPage()
    {
        return $this->flow->last();
    }
}

The session only ever stores the information for the most recent request. How can I make it save every path the user visits?

Dec
14
1 month ago
Activity icon

Started a new Conversation More Intuitive Url->previous() Functionality

In my application, there are several interconnected reports. For example, the Work Order Information report has links to the requested work order's bill of materials or its corresponding customer order. The flow of web traffic is as follows:

Work Order Information Form -> Work Order Information -> Bill of Materials

Once the user submits a form, the resulting pages have a Back button to redirect back to the form. The Back button is is a component template of its own with a link to url->previous. In the case of the traffic flow I described, a user gets caught in a loop between the Work Order Information and Bill of Materials pages.

Is there another helper function like url->previous that keeps track of more than just the previous page visited? Apart from hard coding the route name into the Back Button component, is there another way to always have the back button on the Work Order Information report link back to its form?

Dec
11
1 month ago
Activity icon

Replied to Select From A Subquery Using Query Builder

I figured it out.

$partsSubquery = DB::connection('vmfg')
                ->table('REQUIREMENT as r')
                ->join('PART as p', 'p.ID', '=', 'r.PART_ID')
                ->join('PART_SITE as ps', 'p.ID', '=', 'ps.PART_ID')
                ->select('p.ID as PART_NUMBER', 'p.DESCRIPTION', 'ps.UNIT_PRICE')
                ->where('r.WORKORDER_BASE_ID', '=', $validInput['workorder_number'])
                ->orderBy('ps.UNIT_PRICE', 'desc')
                ->limit(20);

$partsQuery = DB::connection('vmfg')
                ->query()
                ->fromSub($partsSubquery, 'PE')
                ->select('PART_NUMBER', 'DESCRIPTION', 'UNIT_PRICE');

if(isset($validInput['sortBy']))
            {
                $partsQuery->orderBy($validInput['sortBy'], $validInput['sort']);
            }
            else
            {
                $partsQuery->orderBy('UNIT_PRICE', 'desc');
            }
$partsQuery->get()

I noticed that no one chimed in on this. Am I barking up the wrong tree with Query Builder? Is this better done using Eloquent?

Activity icon

Started a new Conversation Select From A Subquery Using Query Builder

I have a data table that I want to allow users to sort by whichever column they choose. One of these data tables is supposed to show the 20 most expensive parts in a workorder. Here is the query I'm trying to duplicate using Query Builder:

select PART_NUMBER, DESCRIPTION, UNIT_PRICE
from (
    select top 20 p.ID as PART_NUMBER, p.DESCRIPTION, ps.UNIT_PRICE
	from requirement r 
	join PART p on p.ID=r.PART_ID
	join PART_SITE ps on p.ID=ps.PART_ID
	where r.WORKORDER_BASE_ID=?
	order by ps.UNIT_PRICE desc
)
order by DESCRIPTION desc

How do I select from a subquery?

Dec
10
1 month ago
Activity icon

Replied to Add Parameters To Current URL's Query String

Worked perfectly! Thanks for the assist.

Activity icon

Started a new Conversation Add Parameters To Current URL's Query String

I have a table used on several pages on my application. I would like users to be able to select a column to sort. Is there a better way to link to the same page with additional query parameters than this?

<a href="{{ url(URL::full() . '&sortBy=YourMama&sort=asc' }}"></a>
Dec
09
1 month ago
Activity icon

Awarded Best Reply on Include A Component With @yield Sections

I figured it out. I needed to use the @component directive instead of @include. The solution is posted below:

Dashboard

@extends('base')

@section('content')
    <div class="widget-grid">
        @component('components.dashboardwidget', ['icon' => 'users', 'widgetTitle' => 'USERS'])
            @slot('contentBody')
                {{ $userCount }} registered users
            @endslot
            @slot('cta')
                <a href="{{ route('adminuser.index') }}" class="btn btn-light btn-outline-dark">VIEW USERS</a>
            @endslot
        @endcomponent
    </div>
@endsection

DashboardWidget

<div class="dashboard-widget-container">
    <div class="widget gradient-background gradient-border">
        <i class="fas fa-{{ $icon }} widget-icon"></i>
        <h3>{{ $widgetTitle }}</h3>
        <p>{{ $contentBody }}</p>
        {{ $cta }}
    </div>
</div>
Activity icon

Replied to Include A Component With @yield Sections

I figured it out. I needed to use the @component directive instead of @include. The solution is posted below:

Dashboard

@extends('base')

@section('content')
    <div class="widget-grid">
        @component('components.dashboardwidget', ['icon' => 'users', 'widgetTitle' => 'USERS'])
            @slot('contentBody')
                {{ $userCount }} registered users
            @endslot
            @slot('cta')
                <a href="{{ route('adminuser.index') }}" class="btn btn-light btn-outline-dark">VIEW USERS</a>
            @endslot
        @endcomponent
    </div>
@endsection

DashboardWidget

<div class="dashboard-widget-container">
    <div class="widget gradient-background gradient-border">
        <i class="fas fa-{{ $icon }} widget-icon"></i>
        <h3>{{ $widgetTitle }}</h3>
        <p>{{ $contentBody }}</p>
        {{ $cta }}
    </div>
</div>
Activity icon

Started a new Conversation Include A Component With @yield Sections

I'm creating a dashboard with basic widget components. Here is the widget component template:

<div class="dashboard-widget-container">
    <div class="widget gradient-background gradient-border">
        <i class="fas fa-{{ $icon }} widget-icon"></i>
        <h3>{{ $widgetTitle }}</h3>
        @yield('contents')
        @yield('cta')
    </div>
</div>

Here is my dashboard template:

@extends('base')

@section('content')
    <div class="widget-grid">
        @include('components.dashboardwidget', ['icon' => 'users', 'widgetTitle' => 'Users'])
    </div>
@endsection

I would like to include the widget component for any number of widgets on my dashboard. How would I extend the contents and cta sections of the widget component through an @include?

Dec
07
1 month ago
Activity icon

Started a new Conversation Cross-Database Relationships

I'm building an add-on to an existing application. I'm keeping my add-on separate from its parent application by having one database for each. Is it possible to define a relationship between one model class of Database A with another model class that accesses Database B?

Here is an example of what I'm trying to do:

I have a model named Quote. Quotes are stored in the database named Keystone. Quotes belong to a customer. My customer model accesses its data from a database named VMFG. How would I create my relatioship methods in each model to access customer data from the quote model?

Dec
03
1 month ago
Activity icon

Replied to User Created Notification

I ran into a snag with this approach. When a new user is registered, I get the error "Call to undefined method App\Notifications\UserCreated::handle()." I take it that the $listen property is expecting a different type of class than the Illuminate\Notifications\Notification class.

Activity icon

Started a new Conversation User Created Notification

When a new user registers on my site, I would like to receive an email notification. I haven't yet wrapped my mind around how the notification would be triggered. I created a new notification class called UserCreated, and I'm using the User model class that comes with Laravel UI. How do I link these two classes up? What happens when a user registers to my site that I can listen for to trigger the UserCreated notification?

Nov
25
1 month ago
Activity icon

Started a new Conversation Add An Error To A Bag Without Redirecting

I have a form with a text box that accepts one workorder ID per line. In the controller, I want to loop over the input received to verify that each line contains a valid workorder ID. When an invalid workorder is found, I want to add it to the message bag without redirecting until the loop is finished. How can I do that?

Nov
24
1 month ago
Activity icon

Replied to Missing Required Parameters

Your suggestion worked. I have a concern though. Does Laravel have to query the database all over again to reinstantiate the object in the controller?

Activity icon

Replied to Retrieve Objects From Eloquent Collection

Yes, it is. I was struggling to find a way to include the ROWID in my result set asking with an aggregate function.

Is there a way to get the same result using collection methods?

Nov
23
1 month ago
Activity icon

Started a new Conversation Subquery Join With Eloquent

How would I perform the same query using an Eloquent model?

$subquery = DB::connection('vmfgtest')
            ->table('LOGINS')
            ->select('USER_ID', 'MACHINE_ID')
            ->selectRaw('MAX(LAST_ACTIVITY) as LAST_ACTIVITY')
            ->groupBy('USER_ID', 'MACHINE_ID');

        $logins = DB::connection('vmfgtest')
            ->table('LOGINS as l1')
            ->joinSub($subquery, 'l2', function($j){
                $j->on('l1.USER_ID', '=', 'l2.USER_ID');
                $j->on('l1.MACHINE_ID', '=', 'l2.MACHINE_ID');
                $j->on('l1.LAST_ACTIVITY', '=', 'l2.LAST_ACTIVITY');
            })
            ->select('l1.ROWID', 'l1.USER_ID', 'l1.MACHINE_ID', 'l2.LAST_ACTIVITY')
            ->get();
Activity icon

Started a new Conversation Retrieve Objects From Eloquent Collection

I've been getting trounced by Eloquent lately. First, I tried to get the most recent timestamp per user_id and machine_id from a database table. My Eloquent model, VisualLogin, complained that the query didn't include the table's primary key, ROWID.

Now I'm trying to use Eloquent Collection methods to get the result I want, and I'm coming up empty so far. When I run VisualLogin::all(), I get the result below.

How would I filter this collection down to only include the records for each logged-in user's most recent last activity per MACHINE ID?

Illuminate\Database\Eloquent\Collection {#3311
     all: [
       App\VisualLogin {#3312
         ROWID: "786636",
         MACHINE_ID: "776B6774857461717264667484857568",
         PROGRAM_ID: "VMPURENT",
         LOGIN_TIME: "2020-11-20 16:17:20.623",
         LAST_ACTIVITY: "2020-11-20 16:17:20.623",
         CHECKSUM: "BEC691EE",
         USER_ID: "SQUINTERO",
       },
       App\VisualLogin {#3313
         ROWID: "786773",
         MACHINE_ID: "776B676B7079797B8A7E6F6C6D706B66",
         PROGRAM_ID: "VMMFGWIN",
         LOGIN_TIME: "2020-11-23 15:39:24.657",
         LAST_ACTIVITY: "2020-11-23 15:44:18.217",
         CHECKSUM: "509C66E4",
         USER_ID: "RHERNANDEZ",
       },
       App\VisualLogin {#3314
         ROWID: "786647",
         MACHINE_ID: "776B676B7E7A6C6D6672776E7D76757C",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 06:05:46.903",
         LAST_ACTIVITY: "2020-11-23 14:37:24.163",
         CHECKSUM: "7DF1CF80",
         USER_ID: "RYNBECK",
       },
       App\VisualLogin {#3315
         ROWID: "786665",
         MACHINE_ID: "776B677385877C727A766E6E787B6969",
         PROGRAM_ID: "VMPURENT",
         LOGIN_TIME: "2020-11-23 08:11:20.993",
         LAST_ACTIVITY: "2020-11-23 16:25:00.300",
         CHECKSUM: "AD8BBBB8",
         USER_ID: "BBLAUER",
       },
       App\VisualLogin {#3316
         ROWID: "786738",
         MACHINE_ID: "776B6774797D8779706F797369716975",
         PROGRAM_ID: "VMVNDMNT",
         LOGIN_TIME: "2020-11-23 13:40:34.907",
         LAST_ACTIVITY: "2020-11-23 14:16:10.550",
         CHECKSUM: "3D646E30",
         USER_ID: "ABROWER",
       },
       App\VisualLogin {#3317
         ROWID: "786726",
         MACHINE_ID: "776B676B7E7A6C6D6672776E7D76757C",
         PROGRAM_ID: "VMINVENT",
         LOGIN_TIME: "2020-11-23 11:33:47.260",
         LAST_ACTIVITY: "2020-11-23 11:35:00.530",
         CHECKSUM: "987A8030",
         USER_ID: "RYNBECK",
       },
       App\VisualLogin {#3318
         ROWID: "786732",
         MACHINE_ID: "776B676B7E7A6C6D6672776E7D76757C",
         PROGRAM_ID: "VMPRTMNT",
         LOGIN_TIME: "2020-11-23 12:56:23.420",
         LAST_ACTIVITY: "2020-11-23 12:56:23.420",
         CHECKSUM: "C4655B58",
         USER_ID: "RYNBECK",
       },
       App\VisualLogin {#3319
         ROWID: "786735",
         MACHINE_ID: "776B676A7D888889887C7D7964748577",
         PROGRAM_ID: "VMORDENT",
         LOGIN_TIME: "2020-11-23 13:14:04.630",
         LAST_ACTIVITY: "2020-11-23 13:24:18.303",
         CHECKSUM: "41419296",
         USER_ID: "SANDERSON",
       },
       App\VisualLogin {#3320
         ROWID: "786648",
         MACHINE_ID: "776B676B7E7A6C6D6672776E7D76757C",
         PROGRAM_ID: "VMORDENT",
         LOGIN_TIME: "2020-11-23 06:06:11.947",
         LAST_ACTIVITY: "2020-11-23 16:23:59.473",
         CHECKSUM: "0BA3AB9C",
         USER_ID: "RYNBECK",
       },
       App\VisualLogin {#3321
         ROWID: "786775",
         MACHINE_ID: "776B6773877F6C7472696D7A88777A8C",
         PROGRAM_ID: "VMPLNWIN",
         LOGIN_TIME: "2020-11-23 15:40:49.933",
         LAST_ACTIVITY: "2020-11-23 15:40:49.933",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "D3346604",
         USER_ID: "BPHELPS",
       },
       App\VisualLogin {#3322
         ROWID: "786649",
         MACHINE_ID: "776B676B7E7A6C6D6672776E7D76757C",
         PROGRAM_ID: "VMSHPENT",
         LOGIN_TIME: "2020-11-23 06:06:35.317",
         LAST_ACTIVITY: "2020-11-23 16:22:49.840",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "7CFD4280",
         USER_ID: "RYNBECK",
       },
       App\VisualLogin {#3323
         ROWID: "786650",
         MACHINE_ID: "776B676B7E7A6C6D6672776E7D76757C",
         PROGRAM_ID: "VMPLNWIN",
         LOGIN_TIME: "2020-11-23 06:06:42.727",
         LAST_ACTIVITY: "2020-11-23 06:06:42.727",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "F36F1AC4",
         USER_ID: "RYNBECK",
       },
       App\VisualLogin {#3324
         ROWID: "786662",
         MACHINE_ID: "776B676B7E7A6C6D6672776E7D76757C",
         PROGRAM_ID: "VMMFGWIN",
         LOGIN_TIME: "2020-11-23 07:32:10.330",
         LAST_ACTIVITY: "2020-11-23 07:32:10.330",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "FF9C1E4C",
         USER_ID: "RYNBECK",
       },
       App\VisualLogin {#3325
         ROWID: "786415",
         MACHINE_ID: "776B6774857461717264667484857568",
         PROGRAM_ID: "VMMFGWIN",
         LOGIN_TIME: "2020-11-19 07:21:02.457",
         LAST_ACTIVITY: "2020-11-23 15:39:05.100",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "034A898A",
         USER_ID: "SQUINTERO",
       },
       App\VisualLogin {#3326
         ROWID: "786747",
         MACHINE_ID: "776B676B7E7A6C6D6672776E7D76757C",
         PROGRAM_ID: "VMPURENT",
         LOGIN_TIME: "2020-11-23 14:37:25.647",
         LAST_ACTIVITY: "2020-11-23 14:37:45.457",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "FDA64630",
         USER_ID: "RYNBECK",
       },
       App\VisualLogin {#3327
         ROWID: "786660",
         MACHINE_ID: "776B676B7079797B8A7E6F6C6D706B66",
         PROGRAM_ID: "VMPRTMNT",
         LOGIN_TIME: "2020-11-23 07:00:17.143",
         LAST_ACTIVITY: "2020-11-23 07:00:17.143",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "B45C1044",
         USER_ID: "RHERNANDEZ",
       },
       App\VisualLogin {#3328
         ROWID: "786695",
         MACHINE_ID: "776B6774797D8779706F797369716975",
         PROGRAM_ID: "VMPURENT",
         LOGIN_TIME: "2020-11-23 09:35:40.340",
         LAST_ACTIVITY: "2020-11-23 16:19:22.387",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "F67A8770",
         USER_ID: "ABROWER",
       },
       App\VisualLogin {#3329
         ROWID: "786675",
         MACHINE_ID: "776B67747A7D7562687B7D707B747487",
         PROGRAM_ID: "VMORDENT",
         LOGIN_TIME: "2020-11-23 08:59:56.503",
         LAST_ACTIVITY: "2020-11-23 14:09:18.290",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "D16C4F28",
         USER_ID: "ARODRIGUEZ",
       },
       App\VisualLogin {#3330
         ROWID: "786688",
         MACHINE_ID: "776B677385767686737585857C7A7268",
         PROGRAM_ID: "VFARCENT",
         LOGIN_TIME: "2020-11-23 09:27:43.570",
         LAST_ACTIVITY: "2020-11-23 10:24:07.227",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "50EB05C4",
         USER_ID: "KTAYLOR",
       },
       App\VisualLogin {#3331
         ROWID: "786691",
         MACHINE_ID: "776B677385767686737585857C7A7268",
         PROGRAM_ID: "VMORDENT",
         LOGIN_TIME: "2020-11-23 09:31:31.603",
         LAST_ACTIVITY: "2020-11-23 09:31:31.603",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "9E7AA3D4",
         USER_ID: "KTAYLOR",
       },
       App\VisualLogin {#3332
         ROWID: "786737",
         MACHINE_ID: "776B676B7079797B8A7E6F6C6D706B66",
         PROGRAM_ID: "VMPURENT",
         LOGIN_TIME: "2020-11-23 13:27:39.470",
         LAST_ACTIVITY: "2020-11-23 13:27:39.470",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "D91B8798",
         USER_ID: "RHERNANDEZ",
       },
       App\VisualLogin {#3333
         ROWID: "786778",
         MACHINE_ID: "776B677385767686737585857C7A7268",
         PROGRAM_ID: "VFAPIENT",
         LOGIN_TIME: "2020-11-23 16:00:15.373",
         LAST_ACTIVITY: "2020-11-23 16:00:15.373",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "EE31CE9C",
         USER_ID: "KTAYLOR",
       },
       App\VisualLogin {#3334
         ROWID: "786666",
         MACHINE_ID: "776B677385877C727A766E6E787B6969",
         PROGRAM_ID: "VMPLNWIN",
         LOGIN_TIME: "2020-11-23 08:11:30.400",
         LAST_ACTIVITY: "2020-11-23 08:11:30.400",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "020D2BF0",
         USER_ID: "BBLAUER",
       },
       App\VisualLogin {#3335
         ROWID: "786779",
         MACHINE_ID: "776B676B6B7484797878788576747667",
         PROGRAM_ID: "VMLABENT",
         LOGIN_TIME: "2020-11-23 16:16:46.430",
         LAST_ACTIVITY: "2020-11-23 16:17:30.670",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "6BB13EDC",
         USER_ID: "KWAITE",
       },
       App\VisualLogin {#3336
         ROWID: "786689",
         MACHINE_ID: "776B6774797D8779706F797369716975",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 09:28:48.153",
         LAST_ACTIVITY: "2020-11-23 15:58:48.830",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "0E219AB8",
         USER_ID: "ABROWER",
       },
       App\VisualLogin {#3337
         ROWID: "786771",
         MACHINE_ID: "776B6773877F6C7472696D7A88777A8C",
         PROGRAM_ID: "VMPRTMNT",
         LOGIN_TIME: "2020-11-23 15:34:41.750",
         LAST_ACTIVITY: "2020-11-23 15:58:13.153",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "A8AF3FB8",
         USER_ID: "BPHELPS",
       },
       App\VisualLogin {#3338
         ROWID: "786762",
         MACHINE_ID: "776B6774797D8779706F797369716975",
         PROGRAM_ID: "VMRCVENT",
         LOGIN_TIME: "2020-11-23 15:08:08.117",
         LAST_ACTIVITY: "2020-11-23 16:06:52.317",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "6FE4BDC4",
         USER_ID: "ABROWER",
       },
       App\VisualLogin {#3339
         ROWID: "786444",
         MACHINE_ID: "776B6774857461717264667484857568",
         PROGRAM_ID: "VMTRVRPT",
         LOGIN_TIME: "2020-11-19 09:40:52.677",
         LAST_ACTIVITY: "2020-11-23 15:15:37.200",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "01EB2952",
         USER_ID: "SQUINTERO",
       },
       App\VisualLogin {#3340
         ROWID: "786768",
         MACHINE_ID: "776B6773877F6C7472696D7A88777A8C",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 15:20:17.590",
         LAST_ACTIVITY: "2020-11-23 16:35:16.917",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "9E08555C",
         USER_ID: "BPHELPS",
       },
       App\VisualLogin {#3341
         ROWID: "786696",
         MACHINE_ID: "776B677385767686737585857C7A7268",
         PROGRAM_ID: "VMINVGEN",
         LOGIN_TIME: "2020-11-23 09:39:11.447",
         LAST_ACTIVITY: "2020-11-23 09:39:20.653",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "BB2A70CC",
         USER_ID: "KTAYLOR",
       },
       App\VisualLogin {#3342
         ROWID: "786780",
         MACHINE_ID: "776B6773877F6C7472696D7A88777A8C",
         PROGRAM_ID: "VMIBTENT",
         LOGIN_TIME: "2020-11-23 16:28:53.130",
         LAST_ACTIVITY: "2020-11-23 16:28:53.130",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "0C5870A4",
         USER_ID: "BPHELPS",
       },
       App\VisualLogin {#3343
         ROWID: "786598",
         MACHINE_ID: "776B677385767686737585857C7A7268",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-20 12:32:00.140",
         LAST_ACTIVITY: "2020-11-23 16:00:14.280",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "9114ECF0",
         USER_ID: "KTAYLOR",
       },
       App\VisualLogin {#3344
         ROWID: "786734",
         MACHINE_ID: "776B676A7D888889887C7D7964748577",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 13:13:56.590",
         LAST_ACTIVITY: "2020-11-23 13:14:03.473",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "E6D13852",
         USER_ID: "SANDERSON",
       },
       App\VisualLogin {#3345
         ROWID: "786227",
         MACHINE_ID: "776B6774857461717264667484857568",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-18 05:11:35.227",
         LAST_ACTIVITY: "2020-11-23 08:26:25.773",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "8CDF4CF2",
         USER_ID: "SQUINTERO",
       },
       App\VisualLogin {#3346
         ROWID: "786681",
         MACHINE_ID: "776B677385767686737585857C7A7268",
         PROGRAM_ID: "VFCASHBK",
         LOGIN_TIME: "2020-11-23 09:11:49.607",
         LAST_ACTIVITY: "2020-11-23 09:49:03.737",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "006DC4A4",
         USER_ID: "KTAYLOR",
       },
       App\VisualLogin {#3347
         ROWID: "786664",
         MACHINE_ID: "776B677385877C727A766E6E787B6969",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 08:11:12.720",
         LAST_ACTIVITY: "2020-11-23 14:09:34.930",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "54F36AB8",
         USER_ID: "BBLAUER",
       },
       App\VisualLogin {#3348
         ROWID: "786769",
         MACHINE_ID: "776B6773877F6C7472696D7A88777A8C",
         PROGRAM_ID: "VMORDENT",
         LOGIN_TIME: "2020-11-23 15:20:22.317",
         LAST_ACTIVITY: "2020-11-23 16:06:04.137",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "FAC25608",
         USER_ID: "BPHELPS",
       },
       App\VisualLogin {#3349
         ROWID: "786700",
         MACHINE_ID: "776B6774797D8779706F797369716975",
         PROGRAM_ID: "VMPRTMNT",
         LOGIN_TIME: "2020-11-23 09:54:52.220",
         LAST_ACTIVITY: "2020-11-23 13:35:45.140",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "B9EAABC4",
         USER_ID: "ABROWER",
       },
       App\VisualLogin {#3350
         ROWID: "786676",
         MACHINE_ID: "776B676B6B7484797878788576747667",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 09:03:42.710",
         LAST_ACTIVITY: "2020-11-23 16:16:45.243",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "18369B58",
         USER_ID: "KWAITE",
       },
       App\VisualLogin {#3351
         ROWID: "786725",
         MACHINE_ID: "776B67747A7D7562687B7D707B747487",
         PROGRAM_ID: "VMSHPENT",
         LOGIN_TIME: "2020-11-23 11:30:21.343",
         LAST_ACTIVITY: "2020-11-23 11:31:57.213",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "96E3B914",
         USER_ID: "ARODRIGUEZ",
       },
       App\VisualLogin {#3352
         ROWID: "786586",
         MACHINE_ID: "776B67747A7D7562687B7D707B747487",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-20 10:29:51.533",
         LAST_ACTIVITY: "2020-11-23 11:30:20.130",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "F6540FD4",
         USER_ID: "ARODRIGUEZ",
       },
       App\VisualLogin {#3353
         ROWID: "786724",
         MACHINE_ID: "776B67747A7D7562687B7D707B747487",
         PROGRAM_ID: "VMMFGWIN",
         LOGIN_TIME: "2020-11-23 11:28:53.130",
         LAST_ACTIVITY: "2020-11-23 11:30:02.993",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "7FCC40D4",
         USER_ID: "ARODRIGUEZ",
       },
       App\VisualLogin {#3354
         ROWID: "786655",
         MACHINE_ID: "776B676B7079797B8A7E6F6C6D706B66",
         PROGRAM_ID: "VMINVENT",
         LOGIN_TIME: "2020-11-23 06:23:02.667",
         LAST_ACTIVITY: "2020-11-23 15:44:54.500",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "215C4570",
         USER_ID: "RHERNANDEZ",
       },
       App\VisualLogin {#3355
         ROWID: "786568",
         MACHINE_ID: "776B6774857461717264667484857568",
         PROGRAM_ID: "VMRCVENT",
         LOGIN_TIME: "2020-11-20 09:33:51.970",
         LAST_ACTIVITY: "2020-11-20 09:33:51.970",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "403A5766",
         USER_ID: "SQUINTERO",
       },
       App\VisualLogin {#3356
         ROWID: "786652",
         MACHINE_ID: "776B676B7079797B8A7E6F6C6D706B66",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 06:10:24.870",
         LAST_ACTIVITY: "2020-11-23 13:27:34.807",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "2B26E1D8",
         USER_ID: "RHERNANDEZ",
       },
       App\VisualLogin {#3357
         ROWID: "786701",
         MACHINE_ID: "776B676B7079797B8A7E6F6C6D706B66",
         PROGRAM_ID: "VMPLNWIN",
         LOGIN_TIME: "2020-11-23 10:03:41.800",
         LAST_ACTIVITY: "2020-11-23 10:03:41.800",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "93B90B28",
         USER_ID: "RHERNANDEZ",
       },
       App\VisualLogin {#3358
         ROWID: "786673",
         MACHINE_ID: "776B6774857461717264667484857568",
         PROGRAM_ID: "VMPRTMNT",
         LOGIN_TIME: "2020-11-23 08:26:27.493",
         LAST_ACTIVITY: "2020-11-23 08:26:27.493",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "2A9F6622",
         USER_ID: "SQUINTERO",
       },
       App\VisualLogin {#3359
         ROWID: "786723",
         MACHINE_ID: "776B6774797D8779706F797369716975",
         PROGRAM_ID: "VMPLNWIN",
         LOGIN_TIME: "2020-11-23 11:17:22.897",
         LAST_ACTIVITY: "2020-11-23 11:17:22.897",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "72969CF4",
         USER_ID: "ABROWER",
       },
       App\VisualLogin {#3360
         ROWID: "786765",
         MACHINE_ID: "776B676B69636C7A776F7C7562757560",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 15:15:35.587",
         LAST_ACTIVITY: "2020-11-23 15:15:41.830",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "4BB87AD0",
         USER_ID: "MWRIGHT",
       },
       App\VisualLogin {#3361
         ROWID: "786684",
         MACHINE_ID: "776B677385767686737585857C7A7268",
         PROGRAM_ID: "VMPURENT",
         LOGIN_TIME: "2020-11-23 09:13:07.303",
         LAST_ACTIVITY: "2020-11-23 09:19:14.800",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "329D38C4",
         USER_ID: "KTAYLOR",
       },
       App\VisualLogin {#3362
         ROWID: "786750",
         MACHINE_ID: "776B6773776C68747275867173796B6C",
         PROGRAM_ID: "MENU",
         LOGIN_TIME: "2020-11-23 14:54:41.943",
         LAST_ACTIVITY: "2020-11-23 15:30:08.947",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "CB17869E",
         USER_ID: "THILLMAN",
       },
       App\VisualLogin {#3363
         ROWID: "786766",
         MACHINE_ID: "776B676B69636C7A776F7C7562757560",
         PROGRAM_ID: "VMORDENT",
         LOGIN_TIME: "2020-11-23 15:15:42.260",
         LAST_ACTIVITY: "2020-11-23 15:16:36.577",
         LICENSE_NUMBER: "000F-601D-0400-0BDE-119D-BC71",
         CHECKSUM: "9071AD38",
         USER_ID: "MWRIGHT",
       },
     ],
   }
Activity icon

Started a new Conversation Missing Required Parameters

I get a "missing required parameters" error in my logins.blade.php template, and I'm not sure why. The full error is:

Missing required parameters for [Route: visuallogins.destroy] [URI: visual/logins/{login}]. (View: /mnt/c/Users/eric.drake/Documents/Sites/dev.keystone.local/resources/views/visual/logins.blade.php)

@extends('base')
@section('content')
    <h1>{{ $title }}</h1>
    @error('message')
        @include('components.alert', ['type' => 'danger', 'message' => $message])
    @enderror
    @if(session('success'))
        @include('components.alert', ['type' => 'success', 'message' => session('success')])
    @endif
    @if($results->count() > 0)
    <table class="table table-striped table-bordered">
        <thead>
        <tr>
            <th>USER ID</th>
            <th>MACHINE ID</th>
            <th>IDLE TIME</th>
            <th></th>
        </tr>
        </thead>
        @foreach($results as $result)
        <tr>
            <td>{{ $result->USER_ID }}</td>
            <td>{{ $result->MACHINE_ID }}</td>
            <td>{{ $result->idleTimeReadable() }}</td>
            <td>
                <form action="{{ route('visuallogins.destroy', ['login' => $result]) }}" method="post">
                    <button class="btn btn-sm btn-light btn-outline-dark" @cannot('delete', $result) disabled @endcannot>
                        <span class="sm-icon icon-delete"></span>
                        DELETE
                    </button>
                    @csrf
                    @method('DELETE')
                </form>
            </td>
        </tr>
        @endforeach
    </table>
    @else
    <p>No one is logged into Visual</p>
    @endif
@endsection

I'm passing a parameter to the route. Why is it still throwing the error?

Nov
20
2 months ago
Activity icon

Replied to What Is The Eloquent Equivalent Of This Query Builder Query?

Thanks for your help. Here is my final result based on your suggestion:

VisualLogin::select('USER_ID', 'MACHINE_ID')
                ->selectRaw('MAX(LAST_ACTIVITY) as LAST_ACTIVITY')
                ->groupBy('USER_ID', 'MACHINE_ID')
                ->get()
Activity icon

Started a new Conversation What Is The Eloquent Equivalent Of This Query Builder Query?

I'm trying to switch from Query Builder to Eloquent models. How can I make my model, VisualLogin, return the last activity per user id and machine id?

Here is my Query Builder equivalent:

$visualLogins = DB::connection('vmfg')
            ->table('LOGINS')
            ->select('USER_ID', 'MACHINE_ID', DB::raw('MAX(LAST_ACTIVITY) as LAST_ACTIVITY'))
            ->groupBy('USER_ID', 'MACHINE_ID')
            ->get();
Nov
19
2 months ago
Activity icon

Replied to Bind Model To Existing Database Table

Nakov, you're the man. Thanks for replying.

Activity icon

Started a new Conversation Bind Model To Existing Database Table

I'm working on a project that pulls data from an existing SQL Server database. The database drives an ERP application, so I have no control over the table names. How do I bind a model class to any of these tables?

Here is what I'm trying to do specifically: I have a table named VMFG.LOGINS, a model named VisualLogin, and a controller named VisualLoginsController. When the destroy method is called in the controller, I would like to delete the corresponding record in the LOGINS table.

Here is the catch. I have three database connections that I'm juggling in this project. How do I assign the model to a database connection and table?

Nov
05
2 months ago
Activity icon

Started a new Conversation Eloquent One-to-Many Relationship

I would like to assign all of my users to groups. Each user may be assigned to multiple groups. In the database, there are three tables to handle this: users, groups, and user_groups.

Here is the schema for each:

users id (PK, bigint, not null) email (nvarchar(255), not null) email_verified_at (datetime, null) password (nvarchar(255), not null) remember_token (nvarchar(100), null) created_at (datetime, null) updated_at (datetime, null) first_name (nvarchar(50), not null) last_name (nvarchar(75), not null)

groups id (PK, smallint, not null) group_name (nvarchar(255), not null)

user_groups user_id (PK, FK, bigint, not null) group_id (PK, FK, smallint, not null)

I have two models defined: App\User and App\Group:

<?php

namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

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

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

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    public function group()
    {
        return $this->hasMany('App\Group');
    }
}
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Group extends Model
{
    public $timestamps = false;

    public function users()
    {
        return $this->belongsTo('App\User');
    }
}

The relationship that I've defined doesn't return the groups to which the user belongs. I get the following error:

Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid column name 'user_id'. (SQL: select * from [groups] where [groups].[user_id] = 1 and [groups].[user_id] is not null)'

I assume this is because Laravel isn't expecting the user_groups table in my database. How should I define the relationship in my models and my database?

Oct
29
2 months ago
Activity icon

Replied to LDAPRecord Laravel Integration

Does LDAPRecord authenticate using the username and password in the default Laravel database, or does it query the domain controller?

Oct
28
2 months ago
Activity icon

Replied to LDAPRecord Laravel Integration

I configured the package to use the domain administrator at one point. Are you referring to something else?

Activity icon

Started a new Conversation LDAPRecord Laravel Integration

To save my users the trouble of remembering another password, I wanted to authenticate users via Active Directory. I found a package called directorytree/ldaprecord that supposedly can make this work. From my understanding, I need to configure Laravel with the connection parameters for the Active Directory, import all of my AD users to my Laravel database, and authentication should work.

When I run the following command, I get a successful connection to the Active Directory server:

php artisan ldap:test

When I run the following command, it tells me that 0 out of 80 users were imported.

php artisan ldap:import ldap

I've tried the import using both a standard and domain administrator account. Neither allows me to import the users. Has anyone used this package before? Does anyone know of anything else that may work better?

Oct
21
3 months ago
Activity icon

Replied to Driver [smb] Is Not Supported

Thanks for making me aware of that option. I haven't used it before. I'd rather not test it. If it doesn't work, fixing the server is a horrendous pain.

Instead, I tested Laravel 7 and 6. SMB is supported on Laravel 6.18.35. I'll hold onto this version until SMB is supported on a future release of Laravel.

Activity icon

Replied to Driver [smb] Is Not Supported

If I understand your suggestion, it would require me to edit the fstab file in Ubuntu to mount a network location as a local drive. In the past, I've had issues with this approach. Whenever the server reboots, it attempts to mount these drives before it has established a network connection. It causes an error and prevents the server from properly booting.

Activity icon

Replied to Driver [smb] Is Not Supported

Thank you for your suggestion. Composer failed to install danhunsaker/laravel-flysystem-others. It conflicts with laravel/framework v8.11.0.

Here is the full Composer output:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install danhunsaker/laravel-flysystem-others v1.3.5
    - Conclusion: don't install danhunsaker/laravel-flysystem-others v1.3.4
    - Conclusion: don't install danhunsaker/laravel-flysystem-others v1.3.3
    - Conclusion: don't install danhunsaker/laravel-flysystem-others v1.3.2
    - Conclusion: don't install danhunsaker/laravel-flysystem-others v1.3.1
    - Conclusion: don't install danhunsaker/laravel-flysystem-others v1.3.0.1
    - Conclusion: remove laravel/framework v8.11.0
    - Installation request for danhunsaker/laravel-flysystem-others ^1.3 -> satisfiable by danhunsaker/laravel-flysystem-others[1.x-dev, v1.3.0.1, v1.3.1, v1.3.2, v1.3.3, v1.3.4, v1.3.5].
    - Conclusion: don't install laravel/framework v8.11.0
    - danhunsaker/laravel-flysystem-others 1.x-dev requires illuminate/filesystem ^5.0 || ^6.0 -> satisfiable by illuminate/filesystem[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, 6.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9, v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4, v6.1.0, v6.10.0, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.18.10, v6.18.11, v6.18.12, v6.18.13, v6.18.14, v6.18.15, v6.18.16, v6.18.17, v6.18.18, v6.18.19, v6.18.2, v6.18.20, v6.18.21, v6.18.22, v6.18.23, v6.18.24, v6.18.25, v6.18.26, v6.18.27, v6.18.28, v6.18.29, v6.18.3, v6.18.30, v6.18.31, v6.18.32, v6.18.33, v6.18.34, v6.18.35, v6.18.36, v6.18.37, v6.18.38, v6.18.39, v6.18.4, v6.18.40, v6.18.41, v6.18.42, v6.18.43, v6.18.5, v6.18.6, v6.18.7, v6.18.8, v6.18.9, v6.19.0, v6.19.1, v6.2.0, v6.3.0, v6.4.1, v6.5.0, v6.5.1, v6.5.2, v6.6.0, v6.6.1, v6.6.2, v6.7.0, v6.8.0].
    - don't install illuminate/filesystem 5.0.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.1.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.2.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.3.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.4.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.5.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.6.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.7.17|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.7.18|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.7.19|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.7.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 5.8.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem 6.x-dev|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.0.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.0.22|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.0.25|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.0.26|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.0.28|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.0.33|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.0.4|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.13|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.16|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.20|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.22|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.25|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.28|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.30|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.31|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.41|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.6|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.1.8|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.19|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.21|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.24|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.25|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.26|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.27|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.28|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.31|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.32|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.37|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.43|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.45|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.6|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.2.7|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.3.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.3.16|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.3.23|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.3.4|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.4.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.4.13|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.4.17|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.4.19|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.4.27|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.4.36|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.4.9|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.16|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.17|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.28|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.33|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.34|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.35|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.36|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.37|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.39|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.40|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.41|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.43|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.5.44|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.10|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.11|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.12|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.13|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.14|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.15|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.16|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.17|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.19|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.20|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.21|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.22|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.23|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.24|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.25|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.26|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.27|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.28|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.29|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.3|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.30|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.31|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.32|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.33|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.34|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.35|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.36|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.37|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.38|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.39|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.4|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.5|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.6|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.7|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.8|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.6.9|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.10|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.11|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.15|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.20|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.21|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.22|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.23|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.26|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.27|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.28|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.3|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.4|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.5|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.6|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.7|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.8|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.7.9|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.11|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.12|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.14|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.15|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.17|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.18|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.19|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.20|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.22|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.24|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.27|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.28|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.29|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.3|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.30|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.31|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.32|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.33|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.34|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.35|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.36|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.4|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.8|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v5.8.9|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.0.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.0.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.0.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.0.3|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.0.4|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.1.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.10.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.11.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.12.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.13.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.13.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.14.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.15.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.15.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.16.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.17.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.17.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.10|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.11|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.12|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.13|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.14|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.15|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.16|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.17|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.18|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.19|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.20|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.21|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.22|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.23|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.24|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.25|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.26|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.27|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.28|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.29|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.3|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.30|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.31|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.32|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.33|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.34|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.35|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.36|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.37|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.38|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.39|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.4|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.40|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.41|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.42|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.43|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.5|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.6|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.7|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.8|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.18.9|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.19.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.19.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.2.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.3.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.4.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.5.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.5.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.5.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.6.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.6.1|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.6.2|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.7.0|don't install laravel/framework v8.11.0
    - don't install illuminate/filesystem v6.8.0|don't install laravel/framework v8.11.0
    - Installation request for laravel/framework (locked at v8.11.0, required as ^8.0) -> satisfiable by laravel/framework[v8.11.0].

Is there a lower version of Laravel 8 to which I could downgrade to resolve the dependency conflicts?

Oct
20
3 months ago
Activity icon

Started a new Conversation Driver [smb] Is Not Supported

I recently upgraded to Laravel 8. When I run a script that requires the smb driver, an exception is thrown that says "driver [smb] is not supported."

Here is my config/filesystem.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default filesystem disk that should be used
    | by the framework. The "local" disk, as well as a variety of cloud
    | based disks are available to your application. Just store away!
    |
    */

    'default' => env('FILESYSTEM_DRIVER', 'local'),

    /*
    |--------------------------------------------------------------------------
    | Default Cloud Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Many applications store files both locally and in the cloud. For this
    | reason, you may specify a default "cloud" driver here. This driver
    | will be bound as the Cloud disk implementation in the container.
    |
    */

    'cloud' => env('FILESYSTEM_CLOUD', 's3'),

    /*
    |--------------------------------------------------------------------------
    | Filesystem Disks
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many filesystem "disks" as you wish, and you
    | may even configure multiple disks of the same driver. Defaults have
    | been setup for each driver as an example of the required options.
    |
    | Supported Drivers: "local", "ftp", "sftp", "s3"
    |
    */

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
        ],
        'manufacturing' => [
            'driver' => 'smb',
            'user' => 'user',
            'password' => '*******',
            'domain' => 'doublel.local',
            'host' => '192.168.1.14',
            'drive_name' => 'manufacturing'
        ],
        'usershares' => [
            'driver' => 'smb',
            'user' => 'user',
            'password' => '*******',
            'domain' => 'doublel.local',
            'host' => '192.168.1.14',
            'drive_name' => 'usershares'
        ],
    ],

];

I installed robgridley/flysystem-smb through composer. Is there anything else that I'm missing?

Activity icon

Started a new Conversation Invalid Object Name [SESSIONS]

I recently installed Laravel 8. The site displays the following error when I open it:

Illuminate\Database\QueryException SQLSTATE[42S02]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'sessions'. (SQL: select top 1 * from [sessions] where [id] = {SESSION_ID}

I saw in the documentation that I should run the following commands:

php artisan session:table

php artisan migrate

My config/database.php file has four database connections configured. How do I know which database the migration will affect?

Sep
16
4 months ago
Activity icon

Started a new Conversation Applying Additional Form Validation Rules To Selectively Required Fields

I have a form that only requires that one field be complete; it doesn't matter which one. If the field has a value, I would like that value to meet other criteria. Here is the form:

<form action="{{ route('reports.customerordersearch') }}" method="get">
                <div class="form-group">
                    <label class="form-label" for="customer_id">CUSTOMER:</label>
                    @error('customer_id')
                    <div class="alert alert-danger" role="alert">{{ $message }}</div>
                    @enderror
                    <select class="custom-select" name="customer_id">
                        <option value="" selected>Select a customer</option>
                        @foreach($customers as $customer)
                        <option value="{{ $customer->ID }}">{{ $customer->NAME }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label" for="order-number">CUSTOMER ORDER NUMBER:</label>
                    @error('order-number')
                    <div class="alert alert-danger" role="alert">{{ $message }}</div>
                    @enderror
                    <input type="text" name="order_number" class="form-control{{ $errors->has('order-number') ? ' is-invalid' : ''}}" value="{{ old('order-number') }}" placeholder="Enter a customer order number to search for" />
                </div>
                <div class="form-group">
                    <label class="form-label" for="order_status">ORDER STATUS:</label>
                    @error('order_status')
                    <div class="alert alert-danger" role="alert">{{ $message }}</div>
                    @enderror
                    <select class="custom-select" name="order_status">
                        <option value="U" selected>Select an order status</option>
                        <option value="R">Released</option>
                        <option value="C">Closed</option>
                        <option value="H">On hold</option>
                        <option value="X">Cancelled/Void</option>
                    </select>
                </div>
                <input class="btn btn-primary" type="submit" name="submit" value="Search" />
                @csrf
            </form>

Here are the validation requirements:

$validStatuses = array_keys(self::CUSTOMER_ORDER_STATUS);
            $validInput = $request->validate([
                'customer_id' => ['bail', 'required_without_all:order_number,order_status', 'alpha_num'],
                'order_number' => ['bail', 'required_without_all:customer_id,order_status', 'string'],
                'order_status' => ['bail', 'required_without_all:order_number,customer_id', Rule::in($validStatuses)]
            ]);

If I only fill out Order Status, the Customer field complains that its value, which is intentionally left blank, is not alphanumeric. I would like its alphanumeric requirement to only apply if the field has a value. How can I do that?

Activity icon

Awarded Best Reply on Conditional Where Clauses Using Query Builder

Thanks for your input. I had my variables in an Eloquent collection already. After tinkering with the code, I think I found the solution:

$variableRevision = DB::connection('engineering')
                ->table('VariableValue as vv')
                ->join('Documents as d', 'd.DocumentID', '=', 'vv.DocumentID')
                ->select('VariableID', DB::raw('max(RevisionNo) as MaxRevisionNo'))
                ->where('d.Filename', '=', $this->partNumber . self::SOLIDWORKS_PART_FILE_EXTENSION)
                ->whereIn('vv.VariableID', self::PDM_VARIABLES)
                ->groupBy('vv.VariableID')
                ->get();

            $variableValues = DB::connection('engineering')
                ->table('VariableValue as vv')
                ->join('Variable as v', 'v.VariableID', '=', 'vv.VariableID')
                ->join('Documents as d', 'd.DocumentID', '=', 'vv.DocumentID')
                ->select('v.VariableName', 'vv.ValueText')
                ->where('d.Filename', '=', $this->partNumber . self::SOLIDWORKS_PART_FILE_EXTENSION);

            if($variableRevision->count() > 0)
            {
                $variableValues->where(function($query) use ($variableRevision, $variableValues){
                    $variableRevision->each(function($item, $key) use ($query, $variableValues){
                        $query->orWhere(function($q) use($item){
                           $q->where('vv.VariableID', '=', $item->VariableID)
                               ->where('vv.RevisionNo', '=', $item->MaxRevisionNo);
                        });
                    });
                });
            }
            $values = $variableValues->get();
Sep
12
4 months ago
Activity icon

Replied to Form Validation

@lemmon This worked! Thanks for your help.

Sep
11
4 months ago
Activity icon

Replied to Form Validation

I apologize for not explaining what I needed better. I need the form to only complain if part-number, part-description, and part-category are empty. If any one of those three fields are filled, the form should submit without complaint. Does that make more sense?

Activity icon

Replied to Form Validation

Ismaile,

Thanks for weighing in. I tried your solution, and the validation still fails if part-number or part-description are empty.

Activity icon

Started a new Conversation Form Validation

I have three fields in a form. Only one of them needs to be filled out for the form to submit. Whenever only the radio button field is selected, the validation triggers an error on the two input fields for not being completed.

Here is the form:

<form action="{{ route('reports.partsearch') }}" method="get">
    <div class="form-group">
        <label class="form-label" for="part-number">PART NUMBER:</label>
        @error('part-number')
        <div class="alert alert-danger" role="alert">{{ $message }}</div>
        @enderror
        <input type="text" name="part-number" class="form-control{{ $errors->has('part-number') ? ' is-invalid' : ''}}" value="{{ old('part-number') }}" placeholder="Enter a part number to search for" />
    </div>
    <div class="form-group">
        <label class="form-label" for="part-description">DESCRIPTION:</label>
        @error('part-description')
        <div class="alert alert-danger" role="alert">{{ $message }}</div>
        @enderror
        <input type="text" name="part-description" class="form-control{{ $errors->has('part-number') ? ' is-invalid' : ''}}" value="{{ old('part-description') }}" placeholder="Enter a part description to search for" />
    </div>
    <div class="form-group">
        <label for="part-category">PART CATEGORY:</label>
        <div class="form-check">
            <input name="part-category" class="form-check-input" type="radio" value="PP" id="part-category-pp" {{ (old('part-category') === 'PP') ? 'checked' : '' }}/>
            <label class="form-check-label" for="part-category-pp">Purchased Parts</label>
        </div>
        <div class="form-check">
            <input name="part-category" class="form-check-input" type="radio" value="MP" id="part-category-mp" {{ (old('part-category') === 'MP') ? 'checked' : '' }}/>
            <label class="form-check-label" for="part-category-mp">Manufactured Parts</label>
        </div>
        <div class="form-check">
            <input name="part-category" class="form-check-input" type="radio" value="BOTH" id="part-category-mp" {{ (old('part-category') === 'BOTH') ? 'checked' : '' }}/>
            <label class="form-check-label" for="part-category-mp">Both</label>
        </div>
    </div>
    <input class="btn btn-primary" type="submit" name="submit" value="Search" />
</form>

Here are my validation rules:

$validInput = $request->validate([
    'part-number' => ['bail', 'required_without_all:part-description, part-category', 'string'],
    'part-description' => ['bail', 'required_without_all:part-number, part-category', 'string'],
    'part-category' => [Rule::in(['MP', 'PP', 'BOTH'])]
]);

Can anyone tell me what I'm doing wrong? Thanks.

Sep
08
4 months ago
Activity icon

Started a new Conversation Use Query Builder To Select From Two Subqueries

I'm at a loss on how to duplicate the following query using the query builder:

select ii.total_in, io.total_out, (ii.total_in - io.total_out) as QTY_ON_HAND, ii.warehouse_id, ii.part_id 
from (select sum(it.qty) as total_in, it.warehouse_id, it.part_id from INVENTORY_TRANS it join PART_SITE ps on it.PART_ID=ps.PART_ID where it.type='I' and it.PART_ID = '46277' and it.TRANSACTION_DATE <= '2019-01-01' and ps.SITE_ID='AF' group by it.WAREHOUSE_ID, it.PART_ID) as ii
join (select sum(it.qty) as total_out, it.warehouse_id, it.part_id from INVENTORY_TRANS it join PART_SITE ps on it.PART_ID=ps.PART_ID where it.type='O' and it.PART_ID = '46277' and it.TRANSACTION_DATE <= '2019-01-01' and ps.SITE_ID='AF' group by it.WAREHOUSE_ID, it.PART_ID) as io on ii.PART_ID = io.PART_ID and ii.WAREHOUSE_ID = io.WAREHOUSE_ID
where (ii.total_in - io.total_out) > 0
order by ii.WAREHOUSE_ID, ii.PART_ID

Any ideas?

Aug
27
4 months ago
Activity icon

Replied to Conditional Where Clauses Using Query Builder

Thanks for your input. I had my variables in an Eloquent collection already. After tinkering with the code, I think I found the solution:

$variableRevision = DB::connection('engineering')
                ->table('VariableValue as vv')
                ->join('Documents as d', 'd.DocumentID', '=', 'vv.DocumentID')
                ->select('VariableID', DB::raw('max(RevisionNo) as MaxRevisionNo'))
                ->where('d.Filename', '=', $this->partNumber . self::SOLIDWORKS_PART_FILE_EXTENSION)
                ->whereIn('vv.VariableID', self::PDM_VARIABLES)
                ->groupBy('vv.VariableID')
                ->get();

            $variableValues = DB::connection('engineering')
                ->table('VariableValue as vv')
                ->join('Variable as v', 'v.VariableID', '=', 'vv.VariableID')
                ->join('Documents as d', 'd.DocumentID', '=', 'vv.DocumentID')
                ->select('v.VariableName', 'vv.ValueText')
                ->where('d.Filename', '=', $this->partNumber . self::SOLIDWORKS_PART_FILE_EXTENSION);

            if($variableRevision->count() > 0)
            {
                $variableValues->where(function($query) use ($variableRevision, $variableValues){
                    $variableRevision->each(function($item, $key) use ($query, $variableValues){
                        $query->orWhere(function($q) use($item){
                           $q->where('vv.VariableID', '=', $item->VariableID)
                               ->where('vv.RevisionNo', '=', $item->MaxRevisionNo);
                        });
                    });
                });
            }
            $values = $variableValues->get();
Aug
26
4 months ago
Activity icon

Started a new Conversation Conditional Where Clauses Using Query Builder

I have one query that is dependent on the results of another. First, I run the following query against a SQL Server DB table:

$variableRevision = DB::connection('engineering')
                ->table('VariableValue as vv')
                ->join('Documents as d', 'd.DocumentID', '=', 'vv.DocumentID')
                ->select('VariableID', 'max(RevisionNo) as MaxRevisionNo')
                ->where('d.Filename', '=', $this->partNumber . self::SOLIDWORKS_PART_FILE_EXTENSION)
                ->whereIn('vv.VariableID', self::PDM_VARIABLES)
                ->get();

This query may return as many as 3 results. I would like to use the results of this query to generate the where clause of the following query:

SELECT v.VariableName, vv.ValueText
  FROM VariableValue as vv
  join Variable as v on v.VariableID = vv.VariableID
  join Documents as d on vv.DocumentID = d.DocumentID
  where d.Filename='151208.SLDPRT' and ((vv.VariableID=61 and vv.RevisionNo=3) or (vv.VariableID=62 and vv.RevisionNo=12) or (vv.VariableID=69 and vv.RevisionNo=12))
  order by vv.VariableID asc

How can I use the VariableIDs and MaxRevisionNos from the first query in the second query?

Aug
06
5 months ago
Activity icon

Replied to Forms, Query Strings, And Controller Parameters

I reviewed the Routing and Form Handling sections, but I didn't find what I was looking for. What did I miss?

Activity icon

Started a new Conversation Forms, Query Strings, And Controller Parameters

I have an HTML form that submits a GET request. Below is the Blade template for it:

@extends('base')

@section('content')
    @error('serial')
    <div class="alert alert-danger">{{ $message }}</div>
    @enderror
    <div class="row">
        <p>Type a part number into the box and press "Generate Report" (Example:
            <a href="{{ route('weldtub.show', ['serial' => '90114-624']) }}"> 90114-624</a>).</p>
        <p>Printing is optimized for the Chrome browser.
            <a href="javascript:window.print()"><em class="fi-print"></em> Click here to print.</a></p>
        <p>To print select tubs type desired page numbers under print preview (Example: 1-3 or 1,2,3)</p>
    </div>
    <div class="row">
        <form action="{{ route('weldtub.show', ['serial'])  }}" method="get">
            <label for="serial">Serial Number:</label>
            <input type="text" name="serial" value="{{ old('serial') or '' }}">
            <input type="submit" value="Generate" class="button postfix">
            @csrf
        </form>
    </div>
@endsection

The route definition is as follows:

Route::get('/fabrication/weldtub/{serial}', '[email protected]')->name('weldtub.show');

When the form submits, I would like it to use this route instead of appending a query string the the URL. How can I do that? If this isn't the right way to make this work, please point me in the right direction.