Member Since 4 Months Ago
1,010 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
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.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
Earned once your experience points ranks in the top 10 of all Laracasts users.
Replied to How Do I Pass A Value Of A Nested Livewire Input Into A Normal Html Form
Because I want to write it or pick from the drop down
Started a new Conversation How Do I Pass A Value Of A Nested Livewire Input Into A Normal Html Form
Hi, I am using Jetstream and am trying to modify the registration blade file, sadly its using normal blade, not Livewire
so I was wondering if there is a way to pass custom input wire:model back into it
registeration.blade.php
<form method="POST" action="{{ route('register') }}">
@csrf
<div>
<x-jet-label for="name" value="{{ __('Name') }}" />
<x-jet-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required autofocus autocomplete="name" />
</div>
<div class="mt-4">
<x-jet-label for="email" value="{{ __('Email') }}" />
<x-jet-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required />
</div>
<div class="mt-4">
<x-jet-label for="password" value="{{ __('Password') }}" />
<x-jet-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" />
</div>
<div class="mt-4">
<x-jet-label for="password_confirmation" value="{{ __('Confirm Password') }}" />
<x-jet-input id="password_confirmation" class="block mt-1 w-full" type="password" name="password_confirmation" required autocomplete="new-password" />
</div>
<div class="mt-4">
<x-jet-label for="grade" value="{{ __('Current Grade') }}" />
<x-jet-input id="password_confirmation" class="block mt-1 w-full" type="number" min="1" max="12" name="grade" required />
</div>
<div class="mt-4">
<x-jet-label for="branch" value="{{ __('Branch') }}" />
<livewire:profile.branches-dropdown for="branch" name="branch" />
</div>
<div class="flex items-center justify-end mt-4">
<a class="underline text-sm text-gray-600 hover:text-gray-900" href="{{ route('login') }}">
{{ __('Already registered?') }}
</a>
<x-jet-button class="ml-4">
{{ __('Register') }}
</x-jet-button>
</div>
</form>
and here is my custom component
<div>
<x-jet-dropdown align="right" width="48">
<x-slot name="trigger">
<input for="branch" id="branch" wire:model="branch" placeholder="Select a branch..." class="form-input rounded-md shadow-sm block mt-1 w-full" type="search" autocomplete="off" />
</x-slot>
<x-slot name="content">
@foreach($branches as $branch)
<span wire:click="select({{ $branch->id }})" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out">
{{ $branch->name }}
</span>
@endforeach
</x-slot>
</x-jet-dropdown>
</div>
Started a new Conversation How Do I Pass A Value Of A Nested Livewire Input Into A Parent Normal Form
Hi, I am using Jetstream and am trying to modify the registration blade file, sadly its using normal blade, not Livewire
so I was wondering if there is a way to pass custom input wire:model back into it
registeration.blade.php
<form method="POST" action="{{ route('register') }}">
@csrf
<div>
<x-jet-label for="name" value="{{ __('Name') }}" />
<x-jet-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required autofocus autocomplete="name" />
</div>
<div class="mt-4">
<x-jet-label for="email" value="{{ __('Email') }}" />
<x-jet-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required />
</div>
<div class="mt-4">
<x-jet-label for="password" value="{{ __('Password') }}" />
<x-jet-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" />
</div>
<div class="mt-4">
<x-jet-label for="password_confirmation" value="{{ __('Confirm Password') }}" />
<x-jet-input id="password_confirmation" class="block mt-1 w-full" type="password" name="password_confirmation" required autocomplete="new-password" />
</div>
<div class="mt-4">
<x-jet-label for="grade" value="{{ __('Current Grade') }}" />
<x-jet-input id="password_confirmation" class="block mt-1 w-full" type="number" min="1" max="12" name="grade" required />
</div>
<div class="mt-4">
<x-jet-label for="branch" value="{{ __('Branch') }}" />
<livewire:profile.branches-dropdown for="branch" name="branch" />
</div>
<div class="flex items-center justify-end mt-4">
<a class="underline text-sm text-gray-600 hover:text-gray-900" href="{{ route('login') }}">
{{ __('Already registered?') }}
</a>
<x-jet-button class="ml-4">
{{ __('Register') }}
</x-jet-button>
</div>
</form>
and here is my custom component
<div>
<x-jet-dropdown align="right" width="48">
<x-slot name="trigger">
<input for="branch" id="branch" wire:model="branch" placeholder="Select a branch..." class="form-input rounded-md shadow-sm block mt-1 w-full" type="search" autocomplete="off" />
</x-slot>
<x-slot name="content">
@foreach($branches as $branch)
<span wire:click="select({{ $branch->id }})" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out">
{{ $branch->name }}
</span>
@endforeach
</x-slot>
</x-jet-dropdown>
</div>
Replied to Now How Do I Layout This Design In Livewire...
I am using Livewire and tailwind, but am not sure what to do or what to lookup if I want to learn
Started a new Conversation Now How Do I Layout This Design In Livewire...
Hi All, I have this design that I want to implement, it consists of a day and some sessions, the sessions are done, but am not sure how do I layout the things, am not a css expert so that's why am trying to get help here
also it would be cool if someone told me what to read so that am not completely useless around complex designs in front end
Image of design here: https://pasteboard.co/JECyFbg.png
Awarded Best Reply on Livewire Component Tag Showing Weird Strings
@srasch Thanks for replying, apparently It was that top level comment that was causing the issue, I am not sure why but it broke the DOM, removing it fixed my issue
Replied to Livewire Component Tag Showing Weird Strings
@srasch Thanks for replying, apparently It was that top level comment that was causing the issue, I am not sure why but it broke the DOM, removing it fixed my issue
Started a new Conversation Livewire Component Tag Showing Weird Strings
Hello, I've declared a livewire component that goes by the name "add-article"
it has its own model and blade component
when I reuse the blade component using this tag
<livewire:add-article />
it shows this string
< wire:id="zvTZIl428DcClvOG5inZ" wire:initial-data="{"fingerprint":{"id":"zvTZIl428DcClvOG5inZ","name":"add-article","locale":"en"},"effects":{"listeners":[]},"serverMemo":{"children":[],"errors":[],"htmlHash":"250c6c27","data":{"title":null,"body":null,"image":null,"rules":{"title":"required|min:3|max:20","body":"required|min:5|max:256","image":"required"},"messages":{"required":"\u0647\u0630\u0627 \u0627\u0644\u062d\u0642\u0644 \u0645\u0637\u0644\u0648\u0628","body.min":"\u064a\u062c\u0628 \u0623\u0644\u0627 \u064a\u0642\u0644 \u0627\u0644\u0645\u0648\u0636\u0648\u0639 \u0639\u0646 5 \u0627\u062d\u0631\u0641","title.min":"\u064a\u062c\u0628 \u0623\u0644\u0627 \u064a\u0642\u0644 \u0627\u0644\u0639\u0646\u0648\u0627\u0646 \u0639\u0646 \u0663 \u0627\u062d\u0631\u0641"}},"dataMeta":[],"checksum":"0a379aa14e22effc233682470802845d4c28b94e82105e3bf1bfdf11a3d4bab7"}}"!-- Start Add Blog Section -->
here is the index.html part where I declare it
<div class="edit-blog">
<!-- Start Add Blog -->
<livewire:add-article />
<!-- End Add Blog Section -->
and here is the component itself
<!-- Start Add Blog Section -->
<div class="add-blog">
<div class="card mb-4">
<div class="card-header">
<i class="fas fa-chart-area ml-1"></i>
اضافة مقال
</div>
<div class="card-body">
<!-- Start Form ----------------->
<form wire:submit.prevent="addArticle">
<div class="row">
<div class="col-12 col-md-6">
<div class="form-group">
<label for="formGroupExampleInput">عنوان المقال</label>
<!-- Blog Title Input
-------------------------->
<input type="text" wire:model="title" class="form-control" id="formGroupExampleInput">
@error('title') <span class="text-danger">{{ $message }}</span> @enderror
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<label>اضافة صورة للمقال</label>
<!-- Upload Blog Image Input
-------------------------->
<div class="custom-file">
<input type="file" wire:model="image" class="custom-file-input" id="customFile">
<label class="custom-file-label" for="customFile">تحميل صورة</label>
@error('image') <span class="text-danger">{{ $message }}</span> @enderror
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="formGroupExampleInput2">محتوى المقال</label>
<!-- blog Content
-------------------------->
<textarea class="form-control" wire:model="body" id="formGroupExampleInput2" cols="30"
rows="5"></textarea>
@error('body') <span class="text-danger">{{ $message }}</span> @enderror
</div>
<!-- button Submit Form
-------------------------->
<button class="btn btn-primary">إضافة</button>
</form>
<!-- End Form
--------------->
</div>
</div>
</div>
Replied to Do I Need To Learn Blade To Learn Livewire? Or Can I Learn Livewire Directly?
Thanks a lot :)
Started a new Conversation Do I Need To Learn Blade To Learn Livewire? Or Can I Learn Livewire Directly?
Hi, I want to do some front end for a backend i built (as APIs), I explored my options and I decided to do server side rendering since its a small project anyway, but am not sure where to start, I read about Livewire but am not sure if its right for me?
also, is there a way to make livewire to use my API routes? cuz that's where I built my controllers.
Thanks 🙏
Replied to How Do I Schedule Some Code To Run At A Specific Time?
Thanks @marianomoreyra, I reached a conclusion that I'll schedule a cron job every day on 6 PM till 10 PM to do the logic, I was thinking of using a delayed dispatch but yea I had the same impression that Amazon's SQS had a maximum delay of 15 minutes
Replied to How Do I Schedule Some Code To Run At A Specific Time?
@marianomoreyra @michaloravec Thanks a lot 😃
actually after some reading, I don't want to schedule a console command, what I want is to dynamically schedule an action for each Session
in my app, I have a session booker where I want after the session's time is up, I want to mark all users who booked the session and didn't come to be marked as didnt_attend
so I was wondering how is that possible
Started a new Conversation How Do I Schedule Some Code To Run At A Specific Time?
Hello 👋, I was wondering how can I make some code run when some time comes?
Is there is some kind of a scheduler I can use so that when, let's say, 7 PM comes tomorrow, mark all students who didn't scan the QR code as didnt_attend
in the DB?
Also if there are any resources one can read about, that would be awesome
Started a new Conversation How Do I Track Things In A Many To Many Relationship
Hello 👋 I wanted to keep records of some things
I have Users
that can attend Sessions
I want to track whether these Users
**attended*8 the Sessions
, did they cancel it, did they didn't attend
so I was thinking I should do that in the pivot table but I don't know how to deal with the pivot tables since it doesn't have an eloquent model
so I was looking for resources to read from or watch
Thanks
Replied to A Good Way To Notify Users Through Email Of Some Event?
Thanks a lot, I was able to get exactly what I want through setting up Events and listeners :)
I recommend watching this cast :)
https://laracasts.com/series/whats-new-in-laravel-8/episodes/7
Started a new Conversation A Good Way To Notify Users Through Email Of Some Event?
Hi 👋 , I have a case where If some user cancelled a session, I want to notify other users that there is an opening in this session, am kinda new to backend development so I don't know which terms to look up
if someone can recommend a series for this here on Laracast it would be cool :)
Started a new Conversation Exporting Some Logic To A Class Caused A Mutability Issue
Hello, I exported some logic for booking a user into a session into a class called Booker
before I directly attached the user into the session (they have a many to many relationship) now I wanted to export them into their own class to do some logic and possibly through exceptions in case the user can't book this session
here is the code
class Booker extends Controller
{
static public function book(Session $session, User $user) {
self::makeSureSessionIsBookable($session, $user);
$session->attendees()->attach($user);
}
private static function makeSureSessionIsBookable(Session $session, User $user)
{
if ($session->attendees->count() >= $session->limit) throw new NoMoreSlotsToBookException();
}
}
when I dd($session->attendees)
after the attach, it shows nothing has been attached, even tho it is reflected in the database
am not sure what is the problem here
Replied to Which Is Better, Spatie Permissions & Roles Or Using Middlewares Or Policies?
I was thinking that Spatie would give me more flexibility along with Policies, like saying
// In CourseController
public function getAllVideos(User $user, Course $course) {
self.authorize('getVideos', $course);
return $course->videos;
}
and then in a CoursePolicy.php file i'd say
public function getVideos(User $user, Course $course)
{
return $user->hasRole('super-admin') || $user->hasRole('tutor') && $course->author->is($user) || $user->hasRole('learner') && $user->purchasedCourses->has($course);
}
this is more verbose and clear about the intent of what am trying to do
but am not sure if that respects the open closed principle because what if i wanted to make a new role like a subscribed user, i'd have to go to this function and edit it
but at the same time, if i wanted to add a new role and some permissions to it, i'd do that easily from a dashboard or something
however if I go with a middleware approach
i'd just say
public function handle($request, Closure $next)
{
if ($request->user() && $request->user()->type != 'admin')
{
return new Response(view('unauthorized');
}
return $next($request);
}
and assign that middleware on some route
which is easier, but not can't be set from a dashboard
so that was confusing me and i thought of asking for some opinions and maybe some tips
Started a new Conversation Which Is Better, Spatie Permissions & Roles Or Using Middlewares Or Policies?
Hello, am trying to make something like Udemy as practice after finishing some courses here on Laracasts
I'm trying to fix a problem where I want to allow users who purchased a course to view it, if not, they get 401
I was thinking of two approaches, either using Policies combined with Roles and permissions
like saying
if user can view any course, then respond to him with the courses videos
else, check if user has this course in his purchased courses, then send him the course videos
else, unauthorized
that was the the Policies + roles & permissions approach
but i read that u can do so with Middlewares and it seemed easier to do it with middlewares from this article
https://justlaravel.com/middleware-laravel-content-restriction-user-role/
so i was wondering if someone could explain to me which is better and more scalable in the future
thanks a lot!
Started a new Conversation How To Handle Authorization If You Have Many To Many Based Roles And Permissions
I wanted to make roles and permissions to be as dynamic as possible, here is what I made on Diagram.io
https://drive.google.com/file/d/1NNyFpZZLiIhQwFgVnX26dgm-v7Ar8Th_/view?usp=sharing
however I was wondering how would I handle if user is authorized to do some action in Laravel
Commented on Model Tests
If anyone is using Laravel 8 and faced a problem with the Unit test where it doesn't understand what is $this->faker->sentence
change this line in the Unit test file
from: use PHPUnit\Framework\TestCase;
to: use Tests\TestCase;
Replied to From IOS Development To Backend
@app_dev thanks a lot, I just found out there was a tab on Laracasts called Journey with steps of how to learn more, I skimmed through PHP and OOP since I already know both, and currently am learning building birdboard through TDD, only skipping front end part and replacing it with Restful APIs
Replied to From IOS Development To Backend
@app_dev thank u for replying, What i meant is am not interested in building the website's frontend, I meant that am only interested in building Restful APIs so i don't want to waste time building UI, so am looking for topics that explains just that
Started a new Conversation From IOS Development To Backend
Hello, I'm an iOS Developer with 3 years of experience, I wanted to shift to backend and build only restful apps without doing any HTML nor CSS as I would prefer my front end to be building the iOS apps and not websites
So I was wondering which topics should I see on Laracasts, thanks :))