Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
yrdevel committed Sep 8, 2022
1 parent a2b4007 commit 0985ba2
Show file tree
Hide file tree
Showing 23 changed files with 508 additions and 104 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
APP_NAME=Laravel
APP_NAME=Libgram
APP_DESCRIPTION="Meta title"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
Expand Down
75 changes: 11 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,11 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>

<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>

## About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).

Laravel is accessible, powerful, and provides tools required for large, robust applications.

## Learning Laravel

Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

## Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).

### Premium Partners

- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**

## Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).

## Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).

## Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.

## License

The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
## Install

```
git remote add origin git@github.com:Libgram/libgram.git
git pull
composer install
npm install
npm run build
php artisan migrate
php artisan db:seed
```
24 changes: 24 additions & 0 deletions app/Http/Controllers/Public/CategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Controllers\Public;

use App\Http\Controllers\Controller;
use App\Models\Category;
use Artesaos\SEOTools\Traits\SEOTools;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;

class CategoryController extends Controller
{

public function index(Category $category, string $subCategory = null)
{

if (!empty($subCategory)) {
$subCategory = $category->childCategories()->where(['slug' => $subCategory])->firstOrFail();
}

dd($category->toArray(), $subCategory->toArray());

}
}
13 changes: 13 additions & 0 deletions app/Http/Controllers/Public/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@
namespace App\Http\Controllers\Public;

use App\Http\Controllers\Controller;
use Artesaos\SEOTools\Traits\SEOTools;
use Illuminate\Http\Request;

class IndexController extends Controller
{

use SEOTools;

public function index()
{

$this->seo()->setTitle(__('meta.home_title'));
$this->seo()->setDescription(__('meta.home_description'));
$this->seo()->opengraph()->setUrl('http://current.url.com');
$this->seo()->opengraph()->addProperty('type', 'articles');
$this->seo()->twitter()->setSite('@LuizVinicius73');
$this->seo()->jsonLd()->setType('Article');

return view('public.index');
}

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

namespace App\Http\Controllers\Public;

use App\Http\Controllers\Controller;
use Artesaos\SEOTools\Traits\SEOTools;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;

class LanguageController extends Controller
{

public function change($lang): RedirectResponse
{

if (in_array($lang, config('app.locales'))) {
session()->put('locale', $lang);
\App::setLocale($lang);
}

return back();
}
}
24 changes: 13 additions & 11 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http;

use App\Http\Middleware\LanguageMiddleware;
use App\Http\Middleware\OnlyAdmins;
use Illuminate\Foundation\Http\Kernel as HttpKernel;

Expand Down Expand Up @@ -37,6 +38,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
LanguageMiddleware::class,
],

'api' => [
Expand All @@ -45,7 +47,7 @@ class Kernel extends HttpKernel
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],

'admin'=>[
'admin' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
Expand All @@ -68,16 +70,16 @@ class Kernel extends HttpKernel
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'admin'=>OnlyAdmins::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'admin' => OnlyAdmins::class,
];
}
27 changes: 27 additions & 0 deletions app/Http/Middleware/LanguageMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class LanguageMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{

if(session()->has('locale'))
app()->setLocale(session('locale'));
else
app()->setLocale(config('app.locale'));

return $next($request);
}
}
34 changes: 27 additions & 7 deletions app/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Translatable\HasTranslations;

/**
* App\Models\Category
*
* @property int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string $name
* @property int|null $category_id
* @property int $sort
* @property int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string $name
* @property int|null $category_id
* @property int $sort
* @method static Builder|Category newModelQuery()
* @method static Builder|Category newQuery()
* @method static Builder|Category query()
Expand All @@ -26,11 +27,30 @@
* @method static Builder|Category whereName($value)
* @method static Builder|Category whereUpdatedAt($value)
* @mixin \Eloquent
* @property mixed $meta_title
* @property mixed $meta_description
* @property string $slug
* @property string|null $icon
* @property-read \Illuminate\Database\Eloquent\Collection|Category[] $childCategories
* @property-read int|null $child_categories_count
* @property-read Category|null $parentCategory
* @method static \Database\Factories\CategoryFactory factory(...$parameters)
* @method static Builder|Category whereIcon($value)
* @method static Builder|Category whereMetaDescription($value)
* @method static Builder|Category whereMetaTitle($value)
* @method static Builder|Category whereSlug($value)
* @method static Builder|Category whereSort($value)
*/
class Category extends Model
{
use HasFactory;
use HasFactory, HasTranslations;

public array $translatable = ['name', 'meta_title', 'meta_description'];

public function getRouteKeyName(): string
{
return 'slug';
}

public function parentCategory(): BelongsTo
{
Expand Down
15 changes: 14 additions & 1 deletion app/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;

/**
* App\Models\Product
Expand Down Expand Up @@ -34,12 +35,24 @@
* @method static Builder|Product whereSlug($value)
* @method static Builder|Product whereUpdatedAt($value)
* @mixin \Eloquent
* @property mixed $meta_title
* @property mixed $meta_description
* @method static Builder|Product whereMetaDescription($value)
* @method static Builder|Product whereMetaTitle($value)
*/
class Product extends Model
{
use HasFactory;
use HasFactory, HasTranslations;

public array $translatable = ['name', 'meta_title', 'meta_description', 'short_description', 'description'];

protected $casts = [
'images'=>AsArrayObject::class,
];

public function getRouteKeyName(): string
{
return 'slug';
}

}
2 changes: 2 additions & 0 deletions app/Models/ProductCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* @method static Builder|ProductCategory whereProductId($value)
* @method static Builder|ProductCategory whereUpdatedAt($value)
* @mixin \Eloquent
* @property-read \App\Models\Category|null $category
* @property-read \App\Models\Product|null $product
*/
class ProductCategory extends Model
{
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
"require": {
"php": "^8.0.2",
"anhskohbo/no-captcha": "^3.4",
"artesaos/seotools": "^0.23.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.19",
"laravel/jetstream": "^2.11",
"laravel/sanctum": "^3.0",
"laravel/telescope": "^4.9",
"laravel/tinker": "^2.7",
"livewire/livewire": "^2.5",
"spatie/laravel-translatable": "^6.0"
"spatie/laravel-translatable": "^6.0",
"spatie/laravel-translation-loader": "^2.7"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.7",
Expand Down
Loading

0 comments on commit 0985ba2

Please sign in to comment.