Skip to content

Commit

Permalink
Implementarea postarilor inceputa
Browse files Browse the repository at this point in the history
  • Loading branch information
brobert04 committed Jan 9, 2023
1 parent f452586 commit 1b65173
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 8 deletions.
11 changes: 11 additions & 0 deletions app/Models/Posts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Models;

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

class Posts extends Model
{
use HasFactory;
}
36 changes: 36 additions & 0 deletions database/factories/PostsFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Database\Factories;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Posts>
*/
class PostsFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
$title = $this->faker->sentence(3, $asText=true);
$slug = Str::slug($title, '-');
return [
'title'=>$title,
'slug'=>$slug,
'subtitle'=>$this->faker->sentence(3, true),
'content' => $this->faker->paragraph(rand(6,15), true),
'views' => rand(0, 10000),
'published_at' => $this->faker->randomElement(array(null, $this->faker->dateTimeBetween('-2 year', 'now'))),
'user_id' => User::all()->where('role','autor')->random(),
'meta_title' => $this->faker->words(rand(1,5), true),
'meta_description' => $this->faker->sentence(3, true),
'meta_keywords' => $this->faker->words(rand(1,8), true),
];
}
}
2 changes: 1 addition & 1 deletion database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function definition()
'phone' => fake()->e164PhoneNumber(),
'address' => fake()->city().', '.fake()->streetAddress().', '.fake()->country(),
'created_at' => fake()->dateTimeBetween('-2 year', 'now'),
'role' => fake()->randomElement(['editor', 'autor ']),
'role' => fake()->randomElement(['user', 'autor']),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default('editor')->nullable();
$table->string('role')->default('user')->nullable();
$table->string('profile_picture')->default('default.png')->nullable();
$table->string('phone')->nullable();
$table->string('address')->nullable();
Expand Down
43 changes: 43 additions & 0 deletions database/migrations/2023_01_09_205452_create_posts_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('slug');
$table->string('subtitle')->nullable();
$table->string('photo')->nullable();
$table->text('content')->nullable();
$table->integer('views')->default(0);
$table->boolean('publish')->default(1);
$table->timestamp('published_at')->nullable();
$table->bigInteger('user_id');
$table->string('meta_title')->nullable();
$table->string('meta_description')->nullable();
$table->string('meta_keywords')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('posts');
}
};
4 changes: 3 additions & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use App\Models\User;
use Illuminate\Database\Seeder;
use Database\Seeders\PostsSeeder;

class DatabaseSeeder extends Seeder
{
Expand All @@ -21,7 +22,8 @@ public function run()
// ]);
$this->call([
CategorySeeder::class,
// UserSeeder::class,
UserSeeder::class,
PostsSeeder::class,
]);
}
}
20 changes: 20 additions & 0 deletions database/seeders/PostsSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Database\Seeders;

use App\Models\Posts;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class PostsSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Posts::factory(70)->create();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/users/BercaruRobert_1673296393.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion resources/views/admin/category/categories.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
<th class="text-center">Vizualizări</th>
<th class="text-center">Fotografie</th>
<th class="text-center">Meta Description & Meta Keywords</th>
@can('author-rights')
<th class="text-center">Acțiuni</th>
@endcan
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -57,10 +59,11 @@
{{$c->meta_description}}
<br>
<span id="keywords" class="badge bg-primary">{{$c->meta_keywords}}</span>
@can('author-rights')
<td class="text-center">
<a href="{{route('categories.edit-form',
$c->id)}}" class="butoane text-success" title="Editează categorie"><i class="fa-solid fa-xl fa-pen-to-square"></i></a>
&nbsp;
@endcan
@can('author-rights')
<form id="delete-form-{{$c->id}}" action="{{route('categories.delete', $c->id)}}" method="post" style="display:inline-block;">
@csrf
Expand Down
2 changes: 1 addition & 1 deletion resources/views/frontend_views/partials/head.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<link rel="shortcut icon" href="{{asset('../frontend/assets/images/favicon.png')}}" />
<!-- inject:css -->
<link rel="stylesheet" href="{{asset('../frontend/assets/css/style.css')}}">
<!-- endinject -->

<!-- endinject -->
@yield('custom-css')
</head>
6 changes: 3 additions & 3 deletions resources/views/frontend_views/partials/navbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ class="navbar-nav d-lg-flex justify-content-between align-items-center"
@break
@endif
@endforeach

<li class="nav-item">
{{-- <a class="nav-link" href="#"><i class="mdi mdi-magnify"></i></a>--}}

<button id="search" class="nav-link" href="#" style="background-color:transparent; border: none;"><i class="mdi mdi-magnify"></i></button>
</li>
<li><input id="searchBar" type="text" class="form-control form-control-border" id="exampleInputBorder" placeholder="Caută..." hidden="true"></li>
</ul>
</div>
</div>
</nav>

7 changes: 7 additions & 0 deletions resources/views/frontend_views/partials/scripts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@
<!-- Custom js for this page-->
<script src="{{asset('../frontend/assets/js/demo.js')}}"></script>
<!-- End custom js for this page-->
<script>
let search = document.querySelector('#search')
let searchBar = document.querySelector('#searchBar')
search.addEventListener('click', function(){
searchBar.hidden = !searchBar.hidden
})
</script>
@yield('custom-js')

0 comments on commit 1b65173

Please sign in to comment.