Skip to content

Commit

Permalink
feat: implement traits on models and resources and final adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
eng-gabrielscardoso committed Jun 30, 2024
1 parent 111866b commit 6c50475
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 15 deletions.
11 changes: 9 additions & 2 deletions app/Filament/Resources/EducationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Filament\Resources;

use App\Filament\Resources\EducationResource\Pages;
use App\Support\UsesMonthYearDates;
use App\Models\Education;
use Filament\Forms;
use Filament\Forms\Form;
Expand All @@ -14,6 +15,8 @@

class EducationResource extends Resource
{
use UsesMonthYearDates;

protected static ?string $model = Education::class;

protected static ?string $navigationIcon = 'heroicon-o-academic-cap';
Expand Down Expand Up @@ -44,8 +47,12 @@ public static function form(Form $form): Form
->maxLength(1000)
->columnSpanFull(),
Forms\Components\DatePicker::make('start_date')
->required(),
Forms\Components\DatePicker::make('end_date'),
->required()
->native(false)
->displayFormat('m/Y'),
Forms\Components\DatePicker::make('end_date')
->native(false)
->displayFormat('m/Y'),
]);
}

Expand Down
11 changes: 9 additions & 2 deletions app/Filament/Resources/ExperienceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Enums\EmploymentType;
use App\Filament\Resources\ExperienceResource\Pages;
use App\Support\UsesMonthYearDates;
use App\Models\Experience;
use Filament\Forms;
use Filament\Forms\Form;
Expand All @@ -15,6 +16,8 @@

class ExperienceResource extends Resource
{
use UsesMonthYearDates;

protected static ?string $model = Experience::class;

protected static ?string $navigationIcon = 'heroicon-o-briefcase';
Expand Down Expand Up @@ -45,8 +48,12 @@ public static function form(Form $form): Form
->maxLength(1024)
->columnSpanFull(),
Forms\Components\DatePicker::make('start_date')
->required(),
Forms\Components\DatePicker::make('end_date'),
->required()
->native(false)
->displayFormat('m/Y'),
Forms\Components\DatePicker::make('end_date')
->native(false)
->displayFormat('m/Y'),
]);
}

Expand Down
11 changes: 9 additions & 2 deletions app/Filament/Resources/ProjectResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Filament\Resources;

use App\Filament\Resources\ProjectResource\Pages;
use App\Support\UsesMonthYearDates;
use App\Models\Project;
use Filament\Forms;
use Filament\Forms\Form;
Expand All @@ -17,6 +18,8 @@

class ProjectResource extends Resource
{
use UsesMonthYearDates;

protected static ?string $model = Project::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
Expand Down Expand Up @@ -44,8 +47,12 @@ public static function form(Form $form): Form
->maxLength(1024)
->columnSpanFull(),
Forms\Components\DatePicker::make('start_date')
->required(),
Forms\Components\DatePicker::make('end_date'),
->required()
->native(false)
->displayFormat('m/Y'),
Forms\Components\DatePicker::make('end_date')
->native(false)
->displayFormat('m/Y'),
Forms\Components\FileUpload::make('image')
->required()
->directory('projects')
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Education.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace App\Models;

use App\Support\HasMonthYearDates;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Education extends Model
{
use HasFactory, SoftDeletes;
use HasFactory, HasMonthYearDates, SoftDeletes;

/**
* The attributes that are mass assignable.
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Experience.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace App\Models;

use App\Enums\EmploymentType;
use App\Support\HasMonthYearDates;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Experience extends Model
{
use HasFactory, SoftDeletes;
use HasFactory, HasMonthYearDates, SoftDeletes;

/**
* The attributes that are mass assignable.
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace App\Models;

use App\Support\HasMonthYearDates;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Project extends Model
{
use HasFactory, SoftDeletes;
use HasFactory, HasMonthYearDates, SoftDeletes;

/**
* The attributes that are mass assignable.
Expand Down
1 change: 1 addition & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"files": [
"app/helpers.php"
]
},
"scripts": {
"post-autoload-dump": [
Expand Down Expand Up @@ -82,4 +85,4 @@
"minimum-stability": "stable",
"prefer-stable": true,
"version": "0.0.1"
}
}
5 changes: 4 additions & 1 deletion resources/views/components/home/educations.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
<div class="card-body h-80 md:h-64">
<strong class="card-title">{{ $education->course }}</strong>
<i>{{ $education->degree }}</i>
<span><b class="text-accent">{{ $education->school }}</b> | {{ $education->start_date }} to {{ $education->end_date ?? 'Present' }}</span>
<span>
<b class="text-accent">{{ $education->school }}</b> | {{ $education->start_date->format('M Y') }} to
{{ $education->end_date ? $education->end_date->format('M Y') : 'Present' }}
</span>
<br>
<p class="overflow-y-scroll">{{ $education->description }}</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/home/experiences.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="card-body h-80 md:h-64">
<strong class="card-title">{{ $experience->title }}</strong>
<i>{{ $experience->company }}</i>
<span><b class="text-accent">{!! $experience->employment_type->getLabel() !!}</b> | {{ $experience->start_date }} to {{ $experience->end_date ?? 'Present' }}</span>
<span><b class="text-accent">{!! $experience->employment_type->getLabel() !!}</b> | {{ $experience->start_date->format('M Y') }} to {{ $experience->end_date ? $experience->end_date->format('M Y') : 'Present' }}</span>
<br>
<p class="overflow-y-scroll">{{ $experience->description }}</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/home/headline.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="relative px-4 h-full min-h-screen w-full flex items-center justify-center bg-home-hero bg-cover bg-center">
<article class="prose lg:prose-xl text-center">
<div class="avatar">
<figure class="w-60 h-60 relative rounded-full ring ring-primary ring-offset-base-100 ring-offset-2 rounded-full">
<figure class="w-60 h-60 relative rounded-full ring ring-primary ring-offset-base-100 ring-offset-2">
<span class="absolute top-0 right-16 w-4 h-4 rounded-full bg-success animate-pulse"></span>
<img src="https://pt.gravatar.com/userimage/199484219/012c5298d952c34d6699a3d280e3a4f3.png?size=350" class="rounded-full" />
</figure>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/projects.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class="p-4 h-full min-h-screen w-full flex flex-col items-center justify-center
<article class="prose lg:prose-xl text-center">
<div class="avatar">
<figure
class="w-60 h-60 relative rounded-full ring ring-primary ring-offset-base-100 ring-offset-2 rounded-full">
class="w-60 h-60 relative rounded-full ring ring-primary ring-offset-base-100 ring-offset-2">
<span class="absolute top-0 right-16 w-4 h-4 rounded-full bg-success animate-pulse"></span>
<img src="https://pt.gravatar.com/userimage/199484219/012c5298d952c34d6699a3d280e3a4f3.png?size=350"
class="rounded-full" />
Expand Down

0 comments on commit 6c50475

Please sign in to comment.