Randy_Johnson

Member Since 2 Years Ago

Experience Points
10,330
Total
Experience

4,670 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
9
Lessons
Completed
Best Reply Awards
1
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 3
10,330 XP
Feb
21
1 week ago
Activity icon

Started a new Conversation Stock Ticker

Hi, I am looking to create a Portfolio page, for hobbies reasons. For this I will need to connect to finance service through an API, most likely going to the Yahoo Finance. Can anyone point me in the right direction for doing this in Laravel?

Jan
31
1 month ago
Activity icon

Started a new Conversation SOLID!

Is it worth me taking to the time to learn this. Just how valuable is it?

Jan
25
1 month ago
Activity icon

Started a new Conversation Running JetStream With LiveWire. Class 'Inertia\Inertia' Not Found

I follow everything here

https://jetstream.laravel.com/2.x/installation.html

going down the livewire route, but still!

Class 'Inertia\Inertia' not found 

Does anyone know how I can fix this.

Activity icon

Replied to Laravel 8: Jetstream; Livewire; Inertia Error

Which is better? Or is it down to personal preference?

Jan
24
1 month ago
Activity icon

Started a new Conversation Middleware On Specific Methods

I have run into a problem where I have multiple users using different functions in one Controller, the problem is that a standard user can have access to a controller that has admin functionality. I did this because I thought I can get away with having to create multiple of the same controllers.

The problem is I don't want a standard user running admin functionality from that controller, so I was wondering if I can put restrictions with middleware on a specific method.

D:.
│   Controller.php
│   WelcomeController.php
│
├───Auth
│       ConfirmPasswordController.php
│       ForgotPasswordController.php
│       LoginController.php
│       RegisterController.php
│       ResetPasswordController.php
│       VerificationController.php
│
├───Dashboard
│       AdminController.php
│       AttendanceController.php
│       CustodialController.php
│       FeeController.php
│       GradeController.php
│       ImageController.php
│       InjuryController.php
│       PaymentController.php
│       PermissionController.php
│       ReportController.php
│       RoleController.php
│       StudentController.php
│       SubjectController.php
│       TeacherController.php
│       TimeTableController.php
│       UserController.php
│
└───Tools
        MailController.php
        MessageAlertController.php
        MessageController.php
Jan
21
1 month ago
Activity icon

Started a new Conversation Moved File, Now Component Cannot Be Found

I moved my whole file from C: to D: and now I have this error message.

View [components.user.update] not found. (View: D:\Josh\Computing\Projects\School Project\resources\views\dashboard\users.blade.php) 

I check to see if the file was there, and low and behold it is. Am just wondering is there a command to fix this. Or will I have to just create again and copy and paste the code.

Jan
17
1 month ago
Activity icon

Replied to My Own Package Not Working After Running Composer...

I found the problem. I hadn't allowed the app to see it through the app config. It was amazing, I wasn't even thinking about it and poof, the answer just pop into my head like magic.

config/app.php

CoteHeath\ContactForm\ContactFormServiceProvider::class,

Activity icon

Started a new Conversation My Own Package Not Working After Running Composer...

I followed this tutorial and have reached the end. Now the time has come to install the package which seems to be okay. But running the website results in nothing.

Is there something else I have to do because right now I am getting 404.

I checked the vendor files and everything is there.

TUTORIAL URL

https://pusher.com/tutorials/publish-laravel-packagist

PACKAGE COMPOSER

composer require coteheath/contactform

MESSAGE OF THE INSTALLING OF THE PACKAGE

Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://geUsing version dev-master for coteheath/contactform
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing coteheath/contactform (dev-master 8355e5b): Cloning 8355e5bdd0 from cache
Writing lock file
Generating optimized autoload files
Deprecation Notice: Class CoteHeath\ContactForm\Http\Controllers\ContactFormController located in D:/Josh/Computing/Projects/Package-Test/vendor/coteheath/contactform/src\Http\controllers\ContactFormController.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Use the `composer fund` command to find out more!                                                                                                           Starting Laravel development server: http://127.0.0.1:8000

FILE SYSTEM WHEN THE PACKAGE IS INSTALLED

