/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { dd($request->all()); // $input = $request->all(); // $input['apartment_id'] = Auth::user()->profile->defaultApartment; // $input['profile_id'] = Auth::user()->profile->id; // $quote = Quote::create($input); $quote = new Quote(); $quote->apartment_id = Auth::user()->profile->defaultApartment; $quote->profile_id = Auth::user()->profile->id; $quote->subject = $request->subject; $quote->stage = $request->stage; $quote->validuntil = $request->date_expiry; $quote->invoicenum = '1000'; $quote->discount_type = 'value'; $quote->tax1 = $request->oc; $quote->tax2 = $request->tax; $quote->save(); for ($idx = 0; $idx < count($request->description); $idx++) { $item = new QuoteItem(); $item->quote_id = $quote->id; $item->description = ucfirst($request->description[$idx]); $item->qty = $request->qty[$idx]; $item->price = $request->price[$idx]; $item->total = $request->qty[$idx] * $request->price[$idx]; $item->taxable = $request->taxable[$idx]; $item->save(); } return redirect()->back()->withMessage('Quotation Created')->withStatus('success'); }
public function run() { Quote::create(['text' => 'Success is going from failure to failure without losing your enthusiasm', 'author' => 'Winston Churchill', 'background' => '1.jpg']); Quote::create(['text' => 'Dream big and dare to fail', 'author' => 'Norman Vaughan', 'background' => '2.jpg']); Quote::create(['text' => 'It does not matter how slowly you go as long as you do not stop', 'author' => 'Confucius', 'background' => '3.jpg']); Quote::create(['text' => 'Do not wish for an easy life. Wish for the strength to endure a difficult one', 'author' => 'Bruce Lee', 'background' => '4.jpg']); }
public function run() { Quote::create(['text' => 'Success is going from failure to failure without losing your enthusiasm', 'author' => 'Winston Churchill', 'background' => '1.jpg']); Quote::create(['text' => 'Dream big and dare to fail', 'author' => 'Norman Vaughan', 'background' => '2.jpg']); Quote::create(['text' => '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! $this->call('QuoteTableSeeder'); }
public function rss() { $Quotes = Quote::orderBy('id', 'DESC')->paginate(15); $xml = new \XMLWriter(); $xml->openMemory(); $xml->startDocument(); $xml->startElement('rss'); $xml->startElement('channel'); $xml->startElement('title'); $xml->text("KM-QRS"); $xml->endElement(); //title foreach ($Quotes as $Quote) { $xml->startElement('item'); $xml->startElement('id'); $xml->text($Quote->id); $xml->endElement(); //id $xml->startElement('title'); $xml->text("#" . $Quote->id . ": " . $Quote->truncate($Quote->content)); $xml->endElement(); //title $xml->startElement('description'); $xml->text($Quote->content); $xml->endElement(); //description $xml->startElement('link'); $xml->text(url('/') . "/" . $Quote->id); $xml->endElement(); //link $xml->startElement('pubDate'); $xml->text($Quote->created_at); $xml->endElement(); //pubDate $xml->endElement(); //item } $xml->endElement(); //channel $xml->endElement(); //rss $xml->endDocument(); $content = $xml->outputMemory(); $xml = null; return response($content)->header('Content-Type', 'text/xml'); }
public function rate(Request $request) { $ratings = $request->session()->get('ratings', []); $rating = $request->input('rating'); $id = $request->input('id'); $quote = Models\Quote::find($id); if (!in_array($id, $ratings)) { if ($rating > 0) { $quote->rating += 1; } else { $quote->rating -= 1; } $quote->save(); $ratings[] = $id; $request->session()->put('ratings', $ratings); } return response()->json(['rating' => $quote->rating]); }
public function import() { //echo "aaaaaaa"; $quotesData = json_decode(Storage::get('quotes.json'), true); //echo $quotesData["1"]["1"]; $count = 0; foreach ($quotesData as $ship_id => $quoteArray) { foreach ($quoteArray as $voice_id => $quote) { //echo $ship_id." ".$voice_id." ".$quote."<br>"; $newQuote = new Quote(); $newQuote->ship_id = $ship_id; $newQuote->voice_id = $voice_id; $newQuote->lang = "en"; $newQuote->content = $quote; $newQuote->status = "Pending"; $newQuote->save(); } $count++; echo "Finished " . $count . "<br>"; $this->updateCounter($ship_id, "en"); } /* while (current($quotesData)) { $ship_id = key($quotesData); $quoteArray = $quotesData[$ship_id]; while (current($quoteArray)) { $voice_id = key($quoteArray); echo $ship_id." ".$voice_id." ".$quoteArray[$voice_id]."<br>"; $newQuote = new Quote; $newQuote->ship_id = $ship_id; $newQuote->voice_id = $voice_id; $newQuote->lang = "en"; $newQuote->content = $quoteArray[$voice_id]; //$newQuote->save(); next($quoteArray); } $count++; echo "Finished ".$count."<br>"; next($quotesData); }*/ /*foreach($quotesData as $shipQuoteData){ foreach($shipQuoteData as $quote){ echo $quote.'<br>'; } /*$newQuote = new Quote; $newQuote->ship_id = $quote->ship_id; $newQuote->voice_id = $request->voice_id; $newQuote->lang = $request->lang; $newQuote->content = $request->content;*/ //$newQuote->save(); //} /*return view("app/Data/Quests", [ 'quests' => $quests, ]); $quote = new Quote; $quote->ship_id = $request->ship_id; $quote->voice_id = $request->voice_id; $quote->lang = $request->lang; $quote->content = $request->content; $quote->save();*/ return redirect('/data/quotes'); }
Route::get('projtypedelete/{id}', ['as' => 'projtypedelete', 'uses' => 'ProjectTypesController@destroy']); Route::get('projdelete/{id}', ['as' => 'projdelete', 'uses' => 'ProjectsController@destroy']); Route::get('quotedelete/{id}', ['as' => 'quotedelete', 'uses' => 'QuotesController@destroy']); Route::get('clientdelete/{id}', ['as' => 'clientdelete', 'uses' => 'ClientsController@destroy']); Route::get('messagedelete/{id}', ['as' => 'messagedelete', 'uses' => 'MessagesController@destroy']); Route::get('filedelete/{id}', ['as' => 'filedelete', 'uses' => 'FilesController@destroy']); Route::get('filetypedelete/{id}', ['as' => 'filetypedelete', 'uses' => 'FileTypesController@destroy']); Route::get('coverdelete/{id}', ['as' => 'coverdelete', 'uses' => 'CoverLettersController@destroy']); Route::post('generateLegitSlug', ['as' => 'generateLegitSlug', 'uses' => 'Blog\\BlogPostsController@generateLegitSlug']); Route::get('getfilesbytype/{id?}', ['as' => 'getfilesbytype', 'uses' => 'FilesController@getFilesByTypeId']); Route::get('/', function () { return view('admin.index'); }); Route::get('/clients', function () { $clients = \App\Models\Client::all(); $quotes = \App\Models\Quote::all(); return view('admin.clients', ['clients' => $clients, 'quotes' => $quotes]); }); }); Route::get('/speech', function () { return view('speechdemo'); }); Route::get('/blog', function () { $posts = \App\Models\Blog_Post::with('Author')->with('picture')->get(); return view('front.blog.index', ['posts' => $posts]); }); Route::get('/blog/{slug}', function ($slug) { $post = \App\Models\Blog_Post::where('slug', $slug)->with('Author')->with('picture')->first(); if ($post) { return view('front.blog.viewPost', ['post' => $post]); }
# app/Http/routes.php use App\Models\Quote; /** * Display the today quote */ $app->get('/', function () use($app) { /* * Picks a different quote every day * (for a maximum of 366 quotes) * * - $count: the total number of available quotes * - $day: the current day of the year (from 0 to 365) * - $page: the page to look for to retrieve the * 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('/{id}', function ($id) use($app) { $quote = Quote::query()->findOrFail($id); return view('quote', ['quote' => $quote]); });
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $quote = Quote::find($id); $quote->delete(); return back(); }