public function indexAction($params = null) { $randomQuote = \App\Quote::getRandomQuoteId(); $quote = new \App\Quote(); $quote->load($randomQuote); getSystem()->render('home', $quote->toArray()); }
public function run() { Quote::create(['teks' => 'Success is going from failure to failure without losing your enthusiasm', 'author' => 'Winston Churchill', 'background' => '1.jpg']); Quote::create(['teks' => 'Dream big and dare to fail', 'author' => 'Norman Vaughan', 'background' => '2.jpg']); Quote::create(['teks' => 'It does not matter how slowly you go as long as you do not stop', 'author' => 'Confucius', 'background' => '3.jpg']); //... add more quotes if you want! }
/** * Run the database seeds. * * @return void */ public function run() { HTTPRequest::verifyPeer(env('UNIREST_VERIFYPEER')); //Get 10 quotes, from a Mashape API for ($i = 0; $i < 10; $i++) { $response = HTTPRequest::post("https://andruxnet-random-famous-quotes.p.mashape.com/cat=famous", array("X-Mashape-Key" => env('MASHAPE_KEY'), "Content-Type" => "application/x-www-form-urlencoded", "Accept" => "application/json")); Quote::create(["content" => $response->body->quote, "author" => $response->body->author, "source" => "https://andruxnet-random-famous-quotes.p.mashape.com/cat=famous"]); } }
/** * Put a Quote into Quote of the day Cache (qotd) * * @param $id * @param Request $request * @return */ public function setasqotd($id, Request $request) { $quote = $this->quotes->findOrFail($id); if ($request->user()->isSuperAdmin()) { Cache::put('qotd', $quote, 60 * 24); return back()->withNotification("Quote has been set as Quote of the Day"); } return redirect('/')->withNotification("Error! Unauthorized access")->withType("danger"); }
/** * Display the specified resource. * * @param $slug * * @return Response * @internal param int $id */ public function show($slug) { try { $quote = Quote::where(['slug' => $slug])->firstOrFail(); $statusCode = 200; $response = ['data' => $quote]; } catch (Exception $e) { $statusCode = 400; } finally { return Response::json($response, $statusCode); } }
/** * Delete a quote. * @param \Illuminate\Http\Request $request * @return string */ public function destroy(Request $request) { $quote = Quote::find($request->get('deleteQuote')); if ($quote) { if ($quote->delete()) { Flash::success("Quote deleted"); } else { Flash::error("Oops", "Something went wrong when trying to delete that quote."); } } else { Flash::warning("Oops", "The selected quote couldn't be found; perhaps it's been deleted?"); } return redirect()->back(); }
public function edit() { $user = User::findOrFail(Auth::user()->id); $entity = Entity::where('user_id', Auth::user()->id)->firstOrFail(); $about = About::where('user_id', Auth::user()->id)->firstOrFail(); $contact = Contact::where('user_id', Auth::user()->id)->firstOrFail(); $home = Home::where('user_id', Auth::user()->id)->firstOrFail(); $quote = Quote::where('user_id', Auth::user()->id)->get(); $quote_count = $quote->count(); $skill = Skill::where('user_id', Auth::user()->id)->get(); $skill_count = $skill->count(); $skill_slider = SkillSlider::where('user_id', Auth::user()->id)->get(); $skill_slider_count = $skill_slider->count(); $portfolio_piece = PortfolioPiece::where('user_id', Auth::user()->id)->get(); $portfolio_piece_count = $portfolio_piece->count(); return view('edit')->with('user', $user)->with('home', $home)->with('entity', $entity)->with('contact', $contact)->with('about', $about)->with('skill', $skill)->with('skill_count', $skill_count)->with('quote', $quote)->with('quote_count', $quote_count)->with('skill_slider', $skill_slider)->with('skill_slider_count', $skill_slider_count)->with('portfolio_piece', $portfolio_piece)->with('portfolio_piece_count', $portfolio_piece_count); }
/** * Save */ public function save($quote = null, $data = null) { DB::transaction(function () use(&$data, &$quote) { if (is_null($quote)) { $quote = Quote::create($data); } else { $quote->fill($data)->save(); } if (!$data['items']) { throw new UnprocessableEntityHttpException('Empty line items'); } $quote->items()->delete(); foreach ($data['items'] as $item) { $quote->items()->create($item); } }); return $this->getById($quote->id); }
/** * Return quotes's data in a way that can be read by Datatables * * @return Response */ public function getDatatable() { $quotes = Quote::select(); $datatables = \Datatables::of($quotes)->addColumn('deleted_at', function ($quote) { return $quote->deleted_at == null ? '<span class="label label-sm label-success">Active</span>' : '<span class="label label-sm label-danger">Deleted</span>'; })->addColumn('created_at', function ($quote) { return date('F j, Y, g:i a', strtotime($quote->created_at)); })->addColumn('updated_at', function ($quote) { return date('F j, Y, g:i a', strtotime($quote->created_at)); })->addColumn('actions', function ($quote) { return '<a href="' . url('admin/quotes/' . $quote->id . '/edit') . '" class="btn btn-success btn-sm" ><span class="glyphicon glyphicon-pencil"></span> Edit</a>'; }); $filters = \Input::get('filters'); if (!empty($filters)) { $datatables->filter(function ($query) use($filters) { foreach ($filters as $fName => $fValue) { if (!$fValue) { continue; } switch ($fName) { case 'id': $query->where('quote.id', '=', $fValue); break; case 'slug': $query->where('slug', 'LIKE', '%' . $fValue . '%'); break; case 'text': $query->where('text', 'LIKE', '%' . $fValue . '%'); break; case 'created_at_from': $query->where('created_at', '>=', $fValue); break; case 'created_at_to': $query->where('created_at', '<=', $fValue); break; case 'updated_at_from': $query->where('updated_at', '>=', $fValue); break; case 'updated_at_to': $query->where('updated_at', '<=', $fValue); break; case 'deleted': if ($fValue) { if ($fValue == 1) { $query->whereNull('deleted_at'); } if ($fValue == -1) { $query->where('deleted_at', '!=', 'null'); } } break; } } }); } return $datatables->make(true); }
public function delete() { // Get id of quote_request $input = Input::all(); $id = $input['delete']; $quote_request = QuoteRequest::find($id); // Delete Quote PDF if it exists $path = 'quotes/' . $id . '.pdf'; if (file_exists($path)) { unlink($path); } // Delete Artwork image and its thumbnail if they exist if ($quote_request->artwork_image != null) { $path_image = 'uploads/artworks/' . $quote_request->artwork_image; $path_thumbnail = 'uploads/thumbnails/' . $quote_request->artwork_image; if (file_exists($path_image)) { unlink($path_image); } if (file_exists($path_thumbnail)) { unlink($path_thumbnail); } } $quote_request_items = $quote_request->qris; foreach ($quote_request_items as $quote_request_item) { $quote_line_delete = QuoteRequestItem::find($quote_request_item->id); $quote_line_delete->delete(); } $quotes = $quote_request->quotes; foreach ($quotes as $quote) { $quote_lines = $quote->qris; foreach ($quote_lines as $quote_line) { $quote_line_delete = QuoteItem::find($quote_line->id); $quote_line_delete->delete(); } $quote_delete = Quote::find($quote->id); $quote_delete->delete(); } $quote_request->delete(); if (isset($input['customer_id'])) { return redirect('customers/' . $input['customer_id'] . '/history')->with('message', 'Quote / Job has been deleted successfully'); } else { return redirect('/')->with('message', 'Quote / Job has been deleted successfully'); } }
public function inspireAPI() { $inspire = Quote::quote(); $data = ['inspire' => $inspire]; return $data; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $quote = Quote::findOrFail($id); $client_id = $quote->client_id; $quote->delete(); return redirect('clients/' . $client_id); }
public function post_evaluate(\Illuminate\Http\Request $request, $qr_id) { // Validate form $this->validate($request, ['quote_id' => 'required'], $messages = array('quote_id.required' => 'You should choose a Supplier for creating a Quote')); $quote_request = QuoteRequest::find($qr_id); $quantities = $quote_request->first_quote()->quantities(); $input = request::all(); $quote_id = $input['quote_id']; $quote = Quote::find($quote_id); //echo "<pre>"; //echo "Selecting Quote ID $quote_id for Quote Request $qr_id\n"; foreach ($quote_request->qris as $qri) { $qty = $qri["quantity"]; $qi = QuoteItem::where("quantity", "=", $qty)->where("quote_id", "=", $quote_id)->first(); //print("QRI: " . $qri["quantity"] . ": " . $qri["price"]."\n"); if ($qi == null) { //print("Could not find quote item for Quantity $qty\n"); $qri["price"] = 0; $qri["gst"] = 0; $qri["total"] = 0; $qri["unit_price"] = 0; $qri->save(); } else { $qri["price"] = $qi["total_net"]; $qri["gst"] = $qri["price"] * 0.1; $qri["total"] = $qri["price"] + $qri["gst"]; $qri["unit_price"] = $qri["total"] / $qri["quantity"]; $qri->save(); } } $quote_request = QuoteRequest::find($qr_id); $quote_request->quote_id = $input['quote_id']; $quote_request->save(); // delete Quote PDF if exists $path = 'quotes/' . $qr_id . '.pdf'; if (file_exists($path)) { unlink($path); } return redirect('evaluate/' . $qr_id); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Quote::destroy($id); return response('', Response::HTTP_NO_CONTENT); }
public function addQuote() { $user = User::find(Auth::user()->id); if (isset($user)) { $quote = new Quote(); $quote->user_id = $user->id; if (Input::get('add_text') != '') { $quote->text = Input::get('add_text'); } if (Input::get('add_author') != '') { $quote->author = Input::get('add_author'); } if (Input::get('add_extra_1') != '') { $quote->extra_1 = Input::get('add_extra_1'); } if (Input::get('add_extra_2') != '') { $quote->extra_2 = Input::get('add_extra_2'); } $quote->save(); return redirect('home')->with('status', 'success'); } else { return 'An error has occured'; } }
public function destroy($id) { Quote::find($id)->delete(); $quotes = Quote::orderBy('name')->paginate(env('QUOTE_PAGINATION_MAX')); return view('quotes.index')->with('quotes', $quotes); }
public function getAllQuotes() { $quotes = Quote::getAll(); return $quotes; }
public function scrape() { $job = new ShowerthoughtsScrapeJob('https://www.reddit.com/r/Showerthoughts.json?limit=100'); $this->dispatch($job); return Quote::all(); }
public function renderDashboard() { $now = Carbon::now()->toDateTimeString(); $clients = Client::all(); $user_activity = UserActivity::latest()->get(); foreach ($user_activity as $ua) { DB::table('user_activities_read_status')->insert(['user_id' => $ua->user->id, 'activity_id' => $ua->id, 'is_read' => 1]); } foreach ($clients as $client) { $client->client_id = $client->id + 999; } $active_invoices = Invoice::active()->get(); $overdue_invoices = Invoice::overdue()->get(); $thirty_day_invocies = Invoice::paidInLastThirtyDays()->get(); $previous_thirty_day_invocies = Invoice::paidInPreviousThirtyDays()->get(); $this_year_invoices = Invoice::paidThisCalenderYear()->get(); $last_year_invoices = Invoice::paidLastCalenderYear()->get(); $this_financial_year_invoices = Invoice::paidThisFinancialYear()->get(); $last_financial_year_invoices = Invoice::paidLastFinancialYear()->get(); $active_total = $active_invoices->sum('amount'); $overdue_total = $overdue_invoices->sum('amount'); $thirty_day_total = $thirty_day_invocies->sum('amount'); $previous_thirty_day_total = $previous_thirty_day_invocies->sum('amount'); $this_year_total = $this_year_invoices->sum('amount'); $last_year_total = $last_year_invoices->sum('amount'); $this_financial_year_total = $this_financial_year_invoices->sum('amount'); $last_financial_year_total = $last_financial_year_invoices->sum('amount'); $active_quotes = Quote::active()->get(); $accepted_quotes = Quote::issuedThisFinancialYear()->accepted()->get(); $accepted_quotes_total = $accepted_quotes->sum('amount'); $position_difference = $thirty_day_total - $previous_thirty_day_total; if ($this_year_total !== 0 && $last_year_total !== 0) { $year_difference_percent = $this_year_total / $last_year_total * 100; } else { $year_difference_percent = 0; } if ($this_financial_year_total !== 0 && $last_financial_year_total !== 0) { $financial_year_difference_percent = $this_financial_year_total / $last_financial_year_total * 100; } else { $financial_year_difference_percent = 0; } $projected_fy_earnings = $this_financial_year_total + $accepted_quotes_total; $projected_fy_earnings_percent = $projected_fy_earnings / $last_financial_year_total * 100; foreach ($active_invoices as $invoice) { $invoice->client_id = $invoice->client_id + 999; if ($invoice->client_specific_id < 10) { $invoice->client_specific_id = sprintf("%02d", $invoice->client_specific_id); } $issue_date = Carbon::parse($invoice->issue_date); $due_date = Carbon::parse($invoice->due_date); $invoice->terms_diff = $issue_date->diffInDays($due_date); if ($now > $due_date) { $invoice->is_overdue = true; } else { $invoice->is_overdue = false; } } foreach ($active_quotes as $quote) { $quote->client_id = $quote->client_id + 999; if ($quote->client_specific_id < 10) { $quote->client_specific_id = sprintf("%02d", $quote->client_specific_id); } } return view('app.dashboard', ['clients' => $clients, 'active_total' => $active_total, 'overdue_total' => $overdue_total, 'thirty_day_total' => $thirty_day_total, 'previous_thirty_day_total' => $previous_thirty_day_total, 'this_year_total' => $this_year_total, 'last_year_total' => $last_year_total, 'this_financial_year_total' => $this_financial_year_total, 'last_financial_year_total' => $last_financial_year_total, 'position_diffeence' => $position_difference, 'year_difference_percent' => $year_difference_percent, 'financial_year_difference_percent' => $financial_year_difference_percent, 'projected_fy_earnings' => $projected_fy_earnings, 'projected_fy_earnings_percent' => $projected_fy_earnings_percent, 'active_invoices' => $active_invoices, 'active_quotes' => $active_quotes, 'user_activity' => $user_activity]); }
* correct record */ $count = Quote::query()->get()->count(); $day = (int) date('z'); $page = $day % $count + 1; $quotes = Quote::query()->get()->forPage($page, 1)->all(); if (empty($quotes)) { throw new \Illuminate\Database\Eloquent\ModelNotFoundException(); } return view('quote', ['quote' => $quotes[0]]); }); /** * Display a specific quote */ $app->get('/quote/{id}', function ($id) use($app) { $quote = Quote::query()->findOrFail($id); return view('quote', ['quote' => $quote]); }); $app->get('/test', function () { echo 'ngetes doang ini...'; }); $app->get('peserta', 'PesertaController@index'); $app->group(['prefix' => 'api/article', 'namespace' => 'App\\Http\\Controllers'], function ($app) { //untuk group harus pakai namespace $app->get('/', 'ArticleController@index'); $app->get('/{id}', 'ArticleController@getArticle'); $app->post('/', 'ArticleController@saveArticle'); $app->put('{id}', 'ArticleController@updateArticle'); $app->delete('{id}', 'ArticleController@deleteArticle'); }); // $app->get('api/article','ArticleController@index');
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('quotes')->with('quotes', \App\Quote::all()); }); Route::post('/', function () { $quote = new \App\Quote(\Input::all()); $quote->save(); return redirect('/'); });
private function setQuoteParams(\App\Quote $quote, $params, \App\Person $person) { $newParams = array('quote' => $params['quote'], 'quoteDate' => $params['quoteDate'], 'source' => $params['source'], 'dateAdded' => $quote->dateAdded, 'comment' => $params['comment'], 'person' => $person); $quote->setParams($newParams); }
public function quotesDeletePostAction($params) { $quote = new \App\Quote(); try { $quote->load($params['qId']); //$quote->setParams(array('id' => $params['qId'])); $quote->delete(); } catch (\Exception $e) { getSystem()->getRender()->error(500, 'Could not delete quote: ' . $e->getMessage(), $e); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // fetch one particular record by id $quote = Quote::findOrFail($id); return response()->json($quote, 200); }
/** * Execute the job. * * @return void */ public function handle() { HTTPRequest::verifyPeer(env('UNIREST_VERIFYPEER')); $response = HTTPRequest::get($this->url); $posts = $response->body->data->children; foreach ($posts as $post) { // dd($post->data->stickied); if (!$post->data->stickied) { Quote::firstorCreate(["content" => $post->data->title, "author" => $post->data->author, "source" => 'https://www.reddit.com' . $post->data->permalink]); } } }