|
|
@@ -1,20 +1,20 @@
|
|
|
<?php
|
|
|
-
|
|
|
+
|
|
|
namespace App\Http\Controllers;
|
|
|
-
|
|
|
+
|
|
|
use App\News;
|
|
|
use App\Section;
|
|
|
use App\Event;
|
|
|
use App\Page;
|
|
|
use App\Home;
|
|
|
use Illuminate\Http\Request;
|
|
|
-use File;
|
|
|
-use Auth;
|
|
|
+use Illuminate\Support\Facades\File;
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
|
use App\Notifications\FacebookPost;
|
|
|
use App\Notifications\TwitterPost;
|
|
|
class NewsController extends Controller
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
protected $rules = [
|
|
|
//'section_id' => ['required']
|
|
|
'title' => ['required'],
|
|
|
@@ -44,11 +44,11 @@ class NewsController extends Controller
|
|
|
}
|
|
|
|
|
|
$news = News::orderBy('date', 'DESC')->take(1000)->get();//->paginate(50);
|
|
|
-
|
|
|
+
|
|
|
return view('news.index',compact('news'))
|
|
|
->with('i', (request()->input('page', 1) - 1) * 5);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function load_json()
|
|
|
{
|
|
|
$start = $_GET["start"];
|
|
|
@@ -91,7 +91,7 @@ class NewsController extends Controller
|
|
|
|
|
|
|
|
|
$search = $_GET["search"]["value"];
|
|
|
-
|
|
|
+
|
|
|
if ($sort == '3')
|
|
|
{
|
|
|
$news = News::with(['section' => function ($query) use ($sort_by, $sort_by_dir) {
|
|
|
@@ -160,7 +160,7 @@ class NewsController extends Controller
|
|
|
<button type="submit" class="btn btn-w-m btn-danger" onclick="return confirm(\'Sei sicuro?\')"><i class="fa fa-trash-o" aria-hidden="true"></i></button>
|
|
|
</form>';
|
|
|
$x[] = $form;
|
|
|
- $aData[] = $x;
|
|
|
+ $aData[] = $x;
|
|
|
}
|
|
|
$aRet = array('recordsTotal' => $total, 'recordsFiltered' => $filtered, 'data' => $aData);
|
|
|
return json_encode($aRet);
|
|
|
@@ -208,7 +208,7 @@ class NewsController extends Controller
|
|
|
|
|
|
return view('news.create', compact('sections', 'regions', 'events', 'pages', 'layouts', 'section_position', 'region_1_position', 'region_2_position', 'first'));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Store a newly created resource in storage.
|
|
|
*
|
|
|
@@ -229,7 +229,7 @@ class NewsController extends Controller
|
|
|
|
|
|
if (! File::exists(public_path()."/files/news"))
|
|
|
File::makeDirectory(public_path()."/files/news");
|
|
|
-
|
|
|
+
|
|
|
$path = public_path('files/news');
|
|
|
|
|
|
request()->image->move($path, $filename);
|
|
|
@@ -253,7 +253,7 @@ class NewsController extends Controller
|
|
|
|
|
|
if (! File::exists(public_path()."/files/news"))
|
|
|
File::makeDirectory(public_path()."/files/news");
|
|
|
-
|
|
|
+
|
|
|
$path = public_path('files/news');
|
|
|
|
|
|
$input["image" . $i]->move($path, $filename);
|
|
|
@@ -271,7 +271,7 @@ class NewsController extends Controller
|
|
|
|
|
|
if (! File::exists(public_path()."/files/news"))
|
|
|
File::makeDirectory(public_path()."/files/news");
|
|
|
-
|
|
|
+
|
|
|
$path = public_path('files/news');
|
|
|
|
|
|
request()->pdf->move($path, $filename);
|
|
|
@@ -289,20 +289,19 @@ class NewsController extends Controller
|
|
|
}
|
|
|
$input["date"] = $final_date;
|
|
|
|
|
|
- // $input["online"] = isset($input["online"]) ? ($input["online"] == 'on' ? true : false) : false;
|
|
|
$input["online"] = false;
|
|
|
$input["homepage"] = isset($input["homepage"]) ? ($input["homepage"] == 'on' ? true : false) : false;
|
|
|
$input["live"] = isset($input["live"]) ? ($input["live"] == 'on' ? true : false) : false;
|
|
|
$input["breaking_news"] = isset($input["breaking_news"]) ? ($input["breaking_news"] == 'on' ? true : false) : false;
|
|
|
-
|
|
|
+
|
|
|
$news = News::create($input);
|
|
|
|
|
|
if (isset($input['publish']))
|
|
|
{
|
|
|
$news->online = true;
|
|
|
$news->save();
|
|
|
-
|
|
|
- // Posiziono la notizia se la data non è
|
|
|
+
|
|
|
+ // Posiziono la notizia se la data non è
|
|
|
if ($final_date <= date("Y-m-d H:i:s"))
|
|
|
{
|
|
|
|
|
|
@@ -312,7 +311,7 @@ class NewsController extends Controller
|
|
|
$s[$_POST["section_position"]] = $news->id;
|
|
|
$s->save();
|
|
|
$news->section_position = '';
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if ($_POST["region_1_position"] != '')
|
|
|
{
|
|
|
@@ -360,61 +359,6 @@ class NewsController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- // Posizione
|
|
|
- if ($_POST["section_position"] != '')
|
|
|
- {
|
|
|
- $field = $input["section_position"];
|
|
|
- $s = Section::findOrFail($input["section_id"]);
|
|
|
- $s->big = ($field != 'big' && $s->big == $news->id) ? '' : $s->big;
|
|
|
- $s->small1 = ($field != 'small1' && $s->small1 == $news->id) ? '' : $s->small1;
|
|
|
- $s->small2 = ($field != 'small2' && $s->small2 == $news->id) ? '' : $s->small2;
|
|
|
- $s->small3 = ($field != 'small3' && $s->small3 == $news->id) ? '' : $s->small3;
|
|
|
- $s->small4 = ($field != 'small4' && $s->small4 == $news->id) ? '' : $s->small4;
|
|
|
- $s->small5 = ($field != 'small5' && $s->small5 == $news->id) ? '' : $s->small5;
|
|
|
- $s->small6 = ($field != 'small6' && $s->small6 == $news->id) ? '' : $s->small6;
|
|
|
- $s->$field = $news->id;
|
|
|
- $s->save();
|
|
|
-
|
|
|
- // CLEARLAYOUT
|
|
|
- $s->clearLayout();
|
|
|
-
|
|
|
- }
|
|
|
- if ($_POST["region_1_position"] != '')
|
|
|
- {
|
|
|
- $field = $input["region_1_position"];
|
|
|
- $r = Section::findOrFail($input["region_1_id"]);
|
|
|
- $r->big = ($field != 'big' && $r->big == $news->id) ? '' : $r->big;
|
|
|
- $r->small1 = ($field != 'small1' && $r->small1 == $news->id) ? '' : $r->small1;
|
|
|
- $r->small2 = ($field != 'small2' && $r->small2 == $news->id) ? '' : $r->small2;
|
|
|
- $r->small3 = ($field != 'small3' && $r->small3 == $news->id) ? '' : $r->small3;
|
|
|
- $r->small4 = ($field != 'small4' && $r->small4 == $news->id) ? '' : $r->small4;
|
|
|
- $r->small5 = ($field != 'small5' && $r->small5 == $news->id) ? '' : $r->small5;
|
|
|
- $r->small6 = ($field != 'small6' && $r->small6 == $news->id) ? '' : $r->small6;
|
|
|
- $r->$field = $news->id;
|
|
|
- $r->save();
|
|
|
-
|
|
|
- // CLEARLAYOUT
|
|
|
- $r->clearLayout();
|
|
|
- }
|
|
|
- if ($_POST["region_2_position"] != '')
|
|
|
- {
|
|
|
- $field = $input["region_2_position"];
|
|
|
- $r = Section::findOrFail($input["region_2_id"]);
|
|
|
- $r->big = ($field != 'big' && $r->big == $news->id) ? '' : $r->big;
|
|
|
- $r->small1 = ($field != 'small1' && $r->small1 == $news->id) ? '' : $r->small1;
|
|
|
- $r->small2 = ($field != 'small2' && $r->small2 == $news->id) ? '' : $r->small2;
|
|
|
- $r->small3 = ($field != 'small3' && $r->small3 == $news->id) ? '' : $r->small3;
|
|
|
- $r->small4 = ($field != 'small4' && $r->small4 == $news->id) ? '' : $r->small4;
|
|
|
- $r->small5 = ($field != 'small5' && $r->small5 == $news->id) ? '' : $r->small5;
|
|
|
- $r->small6 = ($field != 'small6' && $r->small6 == $news->id) ? '' : $r->small6;
|
|
|
- $r->$field = $news->id;
|
|
|
- $r->save();
|
|
|
-
|
|
|
- // CLEARLAYOUT
|
|
|
- $r->clearLayout();
|
|
|
- }
|
|
|
- */
|
|
|
if (isset($input['publish']))
|
|
|
return redirect()->route('news.index')->with('success','News updated successfully');
|
|
|
|
|
|
@@ -429,9 +373,9 @@ class NewsController extends Controller
|
|
|
{
|
|
|
return redirect()->route('news.index')->with('success','News updated successfully');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Display the specified resource.
|
|
|
*
|
|
|
@@ -442,7 +386,7 @@ class NewsController extends Controller
|
|
|
{
|
|
|
return view('news.show',compact('news'));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Show the form for editing the specified resource.
|
|
|
*
|
|
|
@@ -472,75 +416,7 @@ class NewsController extends Controller
|
|
|
list($year, $month, $day) = explode("-", $dt);
|
|
|
$final_date = $day . "/" . $month . "/" . $year . " " . $time;
|
|
|
}
|
|
|
- /*
|
|
|
- $section_position = '';
|
|
|
- if ($news->section_id > 0)
|
|
|
- {
|
|
|
- if ($news->section->big == $news->id)
|
|
|
- $section_position = 'big';
|
|
|
- if ($news->section->small1 == $news->id)
|
|
|
- $section_position = 'small1';
|
|
|
- if ($news->section->small2 == $news->id)
|
|
|
- $section_position = 'small2';
|
|
|
- if ($news->section->small3 == $news->id)
|
|
|
- $section_position = 'small3';
|
|
|
- if ($news->section->small4 == $news->id)
|
|
|
- $section_position = 'small4';
|
|
|
- if ($news->section->small5 == $news->id)
|
|
|
- $section_position = 'small5';
|
|
|
- if ($news->section->small6 == $news->id)
|
|
|
- $section_position = 'small6';
|
|
|
-
|
|
|
- if ($section_position == null)
|
|
|
- $section_position = $news->section_position;
|
|
|
-
|
|
|
|
|
|
- }
|
|
|
- $region_1_position = '';
|
|
|
- if ($news->region_1_id > 0)
|
|
|
- {
|
|
|
- if ($news->region_1->big == $news->id)
|
|
|
- $region_1_position = 'big';
|
|
|
- if ($news->region_1->small1 == $news->id)
|
|
|
- $region_1_position = 'small1';
|
|
|
- if ($news->region_1->small2 == $news->id)
|
|
|
- $region_1_position = 'small2';
|
|
|
- if ($news->region_1->small3 == $news->id)
|
|
|
- $region_1_position = 'small3';
|
|
|
- if ($news->region_1->small4 == $news->id)
|
|
|
- $region_1_position = 'small4';
|
|
|
- if ($news->region_1->small5 == $news->id)
|
|
|
- $region_1_position = 'small5';
|
|
|
- if ($news->region_1->small6 == $news->id)
|
|
|
- $region_1_position = 'small6';
|
|
|
-
|
|
|
- if ($region_1_position == '')
|
|
|
- $region_1_position = $news->region_1_position;
|
|
|
-
|
|
|
- }
|
|
|
- $region_2_position = '';
|
|
|
- if ($news->region_2_id > 0)
|
|
|
- {
|
|
|
- if ($news->region_2->big == $news->id)
|
|
|
- $region_2_position = 'big';
|
|
|
- if ($news->region_2->small1 == $news->id)
|
|
|
- $region_2_position = 'small1';
|
|
|
- if ($news->region_2->small2 == $news->id)
|
|
|
- $region_2_position = 'small2';
|
|
|
- if ($news->region_2->small3 == $news->id)
|
|
|
- $region_2_position = 'small3';
|
|
|
- if ($news->region_2->small4 == $news->id)
|
|
|
- $region_2_position = 'small4';
|
|
|
- if ($news->region_2->small5 == $news->id)
|
|
|
- $region_2_position = 'small5';
|
|
|
- if ($news->region_2->small6 == $news->id)
|
|
|
- $region_2_position = 'small6';
|
|
|
-
|
|
|
- if ($region_2_position == '')
|
|
|
- $region_2_position = $news->region_2_position;
|
|
|
-
|
|
|
- }
|
|
|
- */
|
|
|
$section_position = $news->section_position;
|
|
|
$region_1_position = $news->region_1_position;
|
|
|
$region_2_position = $news->region_2_position;
|
|
|
@@ -571,7 +447,7 @@ class NewsController extends Controller
|
|
|
{
|
|
|
if (isset($home["left" . $a]) && $home["left" . $a] != '')
|
|
|
$aFirst[] = $home["left" . $a]["title"] . " (slide sinistra)";
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
for($a=1;$a<=5;$a++)
|
|
|
{
|
|
|
@@ -581,12 +457,12 @@ class NewsController extends Controller
|
|
|
$first = '<li>' . implode("</li><li>", $aFirst) . '</li>';
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
$news->date = $final_date;
|
|
|
|
|
|
return view('news.edit',compact('news', 'sections', 'regions', 'pages', 'events', 'layouts', 'section_position', 'region_1_position', 'region_2_position', 'first'));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Update the specified resource in storage.
|
|
|
*
|
|
|
@@ -611,12 +487,6 @@ class NewsController extends Controller
|
|
|
{
|
|
|
if ($news->section->big == $news->id)
|
|
|
$section_position = 'big';
|
|
|
- /*if ($news->section->medium1 == $news->id)
|
|
|
- $section_position = 'medium1';
|
|
|
- if ($news->section->medium2 == $news->id)
|
|
|
- $section_position = 'medium2';
|
|
|
- if ($news->section->medium3 == $news->id)
|
|
|
- $section_position = 'medium3';*/
|
|
|
if ($news->section->small1 == $news->id)
|
|
|
$section_position = 'small1';
|
|
|
if ($news->section->small2 == $news->id)
|
|
|
@@ -629,7 +499,7 @@ class NewsController extends Controller
|
|
|
$section_position = 'small5';
|
|
|
if ($news->section->small6 == $news->id)
|
|
|
$section_position = 'small6';
|
|
|
-
|
|
|
+
|
|
|
if ($section_position == null)
|
|
|
$section_position = $news->section_position;
|
|
|
|
|
|
@@ -640,12 +510,6 @@ class NewsController extends Controller
|
|
|
{
|
|
|
if ($news->region_1->big == $news->id)
|
|
|
$region_1_position = 'big';
|
|
|
- /*if ($news->region_1->medium1 == $news->id)
|
|
|
- $region_1_position = 'medium1';
|
|
|
- if ($news->region_1->medium2 == $news->id)
|
|
|
- $region_1_position = 'medium2';
|
|
|
- if ($news->region_1->medium3 == $news->id)
|
|
|
- $region_1_position = 'medium3';*/
|
|
|
if ($news->region_1->small1 == $news->id)
|
|
|
$region_1_position = 'small1';
|
|
|
if ($news->region_1->small2 == $news->id)
|
|
|
@@ -668,12 +532,6 @@ class NewsController extends Controller
|
|
|
{
|
|
|
if ($news->region_2->big == $news->id)
|
|
|
$region_2_position = 'big';
|
|
|
- /*if ($news->region_2->medium1 == $news->id)
|
|
|
- $region_2_position = 'medium1';
|
|
|
- if ($news->region_2->medium2 == $news->id)
|
|
|
- $region_2_position = 'medium2';
|
|
|
- if ($news->region_2->medium3 == $news->id)
|
|
|
- $region_2_position = 'medium3';*/
|
|
|
if ($news->region_2->small1 == $news->id)
|
|
|
$region_2_position = 'small1';
|
|
|
if ($news->region_2->small2 == $news->id)
|
|
|
@@ -694,7 +552,7 @@ class NewsController extends Controller
|
|
|
|
|
|
if ($old_section_id == $input["section_id"] && $section_position == $input["section_position"])
|
|
|
unset($input["section_position"]);
|
|
|
-
|
|
|
+
|
|
|
if ($old_region_1_id == $input["region_1_id"] && $region_1_position == $input["region_1_position"])
|
|
|
unset($input["region_1_position"]);
|
|
|
|
|
|
@@ -709,7 +567,7 @@ class NewsController extends Controller
|
|
|
|
|
|
if (! File::exists(public_path()."/files/news"))
|
|
|
File::makeDirectory(public_path()."/files/news");
|
|
|
-
|
|
|
+
|
|
|
$path = public_path('files/news');
|
|
|
|
|
|
request()->image->move($path, $filename);
|
|
|
@@ -727,7 +585,7 @@ class NewsController extends Controller
|
|
|
|
|
|
if (! File::exists(public_path()."/files/news"))
|
|
|
File::makeDirectory(public_path()."/files/news");
|
|
|
-
|
|
|
+
|
|
|
$path = public_path('files/news');
|
|
|
|
|
|
$input["image" . $i]->move($path, $filename);
|
|
|
@@ -749,7 +607,7 @@ class NewsController extends Controller
|
|
|
|
|
|
if (! File::exists(public_path()."/files/news"))
|
|
|
File::makeDirectory(public_path()."/files/news");
|
|
|
-
|
|
|
+
|
|
|
$path = public_path('files/news');
|
|
|
|
|
|
request()->pdf->move($path, $filename);
|
|
|
@@ -771,7 +629,7 @@ class NewsController extends Controller
|
|
|
$input["homepage"] = isset($input["homepage"]) ? ($input["homepage"] == 'on' ? true : false) : false;
|
|
|
$input["live"] = isset($input["live"]) ? ($input["live"] == 'on' ? true : false) : false;
|
|
|
$input["breaking_news"] = isset($input["breaking_news"]) ? ($input["breaking_news"] == 'on' ? true : false) : false;
|
|
|
-
|
|
|
+
|
|
|
$news->update($input);
|
|
|
|
|
|
$news->user_id = null;
|
|
|
@@ -780,7 +638,7 @@ class NewsController extends Controller
|
|
|
|
|
|
if (isset($input['publish']))
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
$news->online = true;
|
|
|
$news->save();
|
|
|
|
|
|
@@ -790,16 +648,16 @@ class NewsController extends Controller
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- @$news->notify(new FacebookPost());
|
|
|
- $news->notify(new TwitterPost());
|
|
|
+
|
|
|
$news->published = true;
|
|
|
$news->save();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if (isset($input['unpublish']))
|
|
|
{
|
|
|
$news->online = false;
|
|
|
+
|
|
|
$news->save();
|
|
|
}
|
|
|
|
|
|
@@ -810,11 +668,11 @@ class NewsController extends Controller
|
|
|
{
|
|
|
$home->fill([
|
|
|
$_POST["homepage_position"] => $news->id
|
|
|
- ]);
|
|
|
+ ]);
|
|
|
$home->save();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ($news->event_id != $old_event_id)
|
|
|
{
|
|
|
$e = Event::where('id', '=', $old_event_id)->first();
|
|
|
@@ -834,262 +692,14 @@ class NewsController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- // Posizione
|
|
|
- if ($_POST["section_position"] != '')
|
|
|
- {
|
|
|
-
|
|
|
- if ($input["section_id"] == '')
|
|
|
- {
|
|
|
- if ($old_section_id > 0)
|
|
|
- {
|
|
|
- $s_old = Section::findOrFail($old_section_id);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- // Se online e data > adesso
|
|
|
- if ($news->online && $news->data < date("Y-m-d H:i:s"))
|
|
|
- {
|
|
|
-
|
|
|
- $field = $input["section_position"];
|
|
|
- $s = Section::findOrFail($input["section_id"]);
|
|
|
-
|
|
|
- // Se ho cambiato sezione, tolgo dalla vecchia me metto nella nuova
|
|
|
- if ($input["section_id"] != $old_section_id)
|
|
|
- {
|
|
|
- if ($old_section_id > 0)
|
|
|
- {
|
|
|
- $s_old = Section::findOrFail($old_section_id);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $s->big = ($field != 'big' && $s->big == $news->id) ? '' : $s->big;
|
|
|
- $s->small1 = ($field != 'small1' && $s->small1 == $news->id) ? '' : $s->small1;
|
|
|
- $s->small2 = ($field != 'small2' && $s->small2 == $news->id) ? '' : $s->small2;
|
|
|
- $s->small3 = ($field != 'small3' && $s->small3 == $news->id) ? '' : $s->small3;
|
|
|
- $s->small4 = ($field != 'small4' && $s->small4 == $news->id) ? '' : $s->small4;
|
|
|
- $s->small5 = ($field != 'small5' && $s->small5 == $news->id) ? '' : $s->small5;
|
|
|
- $s->small6 = ($field != 'small6' && $s->small6 == $news->id) ? '' : $s->small6;
|
|
|
- }
|
|
|
- $s->$field = $news->id;
|
|
|
- $s->save();
|
|
|
-
|
|
|
- // CLEARLAYOUT
|
|
|
- $s->clearLayout();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- if ($input["section_id"] == '')
|
|
|
- {
|
|
|
- if ($old_section_id > 0)
|
|
|
- {
|
|
|
- $s_old = Section::findOrFail($old_section_id);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if ($input["section_id"] != $old_section_id)
|
|
|
- {
|
|
|
- $s_old = Section::findOrFail($old_section_id);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- $s_old = Section::findOrFail($input["section_id"]);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- print $s_old->small3;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if ($_POST["region_1_position"] != '')
|
|
|
- {
|
|
|
-
|
|
|
- if ($input["region_1_id"] == '')
|
|
|
- {
|
|
|
-
|
|
|
- if ($old_region_1_id > 0)
|
|
|
- {
|
|
|
- $s_old = Section::findOrFail($old_region_1_id);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- $field = $input["region_1_position"];
|
|
|
- $r = Section::findOrFail($input["region_1_id"]);
|
|
|
- // Se ho cambiato sezione, tolgo dalla vecchia me metto nella nuova
|
|
|
- if ($input["region_1_id"] != $old_region_1_id)
|
|
|
- {
|
|
|
- if ($old_region_1_id > 0)
|
|
|
- {
|
|
|
- $s_old = Section::findOrFail($old_region_1_id);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $r->big = ($field != 'big' && $r->big == $news->id) ? '' : $r->big;
|
|
|
- $r->small1 = ($field != 'small1' && $r->small1 == $news->id) ? '' : $r->small1;
|
|
|
- $r->small2 = ($field != 'small2' && $r->small2 == $news->id) ? '' : $r->small2;
|
|
|
- $r->small3 = ($field != 'small3' && $r->small3 == $news->id) ? '' : $r->small3;
|
|
|
- $r->small4 = ($field != 'small4' && $r->small4 == $news->id) ? '' : $r->small4;
|
|
|
- $r->small5 = ($field != 'small5' && $r->small5 == $news->id) ? '' : $r->small5;
|
|
|
- $r->small6 = ($field != 'small6' && $r->small6 == $news->id) ? '' : $r->small6;
|
|
|
- }
|
|
|
- $r->$field = $news->id;
|
|
|
- $r->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $r->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
- if ($_POST["region_2_position"] != '')
|
|
|
- {
|
|
|
-
|
|
|
- if ($input["region_2_id"] == '')
|
|
|
- {
|
|
|
- if ($old_region_2_id > 0)
|
|
|
- {
|
|
|
- $s_old = Section::findOrFail($old_region_2_id);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- $field = $input["region_2_position"];
|
|
|
- $r = Section::findOrFail($input["region_2_id"]);
|
|
|
- // Se ho cambiato sezione, tolgo dalla vecchia me metto nella nuova
|
|
|
- if ($input["region_2_id"] != $old_region_2_id)
|
|
|
- {
|
|
|
- if ($old_region_2_id > 0)
|
|
|
- {
|
|
|
- $s_old = Section::findOrFail($old_region_2_id);
|
|
|
- $s_old->big = ($s_old->big == $news->id) ? '' : $s_old->big;
|
|
|
- $s_old->small1 = ($s_old->small1 == $news->id) ? '' : $s_old->small1;
|
|
|
- $s_old->small2 = ($s_old->small2 == $news->id) ? '' : $s_old->small2;
|
|
|
- $s_old->small3 = ($s_old->small3 == $news->id) ? '' : $s_old->small3;
|
|
|
- $s_old->small4 = ($s_old->small4 == $news->id) ? '' : $s_old->small4;
|
|
|
- $s_old->small5 = ($s_old->small5 == $news->id) ? '' : $s_old->small5;
|
|
|
- $s_old->small6 = ($s_old->small6 == $news->id) ? '' : $s_old->small6;
|
|
|
- $s_old->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $s_old->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $r->big = ($field != 'big' && $r->big == $news->id) ? '' : $r->big;
|
|
|
- $r->small1 = ($field != 'small1' && $r->small1 == $news->id) ? '' : $r->small1;
|
|
|
- $r->small2 = ($field != 'small2' && $r->small2 == $news->id) ? '' : $r->small2;
|
|
|
- $r->small3 = ($field != 'small3' && $r->small3 == $news->id) ? '' : $r->small3;
|
|
|
- $r->small4 = ($field != 'small4' && $r->small4 == $news->id) ? '' : $r->small4;
|
|
|
- $r->small5 = ($field != 'small5' && $r->small5 == $news->id) ? '' : $r->small5;
|
|
|
- $r->small6 = ($field != 'small6' && $r->small6 == $news->id) ? '' : $r->small6;
|
|
|
- }
|
|
|
- $r->$field = $news->id;
|
|
|
- $r->save();
|
|
|
- // CLEARLAYOUT
|
|
|
- $r->clearLayout();
|
|
|
- }
|
|
|
- }
|
|
|
- */
|
|
|
if (isset($input['publish']))
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
return redirect()->route('news.index')->with('success','News updated successfully');
|
|
|
}
|
|
|
if (isset($input['crop']))
|
|
|
{
|
|
|
return redirect('/admin/news/crop?news_id=' . $news->id);
|
|
|
- // return redirect()->route('news.crop')->with('success','News updated successfully');
|
|
|
}
|
|
|
if (isset($input['unpublish']))
|
|
|
{
|
|
|
@@ -1105,7 +715,7 @@ class NewsController extends Controller
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Remove the specified resource from storage.
|
|
|
*
|
|
|
@@ -1117,38 +727,22 @@ class NewsController extends Controller
|
|
|
$section = null;
|
|
|
if (isset($news->section))
|
|
|
{
|
|
|
- $section = $news->section;
|
|
|
+ $section = $news->section;
|
|
|
}
|
|
|
$region_1 = null;
|
|
|
if (isset($news->region_1))
|
|
|
{
|
|
|
- $region_1 = $news->region_1;
|
|
|
+ $region_1 = $news->region_1;
|
|
|
}
|
|
|
$region_2 = null;
|
|
|
if (isset($news->region_2))
|
|
|
{
|
|
|
- $region_2 = $news->region_2;
|
|
|
+ $region_2 = $news->region_2;
|
|
|
}
|
|
|
|
|
|
$news->delete();
|
|
|
|
|
|
- /*if ($section != null)
|
|
|
- {
|
|
|
- // CLEARLAYOUT
|
|
|
- $section->clearLayout();
|
|
|
- }
|
|
|
- if ($region_1 != null)
|
|
|
- {
|
|
|
- // CLEARLAYOUT
|
|
|
- $region_1->clearLayout();
|
|
|
- }
|
|
|
- if ($region_2 != null)
|
|
|
- {
|
|
|
- // CLEARLAYOUT
|
|
|
- $region_2->clearLayout();
|
|
|
- }*/
|
|
|
-
|
|
|
return redirect()->route('news.index')
|
|
|
->with('success','News deleted successfully');
|
|
|
}
|
|
|
-}
|
|
|
+}
|