Member Since 9 Months Ago
4,000 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 Are These The Correct Model Relationships And Table Structures?
As part of another task/relationship for this yes, but even without that felt this was necessary so that the same Travel Route could be associated with more than one Employee. It's also not an option to include the route_id in the employee's table either
Started a new Conversation Are These The Correct Model Relationships And Table Structures?
Just want to sense check what I'm using for this scenario and get some feed back.
An employee with a role of delivery driver only ever has one travel route but a travel route can have multiple delivery drivers.
I have an employees, routes and employee_routes table. An Employee belongs to one EmployeeRoute, many Routes belongs to many EmployeeRoute.
My Model relationships looks like:
Employee.php
public function employeeRoute()
{
return $this->hasOne(Route::class);
}
Route.php
public function employeeRoutes()
{
return $this->hasMany(EmployeeRoutes::class);
}
EmployeeRoute.php
public function employee()
{
return $this->belongsTo(employee::class);
}
public function routes()
{
return $this->belongsTo(Route::class);
}
Does this look right to you?
Replied to Creating And Consuming An API Service Within Laravel
I appreciate the info and insight - thank you. Inertia certainly seems to deal with the upside of why we would use an SPA/API driven microservice approach without the overhead and is quite blatant about the fact that it is monolithic - I like that. The demo app "PingCRM" really shows it off nicely and is exactly the kind of thing I'm interested in.
For a while, I got stuck into a way of thinking that put me off of building anything that wasn't API driven or didn't use a microservice architecture and quickly realized how thinly I would be spread as a soloist developer for my development endeavours.
Unless we're talking about building a unique platform like Twitter, Stackoverflow, etc that needs to scale vertically instead of horizontally, where like you say, there are those dedicated teams and abundant resources for individual aspects of development I realized it added a lot more depth to the things I just didn't (and still don't fully) know i.e. the added complexities of authorization, storage, AWS/Azure integration, etc.
I'll checkout Livewire and noticed that this and Intertia ships with Laravel 8 - something I haven't yet really exposed myself to as I'm still working with Laravel 6. The reason for this is that it's the most up to date LTS release and where I work, unless a 3rd party framework has an LTS version, we won't use it in a production environment and thought that was a good quality standard to follow for myself.
All the best Rodrigo
Replied to Creating And Consuming An API Service Within Laravel
@rodrigo.pedra Thank you Rodrigo - Inertia seems to fit alot of what I've described there so will be investigating it in detail. Thanks for the reply
Started a new Conversation Creating And Consuming An API Service Within Laravel
I would like to make an application I'm working on API driven and I understand that I could create this as a RESTful API service and then create a separate SPA to consume it. But what if I wanted to make this in a monolithic way where I used a mixture of Vue components, HTML, and blade templates for the views, etc within a single Laravel application?
Rather than follow what I guess is the traditional way i.e. create routes in web.php, reference the endpoints of those routes to a method in a respective controller, etc but what I'm trying to get my head around is how I could do this with the api.php routes and endpoints where I would just be serving responses that would contain JSON data, etc and how could I then implement these to use views as well?
Would I use api.php routes for the JSON response data and web.php routes for defining what views are returned? If so, how? Or, as this is all meant to be contained within a single Laravel application, just stick to using web.php?
Replied to How Do I Give An <option> Element A Selected Attribute In VueJS?
@nakov the value on the option is there
Started a new Conversation How Do I Give An <option> Element A Selected Attribute In VueJS?
<select class="form-control" v-bind:class="{ 'is-invalid' : errors.category_id }" v-model="product.category_id">
<option v-for="category in categories" :selected="category.id ? true : false" :value="category.id">{{ category.name }}</option>
</select>
I've tried :selected="product.category_id == category.id ? true : false "
and have done alot of searching but can't find anything to answer what I thought would be a simple problem
Started a new Conversation How Do I Stop A User From Accessing My Laravel API Like A Normal Website?
I'm trying to create a microservice driven, hello-world app that uses Laravel as the backend (api) and VueJS for the front end to consume it. I'm unsure of how I would even deploy this yet but one thing I've picked up on is that while Laravel serves as the backend and I can interact with it through the frontend, if a user goes to the host of the Laravel app, they can still register, login and click on the default splash page from a fresh install, etc...How would I stop that from happening so that only the frontend (which is on a different host/port) is what a user can access?
Replied to How Do I Get My Custom, Local Laravel Package Into The Vendor Directory?
@automica so if I was to update the package in my package directory and run the composer command again, this would also be updated in the vendor directory?
Replied to How Do I Get My Custom, Local Laravel Package Into The Vendor Directory?
Laughably, I thought about doing that but just assumed omitting it would be the same thing. That'll teach me! Thank you.
Started a new Conversation How Do I Get My Custom, Local Laravel Package Into The Vendor Directory?
Of course, I could just mv
it there but I am wondering if from my root directory where I have ./packages/my-name/my-package
if it can be placed there (not just a symlink) when I run composer require
? In the same way that packages from packagist are placed in the vendor directory, how can my custom, local packages end up there (the actual directories and files rather than just the symlink) when I run composer require
?
As strange as this sounds, I'd ideally have duplicates i.e. package 1 in my root/packages directory and the same again in my vendor directory which is what the app will use.
Replied to How Do I Dockerise This Cloned Laravel App?
@martinbean Interesting because where I work we have our docker folders outside of our app directories. For example, the laravel app would be in a directory named quickstart-intermediate and the docker setup would be in an adjacent directory called quickstart-intermediate-docker, and for the purpose of learning tried to recreate this.
Replied to How Do I Dockerise This Cloned Laravel App?
@martinbean could I include a move/copy command to transfer it to quickstart-intermediate-docker first?
Replied to How Do I Dockerise This Cloned Laravel App?
@martinbean Thanks for your reply - I've tried this and can't get it working. I have two directories, one called quickstart-intermediate the other called quickstart-intermediate-docker.
quickstart-intermediate-docker contains my docker-compose.yml file and Dockerfile and is where I called docker-compose up -d
from where I also reference the volumes for the file and dirs of quickstart-intermediate. So I'm struggling to get it to reference the composer.json and composer.lock files in quickstart-intermediate from there and keep getting copy failed: forbidden path outside the build context
Started a new Conversation How Do I Dockerise This Cloned Laravel App?
I know this is more to with Docker than Laravel but this question is specific to Laravel as I need to run composer update
to install the vendor dependencies of the quickstart-intermediate demo app provided by Laravel.
my docker-compose.yml file:
version: '3'
networks:
laravel:
services:
nginx:
image: nginx:stable-alpine
container_name: nginx
ports:
- "8088:80"
volumes:
- ../quickstart-intermediate:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
- mysql
networks:
- laravel
mysql:
image: mysql:5.7.22
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "4306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: root
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- laravel
php:
build:
context: .
dockerfile: Dockerfile
container_name: php
volumes:
- ../quickstart-intermediate:/var/www/html
ports:
- "9000:9000"
networks:
- laravel
my Dockerfile:
FROM php:7.2-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql
I can get it working by manually executing composer update
in the project directory as I also have composer installed globally but don't know how I could do this with Docker alone. I've done plenty of searching and will continue to but can't find anything that answers this issue.