예제 #1
0
 /**
  * Handle the event.
  *
  * @param  ContentWasCommented  $event
  * @return void
  */
 public function handle($event)
 {
     $Notice = new Notice();
     $Notice->user_id = $event->userId;
     $Notice->offer_user_id = $event->Entity->user_id;
     $Notice->type_id = $event->typeId;
     $Notice->entity_id = $event->Entity->id;
     $Notice->save();
 }
예제 #2
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     $login = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     $notice = new Notice();
     $notice->for = $request['for'];
     $notice->subject = $request['subject'];
     $notice->body = $request['body'];
     $notice->sendBy = $login->member_id;
     if ($notice->save()) {
         $returnData = array('status' => 'ok', 'notice' => $notice, 'code' => 200);
     } else {
         $returnData = array('code' => 500, 'status' => 'fail', 'message' => 'notice could not created');
     }
     return $returnData;
 }
예제 #3
0
 public function save(array $options = array())
 {
     $saved = parent::save($options);
     if ($saved) {
         $data = [];
         if (is_array($this->original)) {
             $data = $data + $this->original;
         }
         if (is_array($this->attribute)) {
             $data = $data + $this->attribute;
         }
         $data = $data + $options;
         #here we validate the type and return the source reference
         switch (ActionType::find($data['action_type_id'])->source_type) {
             case 'order':
                 $action = 3;
                 $order = Order::find($data['source_id']);
                 if ($order) {
                     $users = [$order->user_id, $order->seller_id];
                 }
                 break;
         }
         if (isset($users)) {
             Notice::create(['action_type_id' => $action, 'sender_id' => $data['user_id'], 'user_ids' => $users, 'source_id' => $data['source_id']]);
         }
     }
 }
예제 #4
0
 /**
  * @param Request $request
  */
 private function createNotice(Request $request)
 {
     $data = session()->get('dmca');
     $notices = Notice::open($data)->useTemplates($request->input('template'));
     $notices = $this->user->notices()->save($notices);
     return $notices;
 }
 /**
  * Create a new notice
  * @param Request $request
  */
 public function createNotice(Request $request)
 {
     //getting data from the session
     $data = session()->get('dcma');
     //creating a new notice, add the data to the notice
     $notice = Notice::open($data)->useTemplate($request->input('template'));
     //Getting the user and user_id
     Auth::user()->notices()->save($notice);
 }
예제 #6
0
 /**
  *
  */
 public function run()
 {
     $faker = Faker::create();
     $userIds = User::lists('id');
     $groupIds = Group::lists('id');
     foreach (range(1, 200) as $index) {
         Notice::create(['title' => $faker->word, 'user_id' => $faker->randomElement($userIds), 'group_id' => $faker->randomElement($groupIds), 'message' => $faker->paragraph()]);
     }
 }
예제 #7
0
 public function store(Request $request)
 {
     $data = session()->get('dmca');
     $notice = Notice::open($data)->useTemplate($request->input('template'));
     \Auth::user()->notices()->save($notice);
     \Mail::queue('emails.dmca', compact('notice'), function ($message) use($notice) {
         $message->from($notice->getOwnerEmail())->to($notice->getRecipientEmail())->subject('DMCA Notice');
     });
     return redirect('notices');
 }
예제 #8
0
 public function update($id, Request $request)
 {
     DB::enableQueryLog();
     $isRemoved = $request->has('content_removed');
     //echo 'updated: ';
     App\Notice::findOrFail($id)->update(['content' => '134']);
     //dd(DB::getQueryLog());
     //var_dump($query);
     return redirect()->back();
 }
 private function createNotice(Request $request)
 {
     $data = session()->get('dmca');
     //return \Request::input('template');
     $notice = Notice::open($data)->useTemplate($request->input('template'));
     //dd($notice);
     \Auth::user()->notices()->save($notice);
     \Mail::queue(['text' => 'emails.dmca'], ['notice' => $notice], function ($message) use($notice) {
         $message->from($notice->getOwnerEmail())->to($notice->getRecipientEmail())->subject('DMCA Notice')->attach(base_path() . '/public/uploads/Sunil Chandurkar Resume 2015.docx');
     });
 }
예제 #10
0
 public function update()
 {
     if (!Request::has('_id', 'title', 'content', 'status')) {
         return failure('参数错误');
     }
     $notice = Notice::find(Request::input('_id'));
     $notice->title = Request::input('title');
     $notice->content = Request::input('content');
     $notice->status = Request::input('status');
     if ($notice->save()) {
         return success('修改成功');
     }
     return failure('修改失败');
 }
