From a7929c0097a7bbc89c841962691577275a7b2afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Cort=C3=A9s?= Date: Mon, 14 Oct 2019 22:59:22 -0300 Subject: [PATCH] uff muchas cosas, agrege projecto y setup --- app/Http/Controllers/AdminController.php | 6 +++ app/Http/Controllers/SetupController.php | 51 +++++++++++++++++++ app/Project.php | 5 -- app/ProjectPhoto.php | 14 ----- app/Setup.php | 10 ++++ database/factories/ProjectsFactory.php | 13 +++++ database/factories/SetupFactory.php | 13 +++++ .../2019_06_22_034600_create_base_db.php | 3 +- database/seeds/DatabaseSeeder.php | 2 + database/seeds/ProjectTableSeeder.php | 11 ++++ database/seeds/SetupTableSeeder.php | 11 ++++ public/css/app.css | 4 +- public/js/admin.js | 26 ++-------- public/js/app.js | 24 +-------- resources/js/admin.js | 49 +++++++++++------- resources/js/app.js | 26 +++------- resources/sass/app.scss | 4 +- resources/views/admin/base.blade.php | 7 ++- resources/views/admin/now/create.blade.php | 6 +-- resources/views/admin/now/edit.blade.php | 8 +-- resources/views/admin/now/index.blade.php | 4 +- resources/views/admin/posts/create.blade.php | 10 ++-- resources/views/admin/posts/edit.blade.php | 8 +-- resources/views/admin/posts/index.blade.php | 4 +- .../views/admin/projects/create.blade.php | 8 +-- resources/views/admin/projects/edit.blade.php | 8 +-- .../views/admin/projects/index.blade.php | 4 +- resources/views/admin/setups/create.blade.php | 25 +++++++++ resources/views/admin/setups/edit.blade.php | 25 +++++++++ resources/views/admin/setups/index.blade.php | 36 +++++++++++++ resources/views/base.blade.php | 6 +-- resources/views/projects/index.blade.php | 3 +- resources/views/setup.blade.php | 5 -- resources/views/setups/index.blade.php | 16 ++++++ resources/views/setups/show.blade.php | 15 ++++++ routes/web.php | 11 ++++ 36 files changed, 334 insertions(+), 147 deletions(-) create mode 100644 app/Http/Controllers/SetupController.php delete mode 100644 app/ProjectPhoto.php create mode 100644 app/Setup.php create mode 100644 database/factories/ProjectsFactory.php create mode 100644 database/factories/SetupFactory.php create mode 100644 database/seeds/ProjectTableSeeder.php create mode 100644 database/seeds/SetupTableSeeder.php create mode 100644 resources/views/admin/setups/create.blade.php create mode 100644 resources/views/admin/setups/edit.blade.php create mode 100644 resources/views/admin/setups/index.blade.php delete mode 100644 resources/views/setup.blade.php create mode 100644 resources/views/setups/index.blade.php create mode 100644 resources/views/setups/show.blade.php diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 94bdad3..ad8e101 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Post; use App\Now; use App\Project; +use App\Setup; use Illuminate\Http\Request; class AdminController extends Controller @@ -28,4 +29,9 @@ class AdminController extends Controller { return view('admin.projects.index', ['projects' => Project::orderBy('created_at', 'desc')->get()]); } + + public function setups() + { + return view('admin.setups.index', ['setups' => Setup::orderBy('created_at', 'desc')->get()]); + } } diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php new file mode 100644 index 0000000..a8d751a --- /dev/null +++ b/app/Http/Controllers/SetupController.php @@ -0,0 +1,51 @@ +get(); + return view('setups.index', ['setups' => $setups] ); + } + + public function create() + { + return view('admin.setups.create'); + } + + public function save(Request $request) + { + $setup = new Setup(); + $setup->title = $request->title; + $setup->md = $request->md; + $setup->save(); + + return redirect()->route('admin.setup.index'); + } + + public function edit($id) + { + return view('admin.setups.edit', ['setup' => Setup::find($id)]); + } + + public function update(Request $request, $id) + { + $setup = Setup::find($id); + $setup->title = $request->title; + $setup->md = $request->md; + $setup->save(); + + return redirect()->route('admin.setup.index'); + } + + public function delete($id) + { + Setup::find($id)->delete(); + return redirect()->route('admin.setup.index'); + } +} diff --git a/app/Project.php b/app/Project.php index e2fff17..a627be8 100644 --- a/app/Project.php +++ b/app/Project.php @@ -7,9 +7,4 @@ use Illuminate\Database\Eloquent\Model; class Project extends Model { protected $table = 'projects'; - - public function photos() - { - return $this->hasMany('App\ProjectPhoto'); - } } diff --git a/app/ProjectPhoto.php b/app/ProjectPhoto.php deleted file mode 100644 index 3d8cbbe..0000000 --- a/app/ProjectPhoto.php +++ /dev/null @@ -1,14 +0,0 @@ -belongsTo('App\Project'); - } -} diff --git a/app/Setup.php b/app/Setup.php new file mode 100644 index 0000000..ef319a3 --- /dev/null +++ b/app/Setup.php @@ -0,0 +1,10 @@ +define(App\Project::class, function (Faker $faker) { + return [ + 'title' => $faker->words(5, true), + 'md' => $faker->paragraphs(10, true) + ]; +}); diff --git a/database/factories/SetupFactory.php b/database/factories/SetupFactory.php new file mode 100644 index 0000000..110fdce --- /dev/null +++ b/database/factories/SetupFactory.php @@ -0,0 +1,13 @@ +define(App\Setup::class, function (Faker $faker) { + return [ + 'title' => $faker->words(5, true), + 'md' => $faker->paragraphs(10, true) + ]; +}); diff --git a/database/migrations/2019_06_22_034600_create_base_db.php b/database/migrations/2019_06_22_034600_create_base_db.php index bee0bae..9a001c4 100644 --- a/database/migrations/2019_06_22_034600_create_base_db.php +++ b/database/migrations/2019_06_22_034600_create_base_db.php @@ -28,7 +28,7 @@ class CreateBaseDb extends Migration $table->timestamps(); }); - Schema::create('setup', function(Blueprint $table) { + Schema::create('setups', function(Blueprint $table) { $table->bigIncrements('id'); $table->string('title'); $table->longText('md'); @@ -41,5 +41,6 @@ class CreateBaseDb extends Migration Schema::dropIfExists('projects'); Schema::dropIfExists('now'); Schema::dropIfExists('posts'); + Schema::dropIfExists('setups'); } } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 1535fbc..e836001 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -8,5 +8,7 @@ class DatabaseSeeder extends Seeder { $this->call(PostTableSeeder::class); $this->call(NowTableSeeder::class); + $this->call(SetupTableSeeder::class); + $this->call(ProjectTableSeeder::class); } } diff --git a/database/seeds/ProjectTableSeeder.php b/database/seeds/ProjectTableSeeder.php new file mode 100644 index 0000000..d48d023 --- /dev/null +++ b/database/seeds/ProjectTableSeeder.php @@ -0,0 +1,11 @@ +create(); + } +} diff --git a/database/seeds/SetupTableSeeder.php b/database/seeds/SetupTableSeeder.php new file mode 100644 index 0000000..96cde2a --- /dev/null +++ b/database/seeds/SetupTableSeeder.php @@ -0,0 +1,11 @@ +create(); + } +} diff --git a/public/css/app.css b/public/css/app.css index 07f3a6f..deb9244 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -1610,11 +1610,11 @@ article { => Buttons & Links *******************************************************************************/ -.admin-link { +.special-link { color: #ee1155; } -.admin-link:hover { +.special-link:hover { color: #ee1155; border-bottom: 1px #ee1155 solid; background-color: transparent; diff --git a/public/js/admin.js b/public/js/admin.js index ae72ad7..87bc77d 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -93,27 +93,11 @@ /*! no static exports found */ /***/ (function(module, exports) { -switch (window.location.pathname) { - case "/admin": - document.getElementById("title-link").classList.add("pure-menu-highlight"); - break; - - case "/admin/posts": - document.getElementById("posts-link").classList.add("pure-menu-highlight"); - break; - - case "/admin/now": - document.getElementById("now-link").classList.add("pure-menu-highlight"); - break; - - case "/admin/projects": - document.getElementById("proyectos-link").classList.add("pure-menu-highlight"); - break; - - case "/admin/setup": - document.getElementById("setup-link").classList.add("pure-menu-highlight"); - break; -} +posts_edit_regexp = new RegExp("/admin/posts/\\d+/edit"); +now_edit_regexp = new RegExp("/admin/now/\\d+/edit"); +projects_edit_regexp = new RegExp("/admin/projects/\\d+/edit"); +setups_edit_regexp = new RegExp("/admin/setups/\\d+/edit"); +if (window.location.pathname === "/admin/posts" || window.location.pathname === "/admin/posts/create" || window.location.pathname.match(posts_edit_regexp)) document.getElementById("posts-link").classList.add("pure-menu-highlight");else if (window.location.pathname === "/admin/now" || window.location.pathname === "/admin/now/create" || window.location.pathname.match(now_edit_regexp)) document.getElementById("now-link").classList.add("pure-menu-highlight");else if (window.location.pathname === "/admin/projects" || window.location.pathname === "/admin/projects/create" || window.location.pathname.match(projects_edit_regexp)) document.getElementById("projects-link").classList.add("pure-menu-highlight");else if (window.location.pathname === "/admin/setups" || window.location.pathname === "/admin/setups/create" || window.location.pathname.match(setups_edit_regexp)) document.getElementById("setup-link").classList.add("pure-menu-highlight"); /***/ }), diff --git a/public/js/app.js b/public/js/app.js index b9ebf49..66ea5e1 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -94,29 +94,7 @@ /***/ (function(module, exports) { // Highlight links if in his page -switch (window.location.pathname) { - case "/": - document.getElementById("title-link").classList.add("pure-menu-highlight"); - break; - - case "/blog": - case "/blog/archive": - document.getElementById("blog-link").classList.add("pure-menu-highlight"); - break; - - case "/now": - document.getElementById("now-link").classList.add("pure-menu-highlight"); - break; - - case "/projects": - document.getElementById("proyectos-link").classList.add("pure-menu-highlight"); - break; - - case "/setup": - document.getElementById("setup-link").classList.add("pure-menu-highlight"); - break; -} // Makes all images clickeable - +if (window.location.pathname == "/blog" || window.location.pathname == "/blog.archive") document.getElementById("blog-link").classList.add("pure-menu-highlight");else if (window.location.pathname == "/now") document.getElementById("now-link").classList.add("pure-menu-highlight");else if (window.location.pathname == "/projects") document.getElementById("proyectos-link").classList.add("pure-menu-highlight");else if (window.location.pathname == "/setup") document.getElementById("setup-link").classList.add("pure-menu-highlight"); // Makes all images clickeable var images = document.getElementsByTagName("img"); diff --git a/resources/js/admin.js b/resources/js/admin.js index 3095923..30d5c17 100644 --- a/resources/js/admin.js +++ b/resources/js/admin.js @@ -1,17 +1,32 @@ -switch(window.location.pathname){ - case "/admin": - document.getElementById("title-link").classList.add("pure-menu-highlight"); - break; - case "/admin/posts": - document.getElementById("posts-link").classList.add("pure-menu-highlight"); - break; - case "/admin/now": - document.getElementById("now-link").classList.add("pure-menu-highlight"); - break; - case "/admin/projects": - document.getElementById("proyectos-link").classList.add("pure-menu-highlight"); - break; - case "/admin/setup": - document.getElementById("setup-link").classList.add("pure-menu-highlight"); - break; -} +posts_edit_regexp = new RegExp("/admin/posts/\\d+/edit"); +now_edit_regexp = new RegExp("/admin/now/\\d+/edit"); +projects_edit_regexp = new RegExp("/admin/projects/\\d+/edit"); +setups_edit_regexp = new RegExp("/admin/setups/\\d+/edit"); + +if( + window.location.pathname === "/admin/posts" || + window.location.pathname === "/admin/posts/create" || + window.location.pathname.match(posts_edit_regexp) +) + document.getElementById("posts-link").classList.add("pure-menu-highlight"); + +else if( + window.location.pathname === "/admin/now" || + window.location.pathname === "/admin/now/create" || + window.location.pathname.match(now_edit_regexp) +) + document.getElementById("now-link").classList.add("pure-menu-highlight"); + +else if( + window.location.pathname === "/admin/projects" || + window.location.pathname === "/admin/projects/create" || + window.location.pathname.match(projects_edit_regexp) +) + document.getElementById("projects-link").classList.add("pure-menu-highlight"); + +else if( + window.location.pathname === "/admin/setups" || + window.location.pathname === "/admin/setups/create" || + window.location.pathname.match(setups_edit_regexp) +) + document.getElementById("setup-link").classList.add("pure-menu-highlight"); diff --git a/resources/js/app.js b/resources/js/app.js index ca28cf9..1653b08 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,22 +1,12 @@ // Highlight links if in his page -switch(window.location.pathname){ - case "/": - document.getElementById("title-link").classList.add("pure-menu-highlight"); - break; - case "/blog": - case "/blog/archive": - document.getElementById("blog-link").classList.add("pure-menu-highlight"); - break; - case "/now": - document.getElementById("now-link").classList.add("pure-menu-highlight"); - break; - case "/projects": - document.getElementById("proyectos-link").classList.add("pure-menu-highlight"); - break; - case "/setup": - document.getElementById("setup-link").classList.add("pure-menu-highlight"); - break; -} +if(window.location.pathname == "/blog" || window.location.pathname == "/blog.archive") + document.getElementById("blog-link").classList.add("pure-menu-highlight"); +else if(window.location.pathname == "/now") + document.getElementById("now-link").classList.add("pure-menu-highlight"); +else if(window.location.pathname == "/projects") + document.getElementById("proyectos-link").classList.add("pure-menu-highlight"); +else if(window.location.pathname == "/setup") + document.getElementById("setup-link").classList.add("pure-menu-highlight"); // Makes all images clickeable var images = document.getElementsByTagName("img"); diff --git a/resources/sass/app.scss b/resources/sass/app.scss index 4318107..ff5ac84 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -129,11 +129,11 @@ article { => Buttons & Links *******************************************************************************/ -.admin-link { +.special-link { color: $admin-color; } -.admin-link:hover{ +.special-link:hover{ color: $admin-color; border-bottom: 1px $admin-color solid; background-color: transparent; diff --git a/resources/views/admin/base.blade.php b/resources/views/admin/base.blade.php index 611b52f..b6b81df 100644 --- a/resources/views/admin/base.blade.php +++ b/resources/views/admin/base.blade.php @@ -11,17 +11,16 @@ Admin
@yield('content')
- diff --git a/resources/views/admin/now/create.blade.php b/resources/views/admin/now/create.blade.php index 4eb9a11..dc6b55f 100644 --- a/resources/views/admin/now/create.blade.php +++ b/resources/views/admin/now/create.blade.php @@ -9,13 +9,13 @@ @csrf

Create Now

- Volver + Back - +
- +
diff --git a/resources/views/admin/now/edit.blade.php b/resources/views/admin/now/edit.blade.php index 6695b90..76251d4 100644 --- a/resources/views/admin/now/edit.blade.php +++ b/resources/views/admin/now/edit.blade.php @@ -8,14 +8,14 @@
@csrf
-

Editar Now

- Volver +

Edit Now

+ Back - +
- +
diff --git a/resources/views/admin/now/index.blade.php b/resources/views/admin/now/index.blade.php index 2cb7035..bb6e9e6 100644 --- a/resources/views/admin/now/index.blade.php +++ b/resources/views/admin/now/index.blade.php @@ -3,13 +3,13 @@ @section('content')

Now

- Create + Create Now
- + diff --git a/resources/views/admin/posts/create.blade.php b/resources/views/admin/posts/create.blade.php index 3ff5822..31bd2f5 100644 --- a/resources/views/admin/posts/create.blade.php +++ b/resources/views/admin/posts/create.blade.php @@ -8,17 +8,17 @@ @csrf
-

Create post

- Volver +

Create Post

+ Back - + - +
- +
diff --git a/resources/views/admin/posts/edit.blade.php b/resources/views/admin/posts/edit.blade.php index 36b9dcb..0e5f2a3 100644 --- a/resources/views/admin/posts/edit.blade.php +++ b/resources/views/admin/posts/edit.blade.php @@ -9,16 +9,16 @@ @csrf

Editar Post

- Volver + Back - + - +
- +
diff --git a/resources/views/admin/posts/index.blade.php b/resources/views/admin/posts/index.blade.php index 6098d78..d527a97 100644 --- a/resources/views/admin/posts/index.blade.php +++ b/resources/views/admin/posts/index.blade.php @@ -11,8 +11,8 @@ - - + + diff --git a/resources/views/admin/projects/create.blade.php b/resources/views/admin/projects/create.blade.php index ac3c746..7f0232d 100644 --- a/resources/views/admin/projects/create.blade.php +++ b/resources/views/admin/projects/create.blade.php @@ -9,16 +9,16 @@ @csrf

Add Project

- Volver + Back - + - +
- +
diff --git a/resources/views/admin/projects/edit.blade.php b/resources/views/admin/projects/edit.blade.php index 34be9bb..86248c8 100644 --- a/resources/views/admin/projects/edit.blade.php +++ b/resources/views/admin/projects/edit.blade.php @@ -9,16 +9,16 @@ @csrf

Edit Project

- Volver + Back - + - +
- +
diff --git a/resources/views/admin/projects/index.blade.php b/resources/views/admin/projects/index.blade.php index 57afdf9..652035f 100644 --- a/resources/views/admin/projects/index.blade.php +++ b/resources/views/admin/projects/index.blade.php @@ -14,8 +14,8 @@ - - + + diff --git a/resources/views/admin/setups/create.blade.php b/resources/views/admin/setups/create.blade.php new file mode 100644 index 0000000..db43670 --- /dev/null +++ b/resources/views/admin/setups/create.blade.php @@ -0,0 +1,25 @@ +@extends('admin.base') + +@section('title') +

Add Setup

+@endsection + +@section('content') + + @csrf +
+

Add Setup

+ Back + + + + + + + +
+ +
+
+ +@endsection diff --git a/resources/views/admin/setups/edit.blade.php b/resources/views/admin/setups/edit.blade.php new file mode 100644 index 0000000..61482be --- /dev/null +++ b/resources/views/admin/setups/edit.blade.php @@ -0,0 +1,25 @@ +@extends('admin.base') + +@section('title') +

Edit Setup

+@endsection + +@section('content') + + @csrf +
+

Edit Setup

+ Back + + + + + + + +
+ +
+
+ +@endsection diff --git a/resources/views/admin/setups/index.blade.php b/resources/views/admin/setups/index.blade.php new file mode 100644 index 0000000..ece5fe9 --- /dev/null +++ b/resources/views/admin/setups/index.blade.php @@ -0,0 +1,36 @@ +@extends('admin.base') + +@section('content') + +
+

Setups

+ Add Setup +
+ +
IdFechaDate
IdTituloFechaTitleDate
IdTituloFechaTitleDate
+ + + + + + + + + + @foreach($setups as $setup) + + + + + + + @endforeach + +
IdTitleDate
{{$setup->id}}{{ Str::limit($setup->title, 30, "...") }}{{$setup->created_at->format('Y-m-d')}} + Edit +
$setup->id]) }} method="post"> + @csrf + +
+
+@endsection diff --git a/resources/views/base.blade.php b/resources/views/base.blade.php index bf2fda7..35141f6 100644 --- a/resources/views/base.blade.php +++ b/resources/views/base.blade.php @@ -19,14 +19,14 @@ Now
  • - Proyectos + Projects
  • - Setup + Setups
  • @auth
  • - Admin + Admin
  • @endauth diff --git a/resources/views/projects/index.blade.php b/resources/views/projects/index.blade.php index cfc3277..47eb2d1 100644 --- a/resources/views/projects/index.blade.php +++ b/resources/views/projects/index.blade.php @@ -12,8 +12,7 @@ {!! $parse->text($project->md) !!} - - + @endforeach
    @endsection diff --git a/resources/views/setup.blade.php b/resources/views/setup.blade.php deleted file mode 100644 index 2c5bf39..0000000 --- a/resources/views/setup.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -@extends('base') - -@section('content') -

    Setup

    -@endsection diff --git a/resources/views/setups/index.blade.php b/resources/views/setups/index.blade.php new file mode 100644 index 0000000..d4c5cc4 --- /dev/null +++ b/resources/views/setups/index.blade.php @@ -0,0 +1,16 @@ +@extends('base') + +@php + $parse = new Parsedown(); +@endphp + +@section('content') + @foreach($setups as $setup) +
    +
    +

    {{$setup->title}}

    +
    + {!! $parse->text($setup->md) !!} +
    + @endforeach +@endsection diff --git a/resources/views/setups/show.blade.php b/resources/views/setups/show.blade.php new file mode 100644 index 0000000..b25c31f --- /dev/null +++ b/resources/views/setups/show.blade.php @@ -0,0 +1,15 @@ +@extends('base') + +@php + $parse = new Parsedown(); +@endphp + +@section('content') +
    +
    +

    {{$setup->title}}

    +
    + {!! $parse->text($setup->md) !!} +
    +
    +@endsection diff --git a/routes/web.php b/routes/web.php index 161a8ab..ab1ec73 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,6 +7,8 @@ Route::get('/now', 'NowController@index')->name('now.index'); Route::get('/projects', 'ProjectController@index')->name('project.index'); +Route::get('/setups', 'SetupController@index')->name('setups.index'); + Route::prefix('blog')->group(function() { Route::get('/', 'BlogController@index')->name('blog.index'); Route::get('archive', 'BlogController@archive')->name('blog.archive'); @@ -45,6 +47,15 @@ Route::middleware('auth')->group(function() { Route::post('{post}/edit', 'ProjectController@update')->name('admin.project.update'); Route::post('{post}/delete', 'ProjectController@delete')->name('admin.project.delete'); }); + + Route::prefix('setups')->group(function() { + Route::get('/', 'AdminController@setups')->name('admin.setup.index'); + Route::get('create', 'SetupController@create')->name('admin.setup.create'); + Route::post('create', 'SetupController@save')->name('admin.setup.save'); + Route::get('{setup}/edit', 'SetupController@edit')->name('admin.setup.edit'); + Route::post('{setup}/edit', 'SetupController@update')->name('admin.setup.update'); + Route::post('{setup}/delete', 'SetupController@delete')->name('admin.setup.delete'); + }); }); });