コード例 #1
0
 public function create()
 {
     $rules = array('type' => 'alpha', 'rating_icon' => 'string');
     $validator = Validator::make(Input::all(), $rules);
     if (!$validator->fails() && in_array($_POST['type'], array('feedback', 'rate'))) {
         $widget = new Widget();
         $widget->user_id = Auth::id();
         $widget->widget_type_id = Input::get('type') == 'feedback' ? 3 : 1;
         if ($widget->widget_type_id == 1 && Input::has('rating_icon') && Input::get('rating_icon') == 'faces') {
             $widget->widget_type_id = 2;
         }
         $widget->save();
         // Redirect to new widget
         return redirect('dashboard/widget/' . $widget->id);
     }
 }
コード例 #2
0
ファイル: DatabaseSeeder.php プロジェクト: paihz/Lara-boot
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     Widget::truncate();
     factory(Widget::class, 50)->create();
     // $this->call(UserTableSeeder::class);
     Model::reguard();
 }
コード例 #3
0
ファイル: WidgetController.php プロジェクト: paihz/Lara-boot
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['widget_name' => 'required|unique:widgets|string|max:40']);
     $slug = str_slug($request->widget_name, "-");
     $widget = Widget::create(['widget_name' => $request->widget_name, 'slug' => $slug, 'user_id' => Auth::id()]);
     $widget->save();
     alert()->success('Tahniah', 'You made my day');
     //return redirect('/');
     return Redirect::action('WidgetController@index');
 }
コード例 #4
0
 public function __construct($widget_id)
 {
     // Find or fail widget
     $this->widget = Widget::findOrFail($widget_id);
     $session_id = Session::getId();
     $referrer = filter_var(Request::server('HTTP_REFERER'), FILTER_SANITIZE_URL);
     // Add new resource?
     $this->resource = Resource::firstOrNew(['uri' => $referrer, 'widget_id' => $this->widget->id]);
     $this->resource->uri = $referrer;
     $this->resource->widget_id = $this->widget->id;
     $this->resource->save();
     // Add new visitor?
     $this->visitor = Visitor::firstOrCreate(['session_id' => $session_id]);
     $this->visitor->touch();
     // Add new view?
     $this->view = View::firstOrCreate(['resource_id' => $this->resource->id, 'visitor_id' => $this->visitor->id]);
     $this->view->touch();
 }
コード例 #5
0
 /**
  * Update widget
  *
  * @param  \App\Widget  $widget
  * @return bool
  */
 public function save($widget)
 {
     return $widget->save();
 }
コード例 #6
0
 /**
  * Get by
  *
  * @param  string  $key
  * @param  string  $value
  *
  * @return \App\Widget
  */
 public function getBy($key, $value)
 {
     return Widget::where($key, $value)->first();
 }
コード例 #7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Widget::destroy($id);
     alert()->overlay('Attention!', 'You deleted a widget', 'error');
     return Redirect::route('widget.index');
 }
コード例 #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Widget::destroy($id);
 }
コード例 #9
0
ファイル: WidgetController.php プロジェクト: jdmays/ls1
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Widget::destroy(1);
     return redirect('widgets')->with('status', 'Poof!');
 }
コード例 #10
0
 /**
  * Create
  *
  * @param  \App\Widget  $widget
  */
 public function delete(Widget $widget)
 {
     return $widget->delete();
 }
コード例 #11
0
ファイル: DatabaseSeeder.php プロジェクト: muhamadanjar/rth
 public function run()
 {
     DB::table('widget')->delete();
     $widgets = array(array('include' => true, 'canFloat' => false, 'type' => 'titlePane', 'placeAt' => 'left', 'path' => '', 'id' => '', 'title' => '', 'open' => false, 'position' => 5, 'srcNodeRef' => 'nodeId', 'option_map' => true, 'option_mapClickMode' => true, 'option_legendLayerInfos' => true, 'option_tocLayerInfos' => true, 'option_editorLayerInfos' => true, 'option_property' => 'value', 'created_at' => date('Y-m-d'), 'updated_at' => date('Y-m-d')));
     foreach ($widgets as $widget) {
         Widget::create($widget);
     }
 }
コード例 #12
0
ファイル: WidgetChart.php プロジェクト: Khande1n/ujval
 public function chartDataFrom($searchTerm)
 {
     $yearCounts = Widget::select(DB::raw('year(created_at) as year'), DB::raw('count(widget_name) as `count`'))->where('widget_name', 'LIKE', '%' . $searchTerm . '%')->groupBy('year')->get();
     $chartData = $this->formatResultOf($yearCounts);
     return $chartData;
 }
コード例 #13
0
ファイル: WidgetController.php プロジェクト: Khande1n/ujval
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Widget::destroy($id);
     return Redirect::route('widget.index');
 }
コード例 #14
0
ファイル: Myphoto.php プロジェクト: sunnycamel/swoole.com
 function show()
 {
     $pid = (int) $_GET['id'];
     App\Widget::photoDetail($pid, $this->uid);
     $this->swoole->tpl->display();
 }
コード例 #15
0
 /**
  * Create
  *
  * @param  array  $attributes
  * @return \App\Widget
  */
 public function create(array $attributes = array())
 {
     return Widget::create($attributes);
 }
コード例 #16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Widget::destroy($id);
     alert()->overlay('Hey!', 'You deleted the widget with id ' . $id);
     return \Redirect::route('widget.index');
 }