Skip to content

Instantly share code, notes, and snippets.

View vineeth030's full-sized avatar

Vineeth Vijayan vineeth030

  • BEO
  • Kochi
View GitHub Profile
- Paying attention to consistency when naming things:
- Classes
- Methods
- Variables
- Routes
- Preventing spelling mistakes
- Preventing unsafe code
- Type hint method parameters
- Always include user input validation
- Add exception and error handling
<?php
public function boot()
{
Nova::serving(function () {
Post::observe(PostObserver::class);
});
}
<?php
/**
* Handle the post "creating" event.
*
* @param \App\Post $post
* @return void
*/
public function creating(Post $post)
{
<?php
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Name'),
Text::make('Description'),
Tags::make('tags')
// I need an author_id field here.
@vineeth030
vineeth030 / custom_confirm_dialog_laravel_nova.vue
Last active July 5, 2020 09:10
The custom confirm dialog modal for Laravel Nova Tools
/* CustomModal.vue */
<template>
<modal tabindex="-1" role="dialog" @modal-close="handleClose">
<form @keydown="handleKeydown" @submit.prevent.stop="handleConfirm" class="bg-white rounded-lg shadow-lg overflow-hidden w-action">
<div>
<heading :level="2" class="border-b border-40 py-8 px-8">Confirm action</heading>
<p class="text-80 px-8 my-8"> Are you sure you want to perform this action? </p>
</div>
<div class="bg-30 px-6 py-3 flex">
<?php
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
"require": {
"php": "^7.2.5",
"fideloper/proxy": "^4.2",
"laravel/framework": "^7.0",
"laravel/nova": "*"
},
"repositories": [
{
"type": "path",
"url": "./nova"
}
],
@vineeth030
vineeth030 / dschool.php
Created May 16, 2020 16:05
Dependency Injection example
class Student {
private $studentName;
public __construct($studentName){
$this->studentName = $studentName;
}
}
class School {
private $student;
private $schoolName;
@vineeth030
vineeth030 / school.php
Last active May 16, 2020 16:02
Tightly coupled class example
class Student {
private $studentName;
public __construct($studentName){
$this->studentName = $studentName;
}
}
class School {
private $student;