Member Since 6 Years Ago

Ceredigion

Experience Points
44,110
Total
Experience

890 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
286
Lessons
Completed
Best Reply Awards
9
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 9
44,110 XP
May
17
1 day ago
Activity icon

Replied to Pagination With Collection

@tray2 Mapping over to grab the first item in a group. I don't want to show all of the images only the first image of a group.

@siangboon Thanks i'll give that a try

Activity icon

Started a new Conversation Pagination With Collection

Hi. I've got an issue when trying to paginate a collection, but as its a collection there is no paginate.

I need to sort the data in a way that it orders it correctly and grabs the first in the group rather than show all the scans, is there a way I can put it into one so I can paginate ?

    $collection = CustomerScan::where('user_id', Auth::user()->id)
            ->orderByRaw('CAST(created_at AS DATE) DESC') // order by future grouped by
            ->orderBy('group_id') // order within each group
            ->orderBy('order') // order within each group
            ->paginate(9);

        $scans = $collection->groupBy('group_id')->map(function ( $scans ) {
            return collect($scans)->first();
        });

Many thanks

Activity icon

Started a new Conversation Route::domain Problem With Auth.login

Hi.

I'm trying to setup an app that handles 2 domains, the frontend and the backend Domains which are separate.

The Laravel app that is currently live uses the same concept and works fine, the only difference with this latest version is that I've built it with the TALL stack.

If theres no domain route specified then all is ok, if I specify the domain route then I get an error when going to the login page,

InvalidArgumentException
View [auth.login] not found.

Any ideas?

Many thanks

Apr
19
4 weeks ago
Activity icon

Replied to Grouping By And Then Getting First Of A Sub Group.

That got me very close to where im trying to get to. I can play around and work on it a bit more to get it working as needed.

Thank you very much for your help

Activity icon

Started a new Conversation Grouping By And Then Getting First Of A Sub Group.

Hi.

I have an eloquent query that grabs images from a database which belong to a specific user, but also the images themselves are grouped.

What i am looking to do is to get all the pictures for that user but only the first of each group.

So in my db i have:

{
    {
        'id' => 1
        'user_id' => 1,
        'path' => '/s3/my_image_1.jpg',
        'group_id' => 'group_one'
    },

    {
        'id' => 2
        'user_id' => 1,
        'path' => '/s3/my_image_2.jpg',
        'group_id' => null
    },
    {
        'id' => 3
        'user_id' => 1,
        'path' => '/s3/my_image_3.jpg',
        'group_id' => 'group_one'
    },
    {
        'id' => 4
        'user_id' => 1,
        'path' => '/s3/my_image_4.jpg',
        'group_id' => 'group_two'
    },
    {
        'id' => 5
        'user_id' => 1,
        'path' => '/s3/my_image_5.jpg',
        'group_id' => 'group_two'
    }
}

What i want is to grab all the images but then only grab the first of each group to show on the blade template. I think that makes sense!

Any help or ideas would be great

Cheers

Apr
05
1 month ago
Activity icon

Replied to Is It Possible To Run Commands In Terminal From Laravel?

Ah awesome. I’ll give the symphony method a shot. But may try both ways to see how it goes.

Many thanks.

Apr
03
1 month ago
Activity icon

Started a new Conversation Is It Possible To Run Commands In Terminal From Laravel?

Hi. I am working on a personal project that I was interested in doing in Laravel so I can get it looking better, I've already built it in Python and Tkinter, but wondered after, if it was possible to run terminal commands using the laravel framework and return the result. Something like Subprocess.call();

Essentially what the project is, is an adb controller that can control an android device, but tkinter is pretty limited in styling choices.

Cheers

Jan
07
4 months ago
Activity icon

Replied to Search Query On ->when() With Relationship (Solved)

Solved...

I had the variable declared as public.

Activity icon

Started a new Conversation Search Query On ->when() With Relationship (Solved)

Hi.

I'm just trying to get a search query back from 2 dropdowns, one is a relationship of the Module model.

Im using the '->when()' property to get the results if the query is passed through, but i can't figure out how to get it to work on the relationship.

$modules = Module::
    		when($this->org != '', function ($query) {
                return $query->where('organisation_id', $this->org);
            })
            ->when($this->module != '', function ($query) {
                return $query->where('module_steps.module_id', $this->module);
            })
            ->get();

