Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Course;
use App\Models\Social;
use App\Models\Company;
use App\Models\Experience;
use App\Models\Certification;
Expand All @@ -18,7 +19,8 @@ public function index()
{
$certifications = Certification::count();
$courses = Course::count();
return view('daniel', compact('certifications', 'courses'));
$socials = Social::all();
return view('daniel', compact('certifications', 'courses', 'socials'));
}

/**
Expand All @@ -32,7 +34,8 @@ public function dashboard()
$courses = Course::count();
$companies = Company::count();
$experiences = Experience::count();
return view('dashboard', compact('certifications', 'courses', 'companies', 'experiences'));
$socials = Social::count();
return view('dashboard', compact('certifications', 'courses', 'companies', 'experiences', 'socials'));
}

}
123 changes: 123 additions & 0 deletions app/Http/Controllers/SocialController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

namespace App\Http\Controllers;

use App\Models\Social;
use Illuminate\Http\Request;

class SocialController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$socials = Social::orderBy('created_at', 'desc')->paginate(10);
return view('social.index', compact('socials'));
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('social.create');
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validatedData = $request->validate([
'name' => [
'string',
'required',
],
'icon' => [
'string',
'required',
],
'link' => [
'url',
'required',
],
]);
Social::create($validatedData);
session()->flash('flash.banner', 'Created Social!');
session()->flash('flash.bannerStyle', 'success');
return redirect()->route('socials.index');
}

/**
* Display the specified resource.
*
* @param \App\Models\Social $social
* @return \Illuminate\Http\Response
*/
public function show(Social $social)
{
return view('social.show', compact('social'));
}

/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Social $social
* @return \Illuminate\Http\Response
*/
public function edit(Social $social)
{
return view('social.edit', compact('social'));
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Social $social
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Social $social)
{
$validatedData = $request->validate([
'name' => [
'string',
'required',
],
'icon' => [
'string',
'required',
],
'link' => [
'url',
'required',
],
]);
$social->update($validatedData);
session()->flash('flash.banner', 'Updated Social!');
session()->flash('flash.bannerStyle', 'success');
return redirect()->route('socials.index');
}

/**
* Remove the specified resource from storage.
*
* @param \App\Models\Social $social
* @return \Illuminate\Http\Response
*/
public function destroy(Social $social)
{
$social->delete();
session()->flash('flash.banner', 'Deleted Social!');
session()->flash('flash.bannerStyle', 'success');
return redirect()->route('socials.index');
}
}
18 changes: 18 additions & 0 deletions app/Models/Social.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Social extends Model
{
use SoftDeletes;

protected $fillable = [
'name',
'icon',
'link',
];
}
35 changes: 35 additions & 0 deletions database/migrations/2021_05_24_152844_create_socials_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSocialsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('socials', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('icon');
$table->string('link');
$table->softDeletes();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('socials');
}
}
20 changes: 2 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"tailwindcss": "^2.0.1"
},
"dependencies": {
"bootstrap": "^5.0.1",
"fontawesome-svg-loader": "^0.4.0"
"@fortawesome/fontawesome-free": "^5.15.3",
"bootstrap": "^5.0.1"
}
}
Loading