1,360 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.
Started a new Conversation Validation Failed
I need to register users via API. The problem will do RegisterRequest just don't know why. The response comes in 404 Validation also fails when users log in ... it also returns 404 in postman as in the picture.
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\Products\ProductController;
use App\Http\Controllers\Categories\CategoryController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::resource('categories', CategoryController::class);
Route::resource('products', ProductController::class);
Route::group(['prefix' => 'auth'], function () {
Route::post('register', [RegisterController::class, 'action']);
Route::post('login', [LoginController::class, 'action']);
});
namespace App\Http\Controllers\Auth;
use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\RegisterRequest;
use App\Http\Resources\PrivateUserResource;
class RegisterController extends Controller
{
public function action(RegisterRequest $request)
{
$user = User::create($request->only('email', 'name', 'password'));
return new PrivateUserResource($user);
}
}
namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class RegisterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email|unique:users,email',
'name' => 'required',
'password' => 'required',
];
}
}
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class PrivateUserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'email' => $this->email,
'name' => $this->name,
];
}
}
Started a new Conversation RegisterRequest
I need to register users via API. The problem will do RegisterRequest just don't know why. The response comes in 404 Validation also fails when users log in ... it also returns 404 in postman as in the picture.
Route::group(['prefix' => 'auth'], function () {
Route::post('register', [RegisterController::class, 'action']);
});
namespace App\Http\Controllers\Auth;
use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\RegisterRequest;
use App\Http\Resources\PrivateUserResource;
class RegisterController extends Controller
{
public function action(RegisterRequest $request)
{
$user = User::create($request->only('email', 'name', 'password'));
return new PrivateUserResource($user);
}
}
namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class RegisterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email|unique:users,email',
'name' => 'required',
'password' => 'required',
];
}
}
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class PrivateUserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'email' => $this->email,
'name' => $this->name,
];
}
}
Replied to RegisterRequest
if is rules empty and the correct post request without key & value I get 500. It's SQL error General error: 1364 Field 'name' doesn't have a default value. But when I uncomment the rules respose is 404.
Replied to RegisterRequest
I have a registered user. As soon as I use registerRequest instead of Request it should start validating but instead it returns me 404 I don't get it ...
Replied to RegisterRequest
Thank you for your response. Yes url I have the correct api/auth/register
Started a new Conversation RegisterRequest
I need to register users via API. The problem will do RegisterRequest just don't know why. The response comes in 404
Route
Route::group(['prefix' => 'auth'], function () {
Route::post('register', [RegisterController::class, 'action']);
});
Controller
namespace App\Http\Controllers\Auth;
use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\RegisterRequest;
use App\Http\Resources\PrivateUserResource;
class RegisterController extends Controller
{
public function action(RegisterRequest $request)
{
$user = User::create($request->only('email', 'name', 'password'));
return new PrivateUserResource($user);
}
}
RegisterRequest
namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class RegisterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email|unique:users,email',
'name' => 'required',
'password' => 'required',
];
}
}
PrivateUserResource
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class PrivateUserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'email' => $this->email,
'name' => $this->name,
];
}
}
Replied to Nuxt.js Axios Call -> Laravel Api
Thanks for the reply but even that didn't help me. The state is still empty ...
Replied to Nuxt.js Axios Call -> Laravel Api
Well, when I call it like this outside of vuex, it's a pride response like I expect ... But why doesn't it work via vuex ???
methods:{
fetchSomeCategories(){
this.$axios.$get('categories').then(response => {
console.log(response.data)
}).catch(err => {
console.error(err.response.data)
})
}
},
mounted() {
this.fetchSomeCategories()
}
response...ok
[{…}]
0:
children: Array(1)
0: {name: "Two", slug: "two"}
length: 1
__proto__: Array(0)
name: "One"
slug: "one"
__proto__: Object
length: 1
__proto__: Array(0)
Started a new Conversation Nuxt.js Axios Call -> Laravel Api
Hi, could anyone help me? I can't connect to the backend of the application. I'm not getting any bugs just the store won't fill it with data. I checked the API via postman and there it's all ok the data is coming back with the app. I use Nuxt.js and the code I have the following ...
index.js
export const state = () => ({
categories: []
})
export const getters = {
categories(state) {
return state.categories
}
}
export const mutations = {
SET_CATEGORIES(state, categories) {
state.categories = categories
}
}
export const actions = {
async nuxtServerInit({ commit }) {
let response = await this.$axios.$get('categories')
commit('SET_CATEGORIES', response.data)
}
}
nuxt.config.js
export default {
// Disable server-side rendering (https://go.nuxtjs.dev/ssr-mode)
ssr: false,
// Global page headers (https://go.nuxtjs.dev/config-head)
head: {
title: 'shopclient',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS (https://go.nuxtjs.dev/config-css)
css: [
],
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
plugins: [
],
// Auto import components (https://go.nuxtjs.dev/config-components)
components: true,
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
buildModules: [
// https://go.nuxtjs.dev/tailwindcss
'@nuxtjs/tailwindcss',
],
// Modules (https://go.nuxtjs.dev/config-modules)
modules: [
'@nuxtjs/axios'
],
axios: {
baseURL: 'http://127.0.0.1:8000/api',
},
// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {
}
}
Replied to Page Navigation Gsap
Thanks for trying but I'm still unsuccessful. I'm going to keep trying
Replied to Page Navigation Gsap
Yes I tried, it didn't help I don't understand why it doesn't work on iPhones
Started a new Conversation Page Navigation Gsap
Hi, I'm doing navigation and using gsap. Everything is fine except for ios ... you don't know why? IOS / IPhone will automatically exit after clicking on that showButton. reverse. The console does not throw any err.
const showButton = document.querySelector('#navToggleShow');
const overlay = document.querySelector('.overlay__navigation');
const exit = document.querySelector('#exitBtn');
var tl = gsap.timeline({ defaults: { duration: 1, ease: "Back.easeOut.config(2)" }})
tl.paused(true);
tl.to(overlay, { clipPath: 'circle(100%)' })
tl.to(".menu__container", { opacity: 1, y: '30px', stagger: 0.1 }, "-=1")
showButton.addEventListener('click', () => {
tl.play();
})
exit.addEventListener('click', () => {
tl.reverse(.7);
})
The application is built on Laravel, so we use a webpack. THX
Started a new Conversation Add Products Images (NOVA ADMIN)
Hi, how can we best add images to products in the nova admin panel? Thank you
Started a new Conversation Advanced Nova Media Library
I'm trying to use the Advanced Nova Media Library package and I have a problem with registration.
I have created a Car and db model in which, among other things, I also register car_images where, with the help of the Nova Media Library, pictures for each car are to be stored.
When I paste the code below into my nova model I get this error: Call to undefined method App\Models\Car::getMedia()
use Spatie\MediaLibrary\Models\Media;
public function registerMediaConversions(Media $media = null)
{
$this->addMediaConversion('thumb')
->width(130)
->height(130);
}
public function registerMediaCollections()
{
$this->addMediaCollection('main')->singleFile();
$this->addMediaCollection('my_multi_collection');
}
/**
* Get the gallery fields for the resource.
*
* @return array
*/
protected function galleryFields()
{
return [
/* Files::make('Single file', 'one_file'), */
Files::make('Multiple files', 'car_images'),
];
}
Can anyone fix me what I'm doing?
Started a new Conversation Multiple Images Laravel Nova
I need to create an image gallery. I have a Car model I need to add a picture gallery to it. I would like to use Laravel Advanced Nova Media Library. How do I use this package? Well thank you. Mammodel Car where I need a gallery of pictures for a specific car. Should I register this packagev model nova or not? well thank you.
Started a new Conversation Generate PDF Invoice
Good day
Can you advise me on the best way to add another $ products variable to the function? I need the invoice blade then run through the foreach table of products. well thank you
class InvoiceController extends Controller
{
public function downloadPDF($id)
{
$order = Order::find($id);
$pdf = PDF::loadView('invoice', compact('order'));
return $pdf->download('invoice.pdf');
}
}
That's not how it works for me
class InvoiceController extends Controller
{
public function downloadPDF($id)
{
$order = Order::find($id);
$products = $order->products;
$pdf = PDF::loadView('invoice', compact('order', 'products'));
return $pdf->download('invoice.pdf');
}
}