I keep getting 'Property [$modules] not found on component: [modules.steps]'

Cant quite get it right. Any ideas?

Nov
25
5 months ago
Activity icon

Started a new Conversation Laravel\Passport\Bridge\AccessToken::__toString() Must Not Throw An Exception

Hi.

Im playing around with Laravel passport and running into this error::

Symfony\Component\ErrorHandler\Error\FatalError: Method Laravel\Passport\Bridge\AccessToken::__toString() must not throw an exception, caught ErrorException: Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead. in file /Users/chrisbowen/Projects/WebDevelopment/jacabra-api/vendor/league/oauth2-server/src/ResponseTypes/BearerTokenResponse.php on line 0

Im using postman to post the request to register myself as an user::

http://api-playground.test/api/register?name=My Name&[email protected]&password=password&c_password=password

Routes::

use App\Http\Controllers\API\PassportAuthController;
use App\Http\Controllers\API\ProductController;

Route::post('register', [PassportAuthController::class, 'register']);
Route::post('login', [PassportAuthController::class, 'login']);

Route::middleware('auth:api')->group(function () {
    Route::get('get-user', [PassportAuthController::class, 'userInfo']);
});

Controller::

public function register(Request $request)
    {

        $valid = validator($request->only('email', 'name', 'password'), [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6',
        ]);

        if ($valid->fails()) {
            $jsonError=response()->json($valid->errors()->all(), 400);
            return \Response::json($jsonError);
        }

        $user = User::create([
            'name' => $request->name,
            'email' => $request->email,
            'password' => bcrypt($request->password)
        ]);

        $token = $user->createToken('Laravel8PassportAuth')->accessToken;

        return response()->json(['token' => $token], 200);
    }

The strange thing is that it is creating the user! Is there a setting on Postman that I need to set for it to work, or do I need to generate an api to access or something? Bear in mind this is the first time ive used postman and Passport.

Many thanks

Nov
24
5 months ago
Activity icon

Replied to OrderBy And GroupBy With Another OrderBy

Adding

->orderByRaw('CAST(created_at AS DATE) DESC') // order by future grouped by
->orderBy('order') // order within each group

That worked perfectly.

Thanks all for your help

Activity icon

Started a new Conversation OrderBy And GroupBy With Another OrderBy

Hi.

I have a collection that has orders the results by ->latest() and then it is grouped by date.

This all works but within the date group, I want to order it by oldest first rather than newest.

I'm the database table I do have and order column with the correct order.

I.e.

// How id like it

6th November
Scan 1 
Scan 2
Scan 3

4th November
Scan 1 
Scan 2
Scan 3

2nd November
Scan 1 
Scan 2
Scan 3

// How it is now
6th November
Scan 3 
Scan 2
Scan 1

4th November
Scan 3 
Scan 2
Scan 1

2nd November
Scan 3 
Scan 2
Scan 1

The controller looks like so::

public function index()
    {
        $collection = CustomerScan::where('user_id', Auth::id())
        ->latest()
        ->get()
        ->groupBy(function ($item) {
            return $item->created_at->format('Y-m-d');
        });

        return view('customer.scan-viewer.index')->with([
            'collection' => $collection,
        ]);
    }

View::

@foreach ($collection as $date => $scans)
	<hr style="border-top: 1px #ccc;">
	<span>
		<strong>{{ Carbon\Carbon::parse($date)->format('jS F Y') }}</strong>
	</span>
	<hr style="border-top: 1px #ccc;">

	@foreach($scans->chunk(3) as $chunk)
		@foreach($chunk as $scan)
			<!-- MY CODE --> 
                @endforeach
 	@endforeach

@endforeach

Any help would be greatful.

Cheers

Nov
19
5 months ago
Activity icon

Started a new Conversation Could Not Resolve: Mydomain.test (Domain Name Not Found)

Hi.

I've just started to try and run some dusk tests for the first time and im getting the error:

Could not resolve: mydomain.test (Domain name not found)

I'm using Valet to serve my test site on Mac osx and all that works, but not sure why dusk cannot use it.

If I set the driver to use localhost or an IP it comes back with the html of the default valet page not found.

Is there a specific location dusk needs to point at?

Cheers