D:\JOSH\COMPUTING\PROJECTS\PACKAGE-TEST\VENDOR\COTEHEATH
└───contactform
    └───src
        ├───Database
        │   └───migrations
        ├───Http
        │   └───controllers
        ├───Models
        ├───resources
        │   └───views
        └───routes
Jan
13
1 month ago
Activity icon

Replied to Packagist - Stability Problem

I have this in my github account for the project.

{
    "name": "coteheath/calculator",
    "description": "This is my first package release.",
    "require": {},
    "minimum-stability": "dev",
    "version": "1.0"
}

I really don't have a clue right now.

Jan
12
1 month ago
Activity icon

Started a new Conversation Packagist - Stability Problem

Okay, so am just testing the water. Here is my package.

composer require coteheath/calculator

The error

  [InvalidArgumentException]
  Could not find a version of package coteheath/calculator matching your minimum-s
  tability (stable). Require it with an explicit version constraint allowing its d
  esired stability.

Activity icon

Replied to Package Creation Help On Tutorial

Sorry guys, like always with me its something small and stupid.

I named the folder view instead of views.

Activity icon

Started a new Conversation Package Creation Help On Tutorial

I am following this tutorial -

https://devdojo.com/devdojo/how-to-create-a-laravel-package

But I am now getting this error on step 7.

InvalidArgumentException
View [add] not found. 
Dec
30
2 months ago
Activity icon

Started a new Conversation Creating Own Personal Package.

Im sick of copying pasting code from one project to another and want to set it up through cmd, like composer require but a more personal way.

Dec
20
2 months ago
Activity icon

Replied to Integrity Constraint Violation

Now I have this really annoying problem with the seeding. It isn't something that I cannot work around, but the option would be nice.

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`school`.`messages`, CONSTRAINT `messages_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE) (SQL: insert into `messages` (`user_id`, `user_id_sender`, `head`, `body`, `updated_at`, `created_at`) values (2, 4, laborum, Delectus quis eveniet odit eum. Consequatur nisi nihil omnis quo aliquid quas iure. Rerum non cum ratione beatae vitae ipsa. Id temporibus officiis minus eaque maiores voluptatum. Accusantium aut est ipsa ab., 2020-12-20 15:06:32, 2020-12-20 15:06:32))

I think it has something to do with that the user doesn't exist that it is trying to link to.

Is there a quick fix or am I going to have to create a seeder for my Roles, user_details etc.. (So when accessing pages there is no error) and if I do do this, what is there to say that the error still would not occur.

Activity icon

Started a new Conversation Integrity Constraint Violation

I need to have two foreign key constraints that being that of two users, one who is to receive the message and one that is to send the message. Unfortunately, I am receiving this error.

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`school`.`messages`, CONSTRAINT `messages_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE) (SQL: insert into `messages` (`user_id`, `user_id_sender`, `head`, `body`, `updated_at`, `created_at`) values (0, 5, dolorum, Sit est fugit est voluptatem voluptatem enim autem. Ut dicta assumenda non maiores., 2020-12-20 14:54:17, 2020-12-20 14:54:17))
    public function up()
    {
        Schema::create('messages', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->foreignId('user_id_sender');
            $table->string('head');
            $table->string('body');
            $table->timestamps();
        });
    }

Activity icon

Replied to How To Seed Db In Pivot Table Laravel?

php artisan make:migration categories

php artisan migrate:fresh

Activity icon

Replied to Trying To Get Property 'id' Of Non-object

Ah yes, very good, but I do it in this array style because in the future I may want to send more data into the page.

An example

        $users = User::with(['roles', 'image', 'detail'])->get();
        $adminCount = DB::table('model_has_roles')->where('role_id', '=', 1)->count();
        $teacherCount = DB::table('model_has_roles')->where('role_id', '=', 2)->count();
        $parentCount = DB::table('model_has_roles')->where('role_id', '=', 3)->count();
        $studentCount = DB::table('model_has_roles')->where('role_id', '=', 4)->count();
        $roleTotal = $adminCount + $teacherCount + $parentCount + $studentCount;
        $data = array('users' => $users, 'adminCount' => $adminCount, 'teacherCount' => $teacherCount, 'parentCount' => $parentCount, 'studentCount' => $studentCount, 'roleTotal' => $roleTotal);
        return view('dashboard.users')->with('data', $data);