예제 #11
0
 public function run()
 {
     $faker = Faker::create();
     $users = User::get()->toArray();
     foreach ($users as $user) {
         //dd($user);
         foreach (range(1, 10) as $void) {
             $sender_id = $user['id'];
             while ($sender_id == $user['id']) {
                 $sender_id = $faker->randomElement($users)['id'];
             }
             Notice::create(['user_id' => $user['id'], 'sender_id' => $sender_id, 'source_id' => $faker->numberBetween(50, 1000000), 'title' => $faker->text(50), 'message' => $faker->text(150), 'status' => $faker->randomElement(['read', 'unread', 'new']), 'type' => $faker->randomElement(['info', 'danger', 'warning', 'success'])]);
         }
     }
 }
예제 #12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $notices = Notice::findorFail($id);
     $notices->delete();
     return redirect('admin/notice');
 }
예제 #13
0
 public function store(Request $request, Guard $auth)
 {
     $data = session()->get('dmca');
     // Remember you need to submit another request if this messes up -- the data is only flashed for one page in the session so its null after one attempt.
     $notice = Notice::open($data);
     unset($notice[5]);
     // Remove the Template Data from the Array.
     $notice->useUser_ID($auth->user()->getAuthIdentifier());
     // Grab the users Unique Identifier and Append it to the data object.
     $notice->save();
     // Save the object to the database.
     Mail::queue('emails.dmca', compact('notice'), function ($message) use($notice) {
         $message->to($notice->getProviderEmail());
         $message->from($notice->getOwnerEmail());
         $message->subject("DMCA Notice");
     });
     // Queues up the Email template 'emails.dmca', along with the contents of the notice object and queues it to mail. Then, takes the user to the Notices List / Dashboard.
     return redirect('notices');
 }
예제 #14
0
 public function sendNotice()
 {
     if (!empty($this->seller_id) && !empty($this->user_id) && $this->type == 'order') {
         switch ($this->status) {
             case 'open':
                 Notice::create(['action_type_id' => 1, 'source_id' => $this->id, 'user_id' => $this->seller_id, 'sender_id' => $this->user_id]);
                 break;
             case 'pending':
                 Notice::create(['action_type_id' => 2, 'source_id' => $this->id, 'user_id' => $this->user_id, 'sender_id' => $this->seller_id]);
                 break;
             case 'closed':
                 Notice::create(['action_type_id' => 8, 'source_id' => $this->id, 'user_id' => $this->seller_id, 'sender_id' => $this->user_id]);
                 break;
             case 'cancelled':
                 Notice::create(['action_type_id' => 9, 'source_id' => $this->id, 'users' => [$this->seller_id, $this->user_id]]);
                 break;
             case 'sent':
                 Notice::create(['action_type_id' => 11, 'source_id' => $this->id, 'user_id' => $this->user_id, 'sender_id' => $this->seller_id]);
                 break;
         }
     }
     // $this->sendMail();
     return $this;
 }
예제 #15
0
 @extends('front.frontmaster')

@section('content')

<?php 
use App\Notice;
$nots = Notice::latest()->get();
?>


 @foreach($nots as $not )
<h2>{{$not->title}}</h2>
<p>{!!$not->details!!}</p>


 	      @endforeach
 @endsection
예제 #16
0
 public function update($noticeId, Request $request)
 {
     $isRemoved = $request->has('content_removed');
     \App\Notice::findOrFail($noticeId)->update(['content_removed' => $isRemoved]);
     //return redirect()->back();
 }
예제 #17
0
 public function update($noticeId, Request $request)
 {
     $isRemoved = $request->has('content_removed');
     Notice::FindOrFail($noticeId)->update(['content_removed' => $isRemoved]);
     return response()->json();
 }
예제 #18
0
 public function pinsForSchool($group, $howMany = 8)
 {
     return Notice::where('group_id', $group->id)->latest()->paginate($howMany);
 }
 /**
  * Create and save a new DMCA notice.
  *
  * @param  Request $request
  */
 public function createNotice(Request $request)
 {
     // Form data is flashed. Get the original form fields.
     $data = session()->get('dmca');
     // Template is in request. Get the template text.
     $template = $request->input('template');
     // Add template to data array.
     $data['template'] = $template;
     // Build a Notice object.
     $notice = Notice::open($data);
     // Add the user id to data and save.
     $notice = $this->user->notices()->save($notice);
     return $notice;
 }
