Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #22 from salis77/develop
Browse files Browse the repository at this point in the history
merging changes in develop branch for about 2 month!
  • Loading branch information
alisalmabadi authored Aug 31, 2019
2 parents 331eed4 + 62798b1 commit bc39ed8
Show file tree
Hide file tree
Showing 97 changed files with 8,315 additions and 1,202 deletions.
52 changes: 52 additions & 0 deletions app/Article.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
public $created_atp;
protected $fillable=[
'article_category_id',
'order',
'title',
'body',
'seo_title',
'img',
'slug',
'seo_desc',
'img_thumbnail',
'category_id',
'user_id',
'product_id',
];
public function article_category()
{
return $this->belongsTo('App\ArticleCategory');
}

public function keywords()
{
return $this->belongsToMany('App\Keyword','article_keyword');
}
public function getRouteKeyName()
{
return 'slug';
}

public function user()
{
return $this->belongsTo('App\User');
}

public function getPersianDateAttribute()
{

$v=new \Verta($this->created_at);
return $v->format('%B %d، %Y');

}


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

namespace App;

use Illuminate\Database\Eloquent\Model;

class ArticleCategory extends Model
{
protected $table = "article_categories";
protected $fillable=['name','slug','img','desc'];
public function articles()
{
return $this->hasMany('App\Article');
}
}
13 changes: 12 additions & 1 deletion app/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ public function images()
}

public function users()
{
{//return users
return $this->belongsToMany(User::class , 'event_users');
}
public function event_users()
{//return event_users
return $this->hasmany(EventUser::class, 'event_id');
}

public function getEventUserIdAttribute(){
$user_id=\Auth::user()->id;
$event_user_id=EventUser::where(['user_id'=>$user_id,'event_id'=>$this->id])->first()->id;
Expand All @@ -81,4 +86,10 @@ public function getEventUserIdAttribute(){
public function eventable(){
return $this->morphto();
}

public function getNewEventUserAttribute()
{
$neweventuser = $this->event_users->where('status',1)->count();
return $neweventuser;
}
}
42 changes: 42 additions & 0 deletions app/Events/SignedUpUserEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Events;

use App\User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class SignedUpUserEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
private $user;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(User $user)
{
$this->user = $user;
}

public function getUser()
{
return $this->user;
}

/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
}
27 changes: 27 additions & 0 deletions app/Exports/UserExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Exports;

use App\User;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;

class UserExport implements FromView
{
/**
* @return \Illuminate\Support\Collection
*/
private $users;

public function __construct($users)
{
$this->users = $users;
}

public function view(): View
{
return view('exports.UserExport',[
'users'=>$this->users
]);
}
}
13 changes: 12 additions & 1 deletion app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace App\Http\Controllers;

use App\Article;
use App\Core;
use App\Event;
use App\EventUser;
use App\User;
use Illuminate\Http\Request;

class AdminController extends Controller
Expand All @@ -13,6 +18,12 @@ public function __construct()

public function index()
{
return view('admin.index');
$data = array();
$data['users_count']= User::all()->count();
$data['cores_count']= Core::all()->count();
$data['events_count']= Event::all()->count();
$data['events_registered_count']= EventUser::all()->count();
$data['articles'] = Article::all();
return view('admin.index',['data'=>$data]);
}
}
Loading

0 comments on commit bc39ed8

Please sign in to comment.