If you know a better way am all ears.

Activity icon

Replied to Trying To Get Property 'id' Of Non-object

How would you do it.

Activity icon

Started a new Conversation Trying To Get Property 'id' Of Non-object

I have done this so many times and its really weird that I am not able to see the problem quickly.

+++ MessageController +++

class MessageController extends Controller
{

    public function index()
    {
        $user = auth()->user();
        $messages = Message::where('user_id', $user->id)->first();
        $data = array('messages' => $messages);
      
        return view('dashboard.messages')->with('data', $data);
    }

+++ Blade View +++

 @foreach($data['messages'] as $datum)
                            <tr>
                                <td>{{$datum->id}}</td>
                                <td>{{$datum->user_id}}</td>
                                <td>{{$datum->user_id_sender}}</td>
                                <td>{{$datum->head}}</td>
                                <td>{{$datum->body}}</td>
                                <td>{{$datum->created_at}}</td>
                                <td>

When I dd($data) as well as dd($data['messages']) everything is there as expect but running dd($datum) just return true.

Dec
07
2 months ago
Activity icon

Replied to Button Not Responding In Livewire

Mark as answered.

Activity icon

Replied to Button Not Responding In Livewire

Is this button inside the html connected to the component controller.

Example:

Counter.php Counter.blade.html

Because if it isn't inside the html that was created with the component controller, it won't work.

Dec
05
3 months ago
Activity icon

Replied to Are Components A Bad Idea?

What are sub-view? Includes etc?

Activity icon

Started a new Conversation Moving The Resource Controllers Into Another File

I moved my resource controllers into another file and now it cannot find them. I tried many things to no avail and just a barrage of error messages.

The files were originally just in the "controller" file, but I moved them into the "dashboard/controller". Here is the update I made to the web.route file.

<?php

use Illuminate\Support\Facades\Route;

use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;

use App\Http\Controllers\Dashboard\UserController;
use App\Http\Controllers\Dashboard\FeeController;
use App\Http\Controllers\Dashboard\GradeController;
use App\Http\Controllers\Dashboard\InjuryController;
use App\Http\Controllers\Dashboard\PaymentController;
use App\Http\Controllers\Dashboard\PermissionController;
use App\Http\Controllers\Dashboard\ReportController;
use App\Http\Controllers\Dashboard\RoleController;
use App\Http\Controllers\Dashboard\SubjectController;
use App\Http\Controllers\Dashboard\TimetableController;
use App\Http\Controllers\Dashboard\AttendanceController;
use App\Http\Controllers\Dashboard\ChartController;
use App\Http\Controllers\Dashboard\ImageController;
use App\Http\Controllers\Dashboard\MailController;





Auth::routes();

Route::get('/', [App\Http\Controllers\WelcomeController::class, 'index'])->name('welcome');

Route::prefix('dashboard')->group(function () 
{
    Route::resource('user',         UserController::class);
    Route::resource('fee',          FeeController::class);
    Route::resource('grade',        GradeController::class);
    Route::resource('injury',       InjuryController::class);
    Route::resource('payment',      PaymentController::class);
    Route::resource('report',       ReportController::class);
    Route::resource('subject',      SubjectController::class);
    Route::resource('timetable',    TimetableController::class);
    Route::resource('attendance',   AttendanceController::class);
    Route::resource('chart',        ChartController::class);
    Route::resource('permission',   PermissionController::class);
    Route::resource('role',         RoleController::class);

    Route::resource('image',        ImageController::class);   
});

Route::get('/account-create-email', [MailController::class, 'accountCreated'])->name('account-create-email');
Route::post('/private-email', [MailController::class, 'sendPrivate'])->name('private-email');
Dec
04
3 months ago
Activity icon

Replied to Are Components A Bad Idea?

I haven't read anything, but am thinking that the whole thing is processed before being served, so I think it wouldn't make a difference in the end.

Still, it is a question, is it adding to much complexity.

Thanks for your inputs.

Activity icon

Started a new Conversation Are Components A Bad Idea?

I was thinking that components are a bad idea due to that each component is making a request for data, where as sending all data for the page at the beginning.

Have I got this wrong, please enlighten me. But in my mind I see it has.

+++ No component +++ Gets request Send all information in one go

+++ Components +++ Gets Request Gets another request Gets another request etc..

Which seems to be a lot more back and forth.

Nov
30
3 months ago
Activity icon

Replied to Opening Emails In Website

I'll give it a shot.

Activity icon

Replied to Opening Emails In Website

Yes I do believe so. I am guessing it has something to do with

imap.hostinger.com 

since I am using hostinger.

https://webmail.hostinger.com/auth

I just want all emails here to be viewed in my dashboard.

Activity icon

Replied to Opening Emails In Website

No, I don't think this is what I am looking for. I want the dashboard to work as a email system, view all emails and reading them.

Like on gmail. I need to either connect into the email service and download the emails - or maybe use some api am not sure.

Activity icon

Started a new Conversation Opening Emails In Website

In the dashboard, I want to be able to view the emails on the host server, I have it set up so I can send via the host server.

Can anyone point me in the direction of how to do this.

Nov
29
3 months ago
Activity icon

Replied to Mailing Problem

Oh my goodness, such a silly mistakes I am making. Thank you

Activity icon

Replied to Mailing Problem

When receiving the email the variables are displayed as such.

dfasfsd
Inbox
Halycon-School <[email protected]>
	
1:18 PM (34 minutes ago)
	
to me
{{details['title']}}

{{details['body']}}
Activity icon

Replied to Mailing Problem

Ah yes I have done this, but I thought I will focus on fixing the first, since it all runs through the same controllers after MailController.

Activity icon

Replied to Mailing Problem

Its a very good point and I will be sure to do that, but I cannot stop scratching my head over this.

I removed the static, and am still getting the same problem, it was working yesterday when the user created the account. All was showing as expected.

Now is gone crazy. Here's all the code.

