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 #15 from salis77/develop
Browse files Browse the repository at this point in the history
notification completed,events image upload,some bugs fixed & ...
  • Loading branch information
alisalmabadi authored Aug 6, 2019
2 parents 046910e + b784658 commit 331eed4
Show file tree
Hide file tree
Showing 30 changed files with 21,803 additions and 21,061 deletions.
4 changes: 2 additions & 2 deletions app/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Event extends Model
{
protected $fillable = [
'name','description','long_description','start_date','end_date','end_date_signup','price','capacity','event_subject_id','event_type_id','event_status_id','province_id','city_id','address','address_point','eventable_id','center_core_id','information','eventable_type'
'name','description','long_description','start_date','end_date','end_date_signup','price','capacity','event_subject_id','event_type_id','event_status_id','province_id','city_id','address','address_point','eventable_id','center_core_id','information','eventable_type','thumbnail_id'
];

protected $table = 'events';
Expand Down Expand Up @@ -59,7 +59,7 @@ public function getFulledCapacityAttribute()

$event_user_count=EventUser::where('event_id',$this->id)->count();
$fulled_count=(int)$this->capacity-(int)$event_user_count;
return $fulled_count;
return (int)$fulled_count;
}

public function images()
Expand Down
75 changes: 52 additions & 23 deletions app/Http/Controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace App\Http\Controllers;

use App\Notifications\NotifySignedUpEvent;
use App\Notifications\SignedUpEvent;
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Event;
use App\EventSubject;
Expand Down Expand Up @@ -116,15 +119,16 @@ public function store(Request $request)
$admin = \Auth::guard('admin')->user();
$request['eventable_id'] = $admin->id;
$request['eventable_type'] = 'admin';
$address_point=[$request->xplace,$request->yplace];
$address_point=json_encode($address_point);

$event=Event::create($request->except(['information','address_point']));
$event->update(['address_point'=>$address_point]);
if($request->xplace != null) {
$address_point = [$request->xplace, $request->yplace];
$address_point = json_encode($address_point);
$event->update(['address_point' => $address_point]);
}
$event=$admin->events()->save($event);

/*image upload*/
foreach ($request->image as $image) {
foreach ($request->image as $key=>$image) {
$imagename = time() . '-' . sha1(time() . "_" . rand(21321, 465465465456)).'.'. $image->getClientOriginalExtension();
$main_folder = 'images/events/';
$url = $main_folder;
Expand All @@ -138,6 +142,10 @@ public function store(Request $request)
'image_path' => $url . $imagename,
'thumbnail_path'=>$img->basename,
]);

if($key==0){
$event->update(['thumbnail_id'=>$images->id]);
}
/***thumbnail ***/
$event->images()->attach($images->id);

Expand Down Expand Up @@ -219,7 +227,7 @@ public function update(Request $request, Event $event)
'center_core_id'=>'required|numeric',
'xplace'=>'nullable|numeric',
'yplace'=>'nullable|numeric',
'image'=>'nullable|image|mimes:png,jpg,jpeg|max:10000000000',
/* 'image'=>'nullable|image|mimes:png,jpg,jpeg|max:10000000000',*/

],[
'name.required'=>'لطفا نام را وارد کنید',
Expand Down Expand Up @@ -254,19 +262,21 @@ public function update(Request $request, Event $event)
'address.max'=>'تعداد کاراکتر وارد شده بیش از حد مجاز است',
'xplace.numeric'=>'لطفا به صورت عددی وارد کنید',
'yplace.numeric'=>'لطفا به صورت عددی وارد کنید',
'image.image'=>'لطفا فقط عکس انتخاب کنید',
'image.mimes'=>'نوع فایل انتخاب شده مناسب نمی باشد',
/* 'image.image'=>'لطفا فقط عکس انتخاب کنید',
'image.mimes'=>'نوع فایل انتخاب شده مناسب نمی باشد',*/
]);



$event->update($request->except(['information','address_point']));
$address_point=[$request->xplace,$request->yplace];
$address_point=json_encode($address_point);
$event->update(['address_point'=>$address_point]);
if($request->xplace != null) {
$address_point = [$request->xplace, $request->yplace];
$address_point = json_encode($address_point);
$event->update(['address_point' => $address_point]);
}

