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); } }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); Widget::truncate(); factory(Widget::class, 50)->create(); // $this->call(UserTableSeeder::class); Model::reguard(); }
/** * 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'); }
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(); }
/** * Update widget * * @param \App\Widget $widget * @return bool */ public function save($widget) { return $widget->save(); }
/** * Get by * * @param string $key * @param string $value * * @return \App\Widget */ public function getBy($key, $value) { return Widget::where($key, $value)->first(); }
/** * 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'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Widget::destroy($id); }
/** * 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!'); }
/** * Create * * @param \App\Widget $widget */ public function delete(Widget $widget) { return $widget->delete(); }
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); } }
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; }
/** * 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'); }
function show() { $pid = (int) $_GET['id']; App\Widget::photoDetail($pid, $this->uid); $this->swoole->tpl->display(); }
/** * Create * * @param array $attributes * @return \App\Widget */ public function create(array $attributes = array()) { return Widget::create($attributes); }
/** * 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'); }