        $sendMail = new MailController();
        $sendMail->accountCreated($user->email);
Route::get('/account-create-email', [MailController::class, 'accountCreated'])->name('account-create-email');
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;

use App\Mail\SendMail;

class MailController extends Controller
{
    public function accountCreated($address)
    {
        $details = [
            'subject' => 'Your Halycon-School Account was Successfully Created!',
            'title' => 'Account Created!',
            'body' => 'Welcome to Halycon School! We look forward to meeting you.'
        ];

        Mail::to($address)->send(new SendMail($details));
    }

    public function sendPrivate(Request $request)
    {
        $address = $request->input('address');
        
        $details = [
            'subject' => $request->input('subject'),
            'title' => "Halycon-School",
            'body' => $request->input('body')
        ];

        Mail::to($address)->send(new SendMail($details));

        return redirect()->back();
    }
}
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SendMail extends Mailable
{
    use Queueable, SerializesModels;

    public $details;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($details)
    {
        $this->details = $details;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject($this->details['subject'])->view('emails.mail-temp');
    }
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="width=device-width, initial-scale=1.0">
    <title>{{details['subject']}}</title>
</head>
<body>
    <h1>{{details['title']}}</h1>
    <p>{{details['body']}}</p>
</body>
</html>

Help Please

Activity icon

Replied to Mailing Problem

Nope I tried before, the same results.

    public static function accountCreated($address)
    {
        $details = [
            'subject' => 'Your Halycon-School Account was Successfully Created!',
            'title' => 'Account Created!',
            'body' => 'Welcome to Halycon School! We look forward to meeting you.'
        ];

        Mail::to($address)->send(new SendMail($details));
    }

    public static function sendPrivate(Request $request)
    {
        $address = $request->input('address');
        
        $details = [
            'subject' => $request->input('subject'),
            'title' => "Halycon-School",
            'body' => $request->input('body')
        ];

        Mail::to($address)->send(new SendMail($details));

        return redirect()->back();
    }

{{$details['title']}}

{{$details['body']}}

I even went on to try this

{{$this->details['title']}}

{{$this->details['body']}}

Nov
28
3 months ago
Activity icon

Started a new Conversation Mailing Problem

+++ EmailController +++

    public static function sendPrivate(Request $request)
    {
        $address = $request->input('address');
        
        $details = [
            'subject' => $request->input('subject'),
            'title' => "Halycon-School",
            'body' => $request->input('body')
        ];

        Mail::to($address)->send(new SendMail($details));

        return redirect()->back();
    }

+++ SendMail - Mailable +++

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SendMail extends Mailable
{
    use Queueable, SerializesModels;

    public $details;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($details)
    {
        $this->details = $details;

    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject($this->details['subject'])->view('emails.mail-temp');
    }
}

+++ Email View +++

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="width=device-width, initial-scale=1.0">
    <title>{{$details->subject}}</title>
</head>
<body>
    <h1>{{$details->title}}</h1>
    <p>{{$details->body}}</p>
</body>
</html>
Nov
27
3 months ago
Activity icon

Awarded Best Reply on Moving 'Component' No Longer Renders It

I tried but it didn't work, so I just ran the command again with users/. Thanks for the quick response.

Activity icon

Replied to Moving 'Component' No Longer Renders It

I tried but it didn't work, so I just ran the command again with users/. Thanks for the quick response.

Activity icon

Started a new Conversation Moving 'Component' No Longer Renders It

I created a component which is working fine. But looking at the project as a whole it is becoming very messy. So I created a folder for this component called users - of course. But when changing the to accommodate I am getting the error of.

View [components.update-user] not found.
resources\views\components\users\update-user.blade.php
<x-users.updateuser :user="$user" :i="$i" />
Nov
21
3 months ago
Activity icon

Started a new Conversation Eloquent - Explanation Inside

Since I am grabbing all my information for the user in one line of code, it makes a lot of sense for me to do the vise versa.

$users = User::with(['roles', 'images', 'userDetails'])->get();

When creating a user from the admin panel I have it as suck.

 // Creates a new user
        User::create([
            'name' => $request->input('name'),
            'email' => $request->input('email'),
            'password' => Hash::make($request->input('password')),
        ]);

        // Grabs the user which we just created
        $user = User::where('email', $request->input('email'))->first();

        // Assign the user the selected role
        $user->assignRole($request->input('role'));

        // Enters the users details into the user_details table
        UserDetails::create([
            'user_id' => $user->id,
            'address' => $request->input('address'),
            'telephone' => $request->input('telephone'),
        ]);

But I am thinking that surely this can be done all at once and save the confusion.

Please help.

Nov
20
3 months ago
Activity icon

Replied to Eloquent Not Working

I just copied the db name. I have no idea how the eloquent works. Its like a magic box.

Activity icon

Replied to Eloquent Not Working

I found the problem - didn't have

use App\Models\Image;

Why it wasn't showing it as an error I don't know but I fear it had something to do with the try catch statement.

Activity icon

Started a new Conversation Eloquent Not Working

I have a database table called 'images' and a model called 'Image' but when I run

Image::create([
                'user_id' => $user->id,
                'url' => 'storage/img/user/'.$imageName
            ]);

Nothing happens. Running the next command works perfectly.

DB::table('images')->insert([
                'user_id' => $user->id, 
                'url' => 'storage/img/user/'.$imageName
            ]);
Activity icon

Replied to Pluck() Grabbing All Images Instead Of Just One

$user->images->url

Actually it was this simple. wtf is wrong with me.

Activity icon

Replied to Pluck() Grabbing All Images Instead Of Just One

Okay thank you. But it is very strange that I was using

{{$user->roles->pluck('name')->implode('')}}

and it was working fine. This is why I was so confused about the matter. Thank you, your way is much more suited.

Activity icon

Replied to Pluck() Grabbing All Images Instead Of Just One

and I cannot understand, clearly from the code I am wanting only 1 image corresponding to the user, as $user. Why is it returning all of them, that just stupid.

Activity icon

Replied to Pluck() Grabbing All Images Instead Of Just One

{{$user->images->pluck('url')->implode('')->first()}}

This is not working.

It is just giving me

syntax error, unexpected '<' (View: C:\Users\Josh\Desktop\Projects\spatie-permissions\resources\views\includes\users-table.blade.php) (View: C:\Users\Josh\Desktop\Projects\spatie-permissions\resources\views\includes\users-table.blade.php) 
Activity icon

Replied to Pluck() Grabbing All Images Instead Of Just One

Why can I not find this in the laravel documentation.

Activity icon

Started a new Conversation Pluck() Grabbing All Images Instead Of Just One

When using the Eloquent Pluck functionality, it is returning all the fields within the database under url.

+++ Returning String +++

storage/img/user/1605882108.jpegstorage/img/user/1605881403.jpegstorage/img/user/user.png

+++ Single Code +++

{{$user->images->pluck('url')->implode('')}}

+++ Blade HTML Full Page +++

<div>
    @php
        $i = 0;
    @endphp
    <!-- Users Table -->
    <div class="card-body">
        <table class="table table-striped">
            <thead class="thead-dark">
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">Name</th>
                    <th scope="col">Email</th>
                    <th scope="col">Role</th>
                    <th scope="col">Updated at</th>
                    <th scope="col"></th>
                </tr>
            </thead>
            <tbody>
                @foreach($data['users'] as $user)
                    <tr>
                        <td>{{$user->id}}</td>
                        <td>{{$user->name}}</td>
                        <td>{{$user->email}}</td>
                        <td>{{$user->roles->pluck('name')->implode('')}}</td>
                        <td>{{$user->updated_at}}</td>
                        <td>
                            <div class="float-right">
                                <button class="btn btn-warning" data-toggle="modal" data-target="#userUpdateModal{{$i}}">Show</button>
                                <form class="d-inline" action="{{route('user.destroy', $user->id)}}" method="POST">
                                    @csrf 
                                    @method('DELETE')
                                    <button type="submit" class="btn btn-danger" data-toggle="confirmation">Delete</button>
                                </form>
                            </div>
                        </td>
                    </tr>

                    {{-- Update user form --}}
                    <form action="{{route('user.update', $user->id)}}" method="POST" enctype="multipart/form-data">
                        @csrf
                        @method('PATCH')
                        <div class="modal" id="userUpdateModal{{$i}}" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="">Update</h5>
                                        <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">×</span>
                                        </button>
                                    </div>
                                    <div class="modal-body">
                                        <div classs="form-group">
                                            <img src="" alt="{{$user->images->pluck('url')->implode('')}}" class="img-thumbnail rounded p-2 mb-2">
                                        </div>
                                        <div class="form-group">
                                            <label for="">Name</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="name" value="{{$user->name}}" required>
                                        </div>
                                        <div class="form-group">
                                            <label for="">Email</label>
                                            <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="email" value="{{$user->email}}" required>
                                        </div>
                                        <div class="form-group">
                                            <label for="">Address</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="" placeholder="Buckingham Palace, London, England" name="address" value="">
                                        </div>
                                        <div class="form-group">
                                            <label for="">Telephone No.</label>
                                            <input type="tel" class="form-control bfh-phone" data-format="+dd (ddd) ddd-dddd" placeholder="" name="telephone" value="">
                                        </div>
                                        <div class="form-group">
                                            <label for="">Role</label>
                                            <select class="form-control" id="sel1" name="role" required>
                                                <option value="1">Admin</option>
                                                <option value="2">Teacher</option>
                                                <option value="3">Parent</option>
                                                <option value="4">Student</option>
                                            </select>
                                        </div>
                                        <div class="form-group files">
                                            <label for="">Upload Image</label>
                                            <input type="file" class="form-control" name="image">
                                        </div>                                              
                                    </div>
                                    <div class="modal-footer">
                                        <button class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                                        <button type="submit" class="btn btn-primary">
                                            Update
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>

                    @php
                        $i++;
                    @endphp
                @endforeach
            </tbody>
        </table>
        
    </div>
</div>