if(!empty($request['image'])){
foreach ($request->image as $image) {
foreach ($request->image as $key=>$image) {
$imagename = time() . '-' . sha1(time() . "_" . rand(21321, 465465465456)).'.'. $image->getClientOriginalExtension();
$main_folder = 'images/events/';
$url = $main_folder;
Expand All @@ -280,8 +290,13 @@ public function update(Request $request, Event $event)
'image_path' => $url . $imagename,
'thumbnail_path'=>$img->basename,
]);
if($key==0){
$event->update(['thumbnail_id'=>$images->id]);
}
$event->images()->attach($images->id);
}


}

flashs('تغییرات با موفقیت اعمال گردید');
Expand All @@ -301,17 +316,9 @@ public function destroy($id)

public function delete(event $event)
{
if(!empty($event)){
if($event->operator_user_id == \Auth::guard('admin')->user()->id){
//Delete the event
Event::destroy($event->id);
}
else{
flashs('شما قادر به حذف این رویداد نمی باشید');
return redirect()->route('admin.event.index');
}
}

//Delete the event
Event::destroy($event->id);
flashs('رویداد حذف گردید');
return redirect()->route('admin.event.index');
}
Expand Down Expand Up @@ -341,9 +348,19 @@ public function showAllEvents(Request $request)
public function getDetails(Request $request)
{
$event = Event::find($request['event_id']);
$event->load('images');
$user = \Auth::guard('web')->user();
$event->subject = $event->event_subject->name;
$event->type = $event->event_type->name;
$event->province = $event->provinces->name;
$event->city = $event->cities->name;
$event->fulled =$event->fulled_capacity;

$event->start =$event->start_dates;
$event->end =$event->end_dates;

$event->ended =$event->fulled_capacity;

/***check kone ke in rooydad ghablan entekhab shode ya na***/
foreach($user->events as $u_event){
if($u_event->id == $event->id){
Expand All @@ -354,7 +371,7 @@ public function getDetails(Request $request)
}

//leaflet points
if(!empty($event->address_point)){
if($event->address_point != null){
$event->address_point = json_decode($event->address_point);
}
return response($event);
Expand Down Expand Up @@ -415,6 +432,11 @@ public function storeUser(Request $request)
'event_information'=>$event_information,
'status'=>1,
]);
$title = "رزرو ثبت نام شما در رویداد NAME انجام شد.";
$message = "'شما با موفقیت در رویداد NAME رزرو شدید،لطفا برای قطعی شدن ثبت نام،پرداخت را انجام دهید.'";
$type = 4;
$when = Carbon::now()->addSecond();
\Notification::send(\Auth::user(),(new NotifySignedUpEvent($event,$title,$message,$type))->delay($when));
return response($eventUser);
}

Expand Down Expand Up @@ -449,6 +471,13 @@ public function selectAll(Request $request)
'status'=>1,
]);
}
$title = "رزرو ثبت نام شما در رویداد NAME انجام شد.";
$message = "'شما با موفقیت در رویداد NAME رزرو شدید،لطفا برای قطعی شدن ثبت نام،پرداخت را انجام دهید.'";
$type = 4;
$event=Event::find($request['event_id']);
$when = Carbon::now()->addSecond();
\Notification::send($user,(new NotifySignedUpEvent($event,$title,$message,$type))->delay($when));

}
}
return redirect()->route('admin.event.addUser');
Expand Down
23 changes: 23 additions & 0 deletions app/Http/Controllers/NotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ public function get()

}

public function unreadget()
{
/* $notifications=\Auth::user()->notifications()->orderBy(DB::raw('read_at IS NOT NULL, read_at'), 'asc')->get();*/
$notifications=\Auth::user()->unreadnotifications()->orderby('created_at')->get()->toArray();


if(!empty($notifications)){
foreach($notifications as $notify){
$v=new Verta($notify['created_at']);
$res=$v->format('%d %B %Y');
$result[]=array_add($notify,'created',$res);
}
// dd($result);
return $result;
}
else{
return null;
}


}


public function read(Request $request)
{
$notification=Notification::find($request->id);
Expand Down
Loading

0 comments on commit 331eed4

Please sign in to comment.