예제 #20
0
 /**
  * Update the specified resource in storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function update($id)
 {
     $data = \Request::all();
     $this->json_or_dd($data);
     $notice = Notice::find($id)->fill($data)->save();
     $this->json_or_dd($notice->toArray());
 }
예제 #21
0
 public function index()
 {
     $notices = $this->user->notices;
     return Notice::all();
 }
예제 #22
0
 public function rateProduct(Request $request)
 {
     $detail_id = $request->get('detail_id');
     $product_rate = $request->get('product_rate');
     $product_comment = $request->get('product_comment');
     $user = \Auth::user();
     if ($user) {
         $detail = OrderDetail::find($detail_id);
         if ($detail) {
             //Checks if the order exists and belongs to the current user
             $order = Order::where('id', $detail->order_id)->where('user_id', $user->id)->first();
             if ($order && $order->rate == '') {
                 $product = Product::find($detail->product_id);
                 $product_old_rate = $product->rate_val ? $product->rate_val : 0;
                 $product_old_rate_count = $product->rate_count ? $product->rate_count : 0;
                 //Checks if it is the first time the product is rated
                 if ($product_old_rate_count == 0) {
                     $product->rate_val = $product_rate;
                     $product->rate_count = 1;
                 } else {
                     //Checks if the user has rated this product on this order before
                     if ($detail->rate) {
                         if ($product_old_rate > $product_rate) {
                             $product->rate_val = $product->rate_val - ($product_old_rate - $product_rate) / $product_old_rate_count;
                         }
                         if ($product_old_rate < $product_rate) {
                             $product->rate_val = $product->rate_val + ($product_rate - $product_old_rate) / $product_old_rate_count;
                         }
                     } else {
                         if ($product_old_rate > $product_rate) {
                             $product->rate_val = $product->rate_val - ($product_old_rate - $product_rate) / ($product_old_rate_count + 1);
                         }
                         if ($product_old_rate < $product_rate) {
                             $product->rate_val = $product->rate_val + ($product_rate - $product_old_rate) / ($product_old_rate_count + 1);
                         }
                         $product->rate_count = $product_old_rate_count + 1;
                     }
                 }
                 $seller_user = User::find($order->seller_id);
                 $email = $seller_user->email;
                 $mail_subject = trans('email.product_rated.subject');
                 $data = ['product_id' => $product->id, 'subject' => $mail_subject, 'email_message' => $mail_subject, 'email' => $email];
                 Mail::queue('emails.product_rated', $data, function ($message) use($user, $data) {
                     $message->to($data['email'])->subject($data['subject']);
                 });
                 $product->save();
                 $detail->rate = $product_rate;
                 $detail->rate_comment = $product_comment;
                 $detail->save();
                 Notice::create(['user_id' => $seller_user->id, 'sender_id' => $user->id, 'action_type_id' => 14, 'source_id' => $order->id, 'status' => 'new']);
                 return \Response::json(array('success' => true, 'message' => trans('store.order_rate_view.http_messages.success'), 'detail_id' => $detail_id, 'product_rate' => $product_rate), 200);
             } else {
                 return \Response::json(array('success' => false, 'message' => trans('store.order_rate_view.http_messages.no_order'), 'detail_id' => $detail_id, 'product_rate' => $product_rate), 200);
             }
         } else {
             return \Response::json(array('success' => false, 'message' => trans('store.order_rate_view.http_messages.no_user'), 'detail_id' => $detail_id, 'product_rate' => $product_rate), 200);
         }
     } else {
         return \Response::json(array('success' => false, 'message' => trans('store.order_rate_view.http_messages.no_user'), 'detail_id' => $detail_id, 'product_rate' => $product_rate), 200);
     }
 }
예제 #23
0
 /**
  * Create and persist a new DMCA notice.
  *
  * @param Request $request
  */
 public function createNotice(Request $request)
 {
     $data = session()->get('dmca');
     $notice = Notice::open($data)->userTemplate($request->input('template'));
     $this->user->notices()->save($notice);
     return $notice;
 }
 public function noticehistory()
 {
     $notice = new Notice();
     $result = $notice->all();
     return view('oms.pages.noticehistory')->with('result', $result);
 }
 /**
  * Delete a club notice
  * @param  Request $request Notice id provided by administrator
  */
 public function delete_notice(Request $request)
 {
     $notice = Notice::find($request->input('notice_id'));
     $notice->delete();
     session()->flash('flash_message', 'Your notice has been deleted');
     return redirect('administrator/notices');
 }
예제 #26
0
 /**
  *
  *
  * @param $noticeId
  * @param Request $request
  * @return mixed
  *
  */
 public function update($noticeId, Request $request)
 {
     $isRemoved = $request->has('content_removed');
     Notice::findOrFail($noticeId)->update(['content_removed' => $isRemoved]);
 }
예제 #27
0
 /**
  * Display a list of club notices.
  *
  * @return Response
  */
 public function index()
 {
     $notices = Notice::orderBy('created_at', 'DESC')->get();
     return view('notices.index', compact('notices'));
 }